From 628bc44ca54fade186fb12830e5ee1335c027dc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 27 Jul 2012 12:58:40 +0200 Subject: [PATCH] streamsynchronizer: Unblock streams on FLUSH_START events --- gst/playback/gststreamsynchronizer.c | 39 +++++++++++++++++++++------- gst/playback/gststreamsynchronizer.h | 1 - 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c index a50194957a..fd78697ce3 100644 --- a/gst/playback/gststreamsynchronizer.c +++ b/gst/playback/gststreamsynchronizer.c @@ -74,6 +74,8 @@ typedef struct gboolean seen_data; gint64 running_time_diff; + + GCond *stream_finish_cond; } GstStream; /* Must be called with lock! */ @@ -306,7 +308,10 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent, GST_DEBUG_OBJECT (self, "New group start time: %" GST_TIME_FORMAT, GST_TIME_ARGS (self->group_start_time)); - g_cond_broadcast (self->stream_finish_cond); + for (l = self->streams; l; l = l->next) { + GstStream *ostream = l->data; + g_cond_broadcast (ostream->stream_finish_cond); + } } } GST_STREAM_SYNCHRONIZER_UNLOCK (self); @@ -323,7 +328,7 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent, if (stream) { if (stream->wait) { GST_DEBUG_OBJECT (pad, "Stream %d is waiting", stream->stream_number); - g_cond_wait (self->stream_finish_cond, self->lock); + g_cond_wait (stream->stream_finish_cond, self->lock); stream = gst_pad_get_element_private (pad); if (stream) stream->wait = FALSE; @@ -401,6 +406,18 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent, GST_STREAM_SYNCHRONIZER_UNLOCK (self); break; } + case GST_EVENT_FLUSH_START:{ + GstStream *stream; + + GST_STREAM_SYNCHRONIZER_LOCK (self); + stream = gst_pad_get_element_private (pad); + if (stream) { + GST_DEBUG_OBJECT (pad, "Flushing streams"); + g_cond_broadcast (stream->stream_finish_cond); + } + GST_STREAM_SYNCHRONIZER_UNLOCK (self); + break; + } case GST_EVENT_FLUSH_STOP:{ GstStream *stream; @@ -640,6 +657,7 @@ gst_stream_synchronizer_request_new_pad (GstElement * element, stream = g_slice_new0 (GstStream); stream->transform = self; stream->stream_number = self->current_stream_number; + stream->stream_finish_cond = g_cond_new (); tmp = g_strdup_printf ("sink_%u", self->current_stream_number); stream->sinkpad = gst_pad_new_from_static_template (&sinktemplate, tmp); @@ -732,6 +750,7 @@ gst_stream_synchronizer_release_stream (GstStreamSynchronizer * self, self->group_start_time = MAX (self->group_start_time, stop_running_time); } + g_cond_free (stream->stream_finish_cond); g_slice_free (GstStream, stream); /* NOTE: In theory we have to check here if all streams @@ -783,13 +802,19 @@ gst_stream_synchronizer_change_state (GstElement * element, case GST_STATE_CHANGE_PAUSED_TO_PLAYING: GST_DEBUG_OBJECT (self, "State change PAUSED->PLAYING"); break; - case GST_STATE_CHANGE_PAUSED_TO_READY: + case GST_STATE_CHANGE_PAUSED_TO_READY:{ + GList *l; + GST_DEBUG_OBJECT (self, "State change READY->NULL"); GST_STREAM_SYNCHRONIZER_LOCK (self); - g_cond_broadcast (self->stream_finish_cond); + for (l = self->streams; l; l = l->next) { + GstStream *ostream = l->data; + g_cond_broadcast (ostream->stream_finish_cond); + } self->shutdown = TRUE; GST_STREAM_SYNCHRONIZER_UNLOCK (self); + } default: break; } @@ -854,11 +879,6 @@ gst_stream_synchronizer_finalize (GObject * object) self->lock = NULL; } - if (self->stream_finish_cond) { - g_cond_free (self->stream_finish_cond); - self->stream_finish_cond = NULL; - } - G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -867,7 +887,6 @@ static void gst_stream_synchronizer_init (GstStreamSynchronizer * self) { self->lock = g_mutex_new (); - self->stream_finish_cond = g_cond_new (); } static void diff --git a/gst/playback/gststreamsynchronizer.h b/gst/playback/gststreamsynchronizer.h index e2379ae3b7..32b6c69bb8 100644 --- a/gst/playback/gststreamsynchronizer.h +++ b/gst/playback/gststreamsynchronizer.h @@ -46,7 +46,6 @@ struct _GstStreamSynchronizer /* < private > */ GMutex *lock; - GCond *stream_finish_cond; gboolean shutdown; GList *streams; -- 2.34.1