asfdemux: Handle issues with "empty" files

In some corrupted files, we could end up with no actual streams
being exposed.

In those cases, make sure we properly propagate the failure all
the way to the loop function. This avoids ending up in cases where
we are neither EOS'd nor ERROR'd out from a pipeline point of view.

https://bugzilla.gnome.org/show_bug.cgi?id=774846
This commit is contained in:
Edward Hervey 2016-11-22 16:22:49 +01:00 committed by Edward Hervey
parent aab716ac40
commit 45c7826d76

View file

@ -1493,7 +1493,7 @@ gst_asf_demux_update_caps_from_payload (GstASFDemux * demux, AsfStream * stream)
static gboolean static gboolean
gst_asf_demux_check_activate_streams (GstASFDemux * demux, gboolean force) gst_asf_demux_check_activate_streams (GstASFDemux * demux, gboolean force)
{ {
guint i; guint i, actual_streams = 0;
if (demux->activated_streams) if (demux->activated_streams)
return TRUE; return TRUE;
@ -1522,11 +1522,18 @@ gst_asf_demux_check_activate_streams (GstASFDemux * demux, gboolean force)
* a stream, then we active it, or we don't, then we'll ignore it */ * a stream, then we active it, or we don't, then we'll ignore it */
GST_LOG_OBJECT (stream->pad, "is prerolled - activate!"); GST_LOG_OBJECT (stream->pad, "is prerolled - activate!");
gst_asf_demux_activate_stream (demux, stream); gst_asf_demux_activate_stream (demux, stream);
actual_streams += 1;
} else { } else {
GST_LOG_OBJECT (stream->pad, "no data, ignoring stream"); GST_LOG_OBJECT (stream->pad, "no data, ignoring stream");
} }
} }
if (actual_streams == 0) {
/* We don't have any streams activated ! */
GST_ERROR_OBJECT (demux, "No streams activated!");
return FALSE;
}
gst_asf_demux_release_old_pads (demux); gst_asf_demux_release_old_pads (demux);
demux->activated_streams = TRUE; demux->activated_streams = TRUE;
@ -2078,7 +2085,7 @@ eos:
* less data queued than required for preroll; force stream activation and * less data queued than required for preroll; force stream activation and
* send any pending payloads before sending EOS */ * send any pending payloads before sending EOS */
if (!demux->activated_streams) if (!demux->activated_streams)
gst_asf_demux_push_complete_payloads (demux, TRUE); flow = gst_asf_demux_push_complete_payloads (demux, TRUE);
/* we want to push an eos or post a segment-done in any case */ /* we want to push an eos or post a segment-done in any case */
if (demux->segment.flags & GST_SEEK_FLAG_SEGMENT) { if (demux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
@ -2105,9 +2112,14 @@ eos:
} }
if (!(demux->segment.flags & GST_SEEK_FLAG_SEGMENT)) { if (!(demux->segment.flags & GST_SEEK_FLAG_SEGMENT)) {
/* normal playback, send EOS to all linked pads */ if (demux->activated_streams) {
GST_INFO_OBJECT (demux, "Sending EOS, at end of stream"); /* normal playback, send EOS to all linked pads */
gst_asf_demux_send_event_unlocked (demux, gst_event_new_eos ()); GST_INFO_OBJECT (demux, "Sending EOS, at end of stream");
gst_asf_demux_send_event_unlocked (demux, gst_event_new_eos ());
} else {
GST_WARNING_OBJECT (demux, "EOS without exposed streams");
flow = GST_FLOW_EOS;
}
} }
/* ... and fall through to pause */ /* ... and fall through to pause */
} }
@ -2119,7 +2131,10 @@ pause:
gst_pad_pause_task (demux->sinkpad); gst_pad_pause_task (demux->sinkpad);
/* For the error cases */ /* For the error cases */
if (flow < GST_FLOW_EOS || flow == GST_FLOW_NOT_LINKED) { if (flow == GST_FLOW_EOS && !demux->activated_streams) {
GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL),
("This doesn't seem to be an ASF file"));
} else if (flow < GST_FLOW_EOS || flow == GST_FLOW_NOT_LINKED) {
/* Post an error. Hopefully something else already has, but if not... */ /* Post an error. Hopefully something else already has, but if not... */
GST_ELEMENT_FLOW_ERROR (demux, flow); GST_ELEMENT_FLOW_ERROR (demux, flow);
gst_asf_demux_send_event_unlocked (demux, gst_event_new_eos ()); gst_asf_demux_send_event_unlocked (demux, gst_event_new_eos ());