Return AVERROR_EOF from the avio_read method when appropriate.
[dcpomatic.git] / src / lib / ffmpeg.cc
index 6c8509b6cd71de2eef9e5a75e3c58b2e9f1cd87f..8220962d64d27077428b773f0df28ff44bd53377 100644 (file)
@@ -273,7 +273,11 @@ FFmpeg::subtitle_codec_context () const
 int
 FFmpeg::avio_read (uint8_t* buffer, int const amount)
 {
-       return _file_group.read (buffer, amount);
+       auto result = _file_group.read(buffer, amount);
+       if (result.eof && result.bytes_read == 0) {
+               return AVERROR_EOF;
+       }
+       return result.bytes_read;
 }