diff --git a/daemon/codec.c b/daemon/codec.c index 474124b18..8c9e13885 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -283,9 +283,7 @@ static void __dtmf_dsp_shutdown(struct call_media *sink, int payload_type) { if (!sink->codec_handlers) return; - GList *list = g_hash_table_get_values(sink->codec_handlers); - - for (GList *l = list; l; l = l->next) { + for (GList *l = sink->codec_handlers_store.head; l; l = l->next) { struct codec_handler *handler = l->data; if (!handler->transcoder) continue; @@ -299,8 +297,6 @@ static void __dtmf_dsp_shutdown(struct call_media *sink, int payload_type) { payload_type); handler->dtmf_payload_type = -1; } - - g_list_free(list); } // call must be locked in W @@ -308,8 +304,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink, const struct sdp_ng_flags *flags) { if (!receiver->codec_handlers) - receiver->codec_handlers = g_hash_table_new_full(g_int_hash, g_int_equal, - NULL, __codec_handler_free); + receiver->codec_handlers = g_hash_table_new(g_int_hash, g_int_equal); MEDIA_CLEAR(receiver, TRANSCODE); receiver->rtcp_handler = NULL; @@ -536,6 +531,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink, handler = __handler_new(pt); g_hash_table_insert(receiver->codec_handlers, &handler->source_pt.payload_type, handler); + g_queue_push_tail(&receiver->codec_handlers_store, handler); } // check our own support for this codec @@ -717,6 +713,7 @@ void codec_handlers_free(struct call_media *m) { g_hash_table_destroy(m->codec_handlers); m->codec_handlers = NULL; m->codec_handler_cache = NULL; + g_queue_clear_full(&m->codec_handlers_store, __codec_handler_free); } diff --git a/include/call.h b/include/call.h index 37538405c..ac5dba04e 100644 --- a/include/call.h +++ b/include/call.h @@ -319,6 +319,7 @@ struct call_media { GHashTable *codec_handlers; // int payload type -> struct codec_handler // XXX combine this with 'codecs_recv' hash table? + GQueue codec_handlers_store; // storage for struct codec_handler volatile struct codec_handler *codec_handler_cache; struct rtcp_handler *rtcp_handler;