1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

LibAudio: Use read_until_filled to fill a buffer from a Stream

This has the advantage of recognizing when the Stream reaches EOF and
avoids an endless loop.
This commit is contained in:
Tim Schumacher 2023-04-12 16:15:49 +02:00 committed by Tim Flynn
parent 4098335600
commit 708387b850

View file

@ -250,12 +250,7 @@ ErrorOr<FlacRawMetadataBlock, LoaderError> FlacLoaderPlugin::next_meta_block(Big
FLAC_VERIFY(!block_data_result.is_error(), LoaderError::Category::IO, "Out of memory"); FLAC_VERIFY(!block_data_result.is_error(), LoaderError::Category::IO, "Out of memory");
auto block_data = block_data_result.release_value(); auto block_data = block_data_result.release_value();
// Blocks might exceed our buffer size. LOADER_TRY(bit_input.read_until_filled(block_data));
auto bytes_left_to_read = block_data.bytes();
while (bytes_left_to_read.size()) {
auto read_bytes = LOADER_TRY(bit_input.read_some(bytes_left_to_read));
bytes_left_to_read = bytes_left_to_read.slice(read_bytes.size());
}
m_data_start_location += block_length; m_data_start_location += block_length;
return FlacRawMetadataBlock { return FlacRawMetadataBlock {