Fix FFmpeg reader function

It should return AVERROR_EOF when reaching the end of the stream, rather
than returning zero. When it returns zero, the avformat prober will just
loop endlessly until the process is terminated.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2022-01-26 20:55:28 -08:00
parent 0415b263a3
commit 2db8e56ef2

View File

@ -218,7 +218,7 @@ static int ffmpeg_read(void* opaque, uint8_t* buf, int read_size) {
if (data->logical_offset + read_size > data->logical_size)
read_size = data->logical_size - data->logical_offset;
if (read_size == 0)
return bytes;
return AVERROR_EOF;
/* handle reads on inserted header */
if (data->header_size && data->logical_offset < data->header_size) {
@ -232,7 +232,7 @@ static int ffmpeg_read(void* opaque, uint8_t* buf, int read_size) {
data->logical_offset += max_to_copy;
if (read_size == 0) {
return max_to_copy; /* offset still in header */
return max_to_copy ? max_to_copy : AVERROR_EOF; /* offset still in header */
}
}