summaryrefslogtreecommitdiff
path: root/gst/playback/gststreamsynchronizer.c
diff options
context:
space:
mode:
authorSong Bing <b06498@freescale.com>2015-02-15 13:51:36 +0800
committerSebastian Dröge <sebastian@centricular.com>2015-02-16 14:34:35 +0200
commitfb9ca25f7f0ee850f73b2c323a2c3a8e7d2d92fc (patch)
treea3a544277802e5a7814a890fe5c95c8f7f764b4a /gst/playback/gststreamsynchronizer.c
parenteeea911c2e477cc51ed72ac5ce2da34caa4115e3 (diff)
streamsynchronizer: Use the same waiting function for EOS and stream switches
Also improve the waiting condition for stream switches, which was assuming before that the condition variable will only stop waiting once when it is signaled. But the documentation says that there might be spurious wakeups. https://bugzilla.gnome.org/show_bug.cgi?id=736655
Diffstat (limited to 'gst/playback/gststreamsynchronizer.c')
-rw-r--r--gst/playback/gststreamsynchronizer.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c
index 50fc7b9c6..f69a7f335 100644
--- a/gst/playback/gststreamsynchronizer.c
+++ b/gst/playback/gststreamsynchronizer.c
@@ -215,13 +215,17 @@ gst_stream_synchronizer_wait (GstStreamSynchronizer * self, GstPad * pad)
while (!self->eos && !self->flushing) {
stream = gst_pad_get_element_private (pad);
if (!stream) {
- GST_WARNING_OBJECT (pad, "EOS for unknown stream");
+ GST_WARNING_OBJECT (pad, "unknown stream");
return ret;
}
if (stream->flushing) {
GST_DEBUG_OBJECT (pad, "Flushing");
break;
}
+ if (!stream->wait) {
+ GST_DEBUG_OBJECT (pad, "Stream not waiting anymore");
+ break;
+ }
if (self->send_gap_event) {
GstEvent *event;
@@ -383,6 +387,7 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
for (l = self->streams; l; l = l->next) {
GstStream *ostream = l->data;
+ ostream->wait = FALSE;
g_cond_broadcast (&ostream->stream_finish_cond);
}
}
@@ -398,16 +403,8 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
gst_event_copy_segment (event, &segment);
GST_STREAM_SYNCHRONIZER_LOCK (self);
- stream = gst_pad_get_element_private (pad);
- if (stream) {
- if (stream->wait) {
- GST_DEBUG_OBJECT (pad, "Stream %d is waiting", stream->stream_number);
- g_cond_wait (&stream->stream_finish_cond, &self->lock);
- stream = gst_pad_get_element_private (pad);
- if (stream)
- stream->wait = FALSE;
- }
- }
+
+ gst_stream_synchronizer_wait (self, pad);
if (self->shutdown) {
GST_STREAM_SYNCHRONIZER_UNLOCK (self);
@@ -415,6 +412,7 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
goto done;
}
+ stream = gst_pad_get_element_private (pad);
if (stream && segment.format == GST_FORMAT_TIME) {
if (stream->new_stream) {
stream->new_stream = FALSE;
@@ -552,6 +550,7 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
if (seen_data) {
self->send_gap_event = TRUE;
stream->gap_duration = GST_CLOCK_TIME_NONE;
+ stream->wait = TRUE;
ret = gst_stream_synchronizer_wait (self, srcpad);
}
}