MT#59038 switch to transparent union for callback

Change-Id: I5270c8d01d7c66662257c8bfa45219961de9b234
pull/1802/head
Richard Fuchs 1 year ago
parent 64fd7b8c1c
commit 8db00bb652

@ -37,9 +37,9 @@ struct mqtt_timer {
}; };
struct timer_callback { struct timer_callback {
struct codec_timer ct; struct codec_timer ct;
void (*timer_callback_func)(call_t *, void *); void (*timer_callback_func)(call_t *, codec_timer_callback_arg_t);
call_t *call; call_t *call;
void *ptr; codec_timer_callback_arg_t arg;
}; };
typedef void (*raw_input_func_t)(struct media_packet *mp, unsigned int); typedef void (*raw_input_func_t)(struct media_packet *mp, unsigned int);
@ -5638,16 +5638,18 @@ static void __codec_timer_callback_free(void *p) {
static void __codec_timer_callback_fire(struct codec_timer *ct) { static void __codec_timer_callback_fire(struct codec_timer *ct) {
struct timer_callback *cb = (void *) ct; struct timer_callback *cb = (void *) ct;
log_info_call(cb->call); log_info_call(cb->call);
cb->timer_callback_func(cb->call, cb->ptr); cb->timer_callback_func(cb->call, cb->arg);
codec_timer_stop(&ct); codec_timer_stop(&ct);
log_info_pop(); log_info_pop();
} }
void codec_timer_callback(call_t *c, void (*func)(call_t *, void *), void *p, uint64_t delay) { void codec_timer_callback(call_t *c, void (*func)(call_t *, codec_timer_callback_arg_t),
codec_timer_callback_arg_t a, uint64_t delay)
{
struct timer_callback *cb = obj_alloc0("codec_timer_callback", sizeof(*cb), __codec_timer_callback_free); struct timer_callback *cb = obj_alloc0("codec_timer_callback", sizeof(*cb), __codec_timer_callback_free);
cb->ct.tt_obj.tt = &codec_timers_thread; cb->ct.tt_obj.tt = &codec_timers_thread;
cb->call = obj_get(c); cb->call = obj_get(c);
cb->timer_callback_func = func; cb->timer_callback_func = func;
cb->ptr = p; cb->arg = a;
cb->ct.timer_func = __codec_timer_callback_fire; cb->ct.timer_func = __codec_timer_callback_fire;
cb->ct.next = rtpe_now; cb->ct.next = rtpe_now;
timeval_add_usec(&cb->ct.next, delay); timeval_add_usec(&cb->ct.next, delay);

@ -264,8 +264,8 @@ void dtmf_trigger_set(struct call_monologue *ml, enum dtmf_trigger_type trigger_
state->inactive = inactive; state->inactive = inactive;
} }
static void dtmf_trigger_set_block(call_t *c, void *mlp) { static void dtmf_trigger_set_block(call_t *c, codec_timer_callback_arg_t a) {
struct call_monologue *ml = mlp; struct call_monologue *ml = a.ml;
rwlock_lock_w(&c->master_lock); rwlock_lock_w(&c->master_lock);
@ -290,8 +290,8 @@ static void dtmf_trigger_set_block(call_t *c, void *mlp) {
rwlock_unlock_w(&c->master_lock); rwlock_unlock_w(&c->master_lock);
} }
static void dtmf_trigger_unset_block(call_t *c, void *mlp) { static void dtmf_trigger_unset_block(call_t *c, codec_timer_callback_arg_t a) {
struct call_monologue *ml = mlp; struct call_monologue *ml = a.ml;
ilog(LOG_INFO, "Setting DTMF block mode to %i", ml->block_dtmf_trigger_end); ilog(LOG_INFO, "Setting DTMF block mode to %i", ml->block_dtmf_trigger_end);

@ -89,12 +89,17 @@ struct codec_scheduler {
long output_skew; long output_skew;
}; };
typedef union {
struct call_monologue *ml;
} codec_timer_callback_arg_t __attribute__ ((__transparent_union__));
void codecs_init(void); void codecs_init(void);
void codecs_cleanup(void); void codecs_cleanup(void);
void codec_timers_loop(void *); void codec_timers_loop(void *);
void rtcp_timer_stop(struct rtcp_timer **); void rtcp_timer_stop(struct rtcp_timer **);
void codec_timer_callback(call_t *, void (*)(call_t *, void *), void *, uint64_t delay); void codec_timer_callback(call_t *, void (*)(call_t *, codec_timer_callback_arg_t),
codec_timer_callback_arg_t, uint64_t delay);
void mqtt_timer_stop(struct mqtt_timer **); void mqtt_timer_stop(struct mqtt_timer **);
void mqtt_timer_start(struct mqtt_timer **mqtp, call_t *call, struct call_media *media); void mqtt_timer_start(struct mqtt_timer **mqtp, call_t *call, struct call_media *media);

Loading…
Cancel
Save