From de61d9c5337d3e0fd2cffbdb2ff39c7e11c299d0 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Thu, 13 Sep 2007 19:20:53 +0000 Subject: [PATCH] [MOVED FROM GST-P-FARSIGHT] Make sure to unlock the thread when going to ready and to flush the queue when moving to paused or playing 20070913192053-4f0f6-76c3925380d1a30988286170535a65dea64a5583.gz --- gst/dtmf/gstdtmfsrc.c | 62 +++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/gst/dtmf/gstdtmfsrc.c b/gst/dtmf/gstdtmfsrc.c index f642558737..06fc50278d 100644 --- a/gst/dtmf/gstdtmfsrc.c +++ b/gst/dtmf/gstdtmfsrc.c @@ -715,9 +715,25 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition) GstDTMFSrc *dtmfsrc; GstStateChangeReturn result; gboolean no_preroll = FALSE; + GstDTMFSrcEvent *event = NULL; dtmfsrc = GST_DTMF_SRC (element); + switch (transition) { + case GST_STATE_CHANGE_READY_TO_PAUSED: + case GST_STATE_CHANGE_PAUSED_TO_PLAYING: + /* Flushing the event queue */ + event = g_async_queue_try_pop (dtmfsrc->event_queue); + + while (event != NULL) { + g_free (event); + event = g_async_queue_try_pop (dtmfsrc->event_queue); + } + break; + default: + break; + } + if ((result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition)) == GST_STATE_CHANGE_FAILURE) @@ -725,30 +741,30 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: - { - GstDTMFSrcEvent *event = NULL; - - /* TODO lock the element */ - - if (dtmfsrc->last_event) { - /* Don't forget to release the stream lock */ - gst_dtmf_src_set_stream_lock (dtmfsrc, FALSE); - g_free (dtmfsrc->last_event); - dtmfsrc->last_event = NULL; - } - - /* Flushing the event queue */ - event = g_async_queue_try_pop (dtmfsrc->event_queue); - - while (event != NULL) { - g_free (event); - event = g_async_queue_try_pop (dtmfsrc->event_queue); - } - - /* Indicate that we don't do PRE_ROLL */ - no_preroll = TRUE; - break; + if (dtmfsrc->last_event) { + /* Don't forget to release the stream lock */ + gst_dtmf_src_set_stream_lock (dtmfsrc, FALSE); + g_free (dtmfsrc->last_event); + dtmfsrc->last_event = NULL; } + + /* Flushing the event queue */ + event = g_async_queue_try_pop (dtmfsrc->event_queue); + + while (event != NULL) { + g_free (event); + event = g_async_queue_try_pop (dtmfsrc->event_queue); + } + + /* Indicate that we don't do PRE_ROLL */ + no_preroll = TRUE; + break; + case GST_STATE_CHANGE_PAUSED_TO_READY: + event = g_malloc (sizeof(GstDTMFSrcEvent)); + event->event_type = DTMF_EVENT_TYPE_PAUSE_TASK; + g_async_queue_push (dtmfsrc->event_queue, event); + + event = NULL; default: break; }