mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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
This commit is contained in:
parent
eeea911c2e
commit
fb9ca25f7f
1 changed files with 10 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue