Skip to content

Commit

Permalink
LibAudio: WAV reading should stop when we run out of file. :^)
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jul 27, 2019
1 parent e6eba24 commit 68c20e5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Libraries/LibAudio/AWavLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 68c20e5

Please sign in to comment.