decoder/Client: add virtual method Read()
This commit is contained in:
@@ -80,51 +80,15 @@ FakeDecoder::OpenUri(const char *uri)
|
||||
}
|
||||
|
||||
size_t
|
||||
decoder_read(gcc_unused DecoderClient *client,
|
||||
InputStream &is,
|
||||
void *buffer, size_t length)
|
||||
FakeDecoder::Read(InputStream &is, void *buffer, size_t length)
|
||||
{
|
||||
try {
|
||||
return is.LockRead(buffer, length);
|
||||
} catch (const std::runtime_error &) {
|
||||
} catch (const std::runtime_error &e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
decoder_read_full(DecoderClient *client, InputStream &is,
|
||||
void *_buffer, size_t size)
|
||||
{
|
||||
uint8_t *buffer = (uint8_t *)_buffer;
|
||||
|
||||
while (size > 0) {
|
||||
size_t nbytes = decoder_read(client, is, buffer, size);
|
||||
if (nbytes == 0)
|
||||
return false;
|
||||
|
||||
buffer += nbytes;
|
||||
size -= nbytes;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
decoder_skip(DecoderClient *client, InputStream &is, size_t size)
|
||||
{
|
||||
while (size > 0) {
|
||||
char buffer[1024];
|
||||
size_t nbytes = decoder_read(client, is, buffer,
|
||||
std::min(sizeof(buffer), size));
|
||||
if (nbytes == 0)
|
||||
return false;
|
||||
|
||||
size -= nbytes;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
FakeDecoder::SubmitTimestamp(gcc_unused double t)
|
||||
{
|
||||
|
Reference in New Issue
Block a user