mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
matroskademux: refactor eos sending when pausing loop
Also, prevent hanging if no pads yet on which to send eos by posting a message instead.
This commit is contained in:
parent
ae515fead4
commit
59224d77f8
1 changed files with 18 additions and 7 deletions
|
@ -2062,12 +2062,14 @@ gst_matroska_demux_found_global_tag (GstMatroskaDemux * demux,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* takes ownership of the passed event! */
|
/* returns FALSE if there are no pads to deliver event to,
|
||||||
|
* otherwise TRUE (whatever the outcome of event sending),
|
||||||
|
* takes ownership of the passed event! */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event)
|
gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event)
|
||||||
{
|
{
|
||||||
gboolean is_newsegment;
|
gboolean is_newsegment;
|
||||||
gboolean ret = TRUE;
|
gboolean ret = FALSE;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
g_return_val_if_fail (event != NULL, FALSE);
|
g_return_val_if_fail (event != NULL, FALSE);
|
||||||
|
@ -2085,6 +2087,7 @@ gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event)
|
||||||
stream = g_ptr_array_index (demux->src, i);
|
stream = g_ptr_array_index (demux->src, i);
|
||||||
gst_event_ref (event);
|
gst_event_ref (event);
|
||||||
gst_pad_push_event (stream->pad, event);
|
gst_pad_push_event (stream->pad, event);
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
/* FIXME: send global tags before stream tags */
|
/* FIXME: send global tags before stream tags */
|
||||||
if (G_UNLIKELY (is_newsegment && stream->pending_tags != NULL)) {
|
if (G_UNLIKELY (is_newsegment && stream->pending_tags != NULL)) {
|
||||||
|
@ -5163,6 +5166,8 @@ pause:
|
||||||
gst_pad_pause_task (demux->sinkpad);
|
gst_pad_pause_task (demux->sinkpad);
|
||||||
|
|
||||||
if (GST_FLOW_IS_FATAL (ret) || ret == GST_FLOW_NOT_LINKED) {
|
if (GST_FLOW_IS_FATAL (ret) || ret == GST_FLOW_NOT_LINKED) {
|
||||||
|
gboolean push_eos = TRUE;
|
||||||
|
|
||||||
if (ret == GST_FLOW_UNEXPECTED) {
|
if (ret == GST_FLOW_UNEXPECTED) {
|
||||||
/* perform EOS logic */
|
/* perform EOS logic */
|
||||||
|
|
||||||
|
@ -5190,15 +5195,21 @@ pause:
|
||||||
gst_element_post_message (GST_ELEMENT (demux),
|
gst_element_post_message (GST_ELEMENT (demux),
|
||||||
gst_message_new_segment_done (GST_OBJECT (demux), GST_FORMAT_TIME,
|
gst_message_new_segment_done (GST_OBJECT (demux), GST_FORMAT_TIME,
|
||||||
stop));
|
stop));
|
||||||
} else {
|
push_eos = FALSE;
|
||||||
/* normal playback, send EOS to all linked pads */
|
|
||||||
GST_LOG_OBJECT (demux, "Sending EOS, at end of stream");
|
|
||||||
gst_matroska_demux_send_event (demux, gst_event_new_eos ());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/* for fatal errors we post an error message */
|
||||||
GST_ELEMENT_ERROR (demux, STREAM, FAILED, (NULL),
|
GST_ELEMENT_ERROR (demux, STREAM, FAILED, (NULL),
|
||||||
("stream stopped, reason %s", reason));
|
("stream stopped, reason %s", reason));
|
||||||
gst_matroska_demux_send_event (demux, gst_event_new_eos ());
|
}
|
||||||
|
if (push_eos) {
|
||||||
|
/* send EOS, and prevent hanging if no streams yet */
|
||||||
|
GST_LOG_OBJECT (demux, "Sending EOS, at end of stream");
|
||||||
|
if (!gst_matroska_demux_send_event (demux, gst_event_new_eos ()) &&
|
||||||
|
(ret == GST_FLOW_UNEXPECTED)) {
|
||||||
|
GST_ELEMENT_ERROR (demux, STREAM, DEMUX,
|
||||||
|
(NULL), ("got eos but no streams (yet)"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue