mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
LibAudio: Handle unknown-sized streams better
Especially FLAC had an issue here before, but the loader infrastructure itself wouldn't handle end of stream properly if the "available samples" information didn't match up.
This commit is contained in:
parent
e9e95b1899
commit
fc70d88367
3 changed files with 16 additions and 3 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <LibAudio/FlacTypes.h>
|
||||
#include <LibAudio/GenericTypes.h>
|
||||
#include <LibAudio/LoaderError.h>
|
||||
#include <LibAudio/MultiChannel.h>
|
||||
#include <LibAudio/Resampler.h>
|
||||
#include <LibAudio/VorbisComment.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -338,7 +339,7 @@ ErrorOr<Vector<FixedArray<Sample>>, LoaderError> FlacLoaderPlugin::load_chunks(s
|
|||
{
|
||||
ssize_t remaining_samples = static_cast<ssize_t>(m_total_samples - m_loaded_samples);
|
||||
// The first condition is relevant for unknown-size streams (total samples = 0 in the header)
|
||||
if (m_stream->is_eof() || remaining_samples <= 0)
|
||||
if (m_stream->is_eof() || (m_total_samples < NumericLimits<u64>::max() && remaining_samples <= 0))
|
||||
return Vector<FixedArray<Sample>> {};
|
||||
|
||||
size_t samples_to_read = min(samples_to_read_from_input, remaining_samples);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue