diff --git a/src/input/plugins/FfmpegInputPlugin.cxx b/src/input/plugins/FfmpegInputPlugin.cxx index 3de948759..198f4bd17 100644 --- a/src/input/plugins/FfmpegInputPlugin.cxx +++ b/src/input/plugins/FfmpegInputPlugin.cxx @@ -31,8 +31,6 @@ class FfmpegInputStream final : public InputStream { Ffmpeg::IOContext io; - bool eof = false; - public: FfmpegInputStream(const char *_uri, Mutex &_mutex) :InputStream(_uri, _mutex), @@ -90,11 +88,6 @@ FfmpegInputStream::Read(void *ptr, size_t read_size) result = io.Read(ptr, read_size); } - if (result == 0) { - eof = true; - return 0; - } - offset += result; return (size_t)result; } @@ -102,7 +95,7 @@ FfmpegInputStream::Read(void *ptr, size_t read_size) bool FfmpegInputStream::IsEOF() noexcept { - return eof; + return io.IsEOF(); } void @@ -116,7 +109,6 @@ FfmpegInputStream::Seek(offset_type new_offset) } offset = result; - eof = false; } static constexpr const char *ffmpeg_prefixes[] = { diff --git a/src/lib/ffmpeg/IOContext.hxx b/src/lib/ffmpeg/IOContext.hxx index c2a3e3409..6530f3568 100644 --- a/src/lib/ffmpeg/IOContext.hxx +++ b/src/lib/ffmpeg/IOContext.hxx @@ -70,6 +70,11 @@ public: return avio_size(io_context); } + gcc_pure + bool IsEOF() const noexcept { + return avio_feof(io_context) != 0; + } + size_t Read(void *buffer, size_t size) { int result = avio_read_partial(io_context, (unsigned char *)buffer, size);