rtpdtmfsrc: Cleanup events on finalize

Problem found by Laurent Glayal

Fixes bug #591440
This commit is contained in:
Tim-Philipp Müller 2009-08-11 16:23:20 -04:00 committed by Olivier Crête
parent 5bc1290431
commit 0d697e8b58

View file

@ -301,6 +301,16 @@ gst_rtp_dtmf_src_class_init (GstRTPDTMFSrcClass * klass)
gstbasesrc_class->negotiate = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_negotiate); gstbasesrc_class->negotiate = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_negotiate);
} }
static void
gst_rtp_dtmf_src_event_free (GstRTPDTMFSrcEvent * event)
{
if (event) {
g_free (event->payload);
event->payload = NULL;
g_free (event);
}
}
static void static void
gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object, GstRTPDTMFSrcClass * g_class) gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object, GstRTPDTMFSrcClass * g_class)
{ {
@ -315,7 +325,8 @@ gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object, GstRTPDTMFSrcClass * g_class)
object->interval = DEFAULT_PACKET_INTERVAL; object->interval = DEFAULT_PACKET_INTERVAL;
object->packet_redundancy = DEFAULT_PACKET_REDUNDANCY; object->packet_redundancy = DEFAULT_PACKET_REDUNDANCY;
object->event_queue = g_async_queue_new (); object->event_queue =
g_async_queue_new_full ((GDestroyNotify) gst_rtp_dtmf_src_event_free);
object->payload = NULL; object->payload = NULL;
GST_DEBUG_OBJECT (object, "init done"); GST_DEBUG_OBJECT (object, "init done");
@ -997,7 +1008,7 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition)
/* Flushing the event queue */ /* Flushing the event queue */
while ((event = g_async_queue_try_pop (dtmfsrc->event_queue)) != NULL) while ((event = g_async_queue_try_pop (dtmfsrc->event_queue)) != NULL)
g_free (event); gst_rtp_dtmf_src_event_free (event);
no_preroll = TRUE; no_preroll = TRUE;
break; break;
@ -1018,7 +1029,7 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition)
/* Flushing the event queue */ /* Flushing the event queue */
while ((event = g_async_queue_try_pop (dtmfsrc->event_queue)) != NULL) while ((event = g_async_queue_try_pop (dtmfsrc->event_queue)) != NULL)
g_free (event); gst_rtp_dtmf_src_event_free (event);
/* Indicate that we don't do PRE_ROLL */ /* Indicate that we don't do PRE_ROLL */
break; break;