input/buffering: pass offset to Read() and eliminate Seek()

Another step towards supporting multiple readers.
This commit is contained in:
Max Kellermann
2019-05-17 10:52:39 +02:00
parent 813567bf5c
commit 555a4d738c
3 changed files with 38 additions and 84 deletions

View File

@@ -46,11 +46,10 @@ BufferedInputStream::Check()
}
void
BufferedInputStream::Seek(std::unique_lock<Mutex> &lock,
BufferedInputStream::Seek(std::unique_lock<Mutex> &,
offset_type new_offset)
{
BufferingInputStream::Seek(lock, new_offset);
InputStream::offset = new_offset;
offset = new_offset;
}
bool
@@ -62,14 +61,14 @@ BufferedInputStream::IsEOF() noexcept
bool
BufferedInputStream::IsAvailable() noexcept
{
return BufferingInputStream::IsAvailable();
return BufferingInputStream::IsAvailable(offset);
}
size_t
BufferedInputStream::Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t s)
{
size_t nbytes = BufferingInputStream::Read(lock, ptr, s);
size_t nbytes = BufferingInputStream::Read(lock, offset, ptr, s);
InputStream::offset += nbytes;
return nbytes;
}