mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
AWavLoader: Fixed incorrect computation of m_loaded_samples
m_loaded_samples was incremented with the value of the processed buffer. This causes m_loaded_samples to be bigger at some point than m_total_samples when downsampling, as the buffer would contain more samples than actually loaded.
This commit is contained in:
parent
173ae370db
commit
94a9649945
1 changed files with 3 additions and 1 deletions
|
@ -27,7 +27,9 @@ RefPtr<ABuffer> AWavLoader::get_more_samples(size_t max_bytes_to_read_from_input
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto buffer = ABuffer::from_pcm_data(raw_samples, *m_resampler, m_num_channels, m_bits_per_sample);
|
auto buffer = ABuffer::from_pcm_data(raw_samples, *m_resampler, m_num_channels, m_bits_per_sample);
|
||||||
m_loaded_samples += buffer->sample_count();
|
//Buffer contains normalized samples, but m_loaded_samples should containt the ammount of actually loaded samples
|
||||||
|
m_loaded_samples += static_cast<int>(max_bytes_to_read_from_input) / (m_num_channels * (m_bits_per_sample / 8));
|
||||||
|
m_loaded_samples = min(m_total_samples, m_loaded_samples);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue