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

LibAudio: WAV reading should stop when we run out of file. :^)

This commit is contained in:
Andreas Kling 2019-07-27 18:54:03 +02:00
parent e6eba24405
commit 68c20e50da

View file

@ -18,11 +18,14 @@ AWavLoader::AWavLoader(const StringView& path)
RefPtr<ABuffer> AWavLoader::get_more_samples()
{
#ifdef AWAVLOADER_DEBUG
dbgprintf("Read WAV of format PCM with num_channels %u sample rate %u, bits per sample %u\n", m_num_channels, m_sample_rate, m_bits_per_sample);
#endif
auto raw_samples = m_file.read(128 * KB);
auto buffer = ABuffer::from_pcm_data(raw_samples, m_num_channels, m_bits_per_sample, m_sample_rate);
return buffer;
if (raw_samples.is_empty())
return nullptr;
return ABuffer::from_pcm_data(raw_samples, m_num_channels, m_bits_per_sample, m_sample_rate);
}
bool AWavLoader::parse_header()