input/ffmpeg: use avio_feof(), eliminate eof
attribute
This commit is contained in:
parent
bfb7b0117f
commit
cb100f2e5c
@ -31,8 +31,6 @@
|
|||||||
class FfmpegInputStream final : public InputStream {
|
class FfmpegInputStream final : public InputStream {
|
||||||
Ffmpeg::IOContext io;
|
Ffmpeg::IOContext io;
|
||||||
|
|
||||||
bool eof = false;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FfmpegInputStream(const char *_uri, Mutex &_mutex)
|
FfmpegInputStream(const char *_uri, Mutex &_mutex)
|
||||||
:InputStream(_uri, _mutex),
|
:InputStream(_uri, _mutex),
|
||||||
@ -90,11 +88,6 @@ FfmpegInputStream::Read(void *ptr, size_t read_size)
|
|||||||
result = io.Read(ptr, read_size);
|
result = io.Read(ptr, read_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0) {
|
|
||||||
eof = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += result;
|
offset += result;
|
||||||
return (size_t)result;
|
return (size_t)result;
|
||||||
}
|
}
|
||||||
@ -102,7 +95,7 @@ FfmpegInputStream::Read(void *ptr, size_t read_size)
|
|||||||
bool
|
bool
|
||||||
FfmpegInputStream::IsEOF() noexcept
|
FfmpegInputStream::IsEOF() noexcept
|
||||||
{
|
{
|
||||||
return eof;
|
return io.IsEOF();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -116,7 +109,6 @@ FfmpegInputStream::Seek(offset_type new_offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
offset = result;
|
offset = result;
|
||||||
eof = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr const char *ffmpeg_prefixes[] = {
|
static constexpr const char *ffmpeg_prefixes[] = {
|
||||||
|
@ -70,6 +70,11 @@ public:
|
|||||||
return avio_size(io_context);
|
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) {
|
size_t Read(void *buffer, size_t size) {
|
||||||
int result = avio_read_partial(io_context,
|
int result = avio_read_partial(io_context,
|
||||||
(unsigned char *)buffer, size);
|
(unsigned char *)buffer, size);
|
||||||
|
Loading…
Reference in New Issue
Block a user