Differentiate between "no more data" from "IO failure" when reading.

Where no more data is available, av_read_frame just returns an error code
instead of making the difference between "I am not returning anything because
we finished reading" and "I am not returning anything because the underlying
read failed".

We differentiate between the two by looking at whether we outputted any
data previously or not.
This commit is contained in:
Edward Hervey 2009-01-27 15:59:25 +01:00
parent 965f23f4f1
commit 89c3c79d5e

View file

@ -387,6 +387,7 @@ gst_ffmpegdemux_is_eos (GstFFMpegDemux * demux)
for (n = 0; n < MAX_STREAMS; n++) {
if ((s = demux->streams[n])) {
GST_DEBUG ("stream %d %p eos:%d", n, s, s->eos);
if (!s->eos)
return FALSE;
}
@ -394,6 +395,22 @@ gst_ffmpegdemux_is_eos (GstFFMpegDemux * demux)
return TRUE;
}
/* Returns True if we at least outputted one buffer */
static gboolean
gst_ffmpegdemux_has_outputted (GstFFMpegDemux * demux)
{
GstFFStream *s;
gint n;
for (n = 0; n < MAX_STREAMS; n++) {
if ((s = demux->streams[n])) {
if (GST_CLOCK_TIME_IS_VALID (s->last_ts))
return TRUE;
}
}
return FALSE;
}
static gboolean
gst_ffmpegdemux_do_seek (GstFFMpegDemux * demux, GstSegment * segment)
{
@ -1446,7 +1463,11 @@ read_failed:
/* pause appropriatly based on if we are flushing or not */
if (demux->flushing)
ret = GST_FLOW_WRONG_STATE;
else
else if (gst_ffmpegdemux_has_outputted (demux)
|| gst_ffmpegdemux_is_eos (demux)) {
GST_DEBUG_OBJECT (demux, "We are EOS");
ret = GST_FLOW_UNEXPECTED;
} else
ret = GST_FLOW_ERROR;
GST_OBJECT_UNLOCK (demux);