decoder/API: add decoder_read_much()
This commit is contained in:
@@ -42,6 +42,27 @@ decoder_read(DecoderClient *client,
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
decoder_read_much(DecoderClient *client, InputStream &is,
|
||||
void *_buffer, size_t size) noexcept
|
||||
{
|
||||
uint8_t *buffer = (uint8_t *)_buffer;
|
||||
|
||||
size_t total = 0;
|
||||
|
||||
while (size > 0 && !is.LockIsEOF()) {
|
||||
size_t nbytes = decoder_read(client, is, buffer, size);
|
||||
if (nbytes == 0)
|
||||
return false;
|
||||
|
||||
total += nbytes;
|
||||
buffer += nbytes;
|
||||
size -= nbytes;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
bool
|
||||
decoder_read_full(DecoderClient *client, InputStream &is,
|
||||
void *_buffer, size_t size) noexcept
|
||||
|
||||
Reference in New Issue
Block a user