adaptivedemux: prevent early EOS when switching at last fragment

Check if there is a next fragment before advancing to avoid causing
a bitrate switch (and maybe exposing new pads) only to push EOS.
This causes playback to stop with an error instead of properly
finishing with EOS message.
This commit is contained in:
Thiago Santos 2015-01-16 16:18:35 -03:00
parent 6dca8f5cce
commit 3a79bd91c7

View file

@ -1937,8 +1937,14 @@ gst_adaptive_demux_stream_download_loop (GstAdaptiveDemuxStream * stream)
g_clear_error (&stream->last_error);
if (GST_CLOCK_TIME_IS_VALID (stream->fragment.duration))
stream->segment.position += stream->fragment.duration;
ret = gst_adaptive_demux_stream_advance_fragment (demux, stream);
GST_DEBUG_OBJECT (stream->pad, "Advancing to next fragment");
if (gst_adaptive_demux_stream_has_next_fragment (demux, stream)) {
ret = gst_adaptive_demux_stream_advance_fragment (demux, stream);
GST_DEBUG_OBJECT (stream->pad, "Advanced. Result: %d %s", ret,
gst_flow_get_name (ret));
if (ret == GST_FLOW_OK) {
if (gst_adaptive_demux_stream_select_bitrate (demux, stream,
gst_adaptive_demux_stream_update_current_bitrate (stream))) {
stream->need_header = TRUE;
@ -1957,7 +1963,11 @@ gst_adaptive_demux_stream_download_loop (GstAdaptiveDemuxStream * stream)
goto end_of_manifest;
}
}
} else {
GST_DEBUG_OBJECT (stream->pad, "No next fragment -> EOS");
ret = GST_FLOW_EOS;
}
}
stream->last_ret = ret;
switch (ret) {