mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +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
Notes:
sideshowbarker
2024-07-19 11:22:00 +09:00
Author: https://github.com/tlmrgvf Commit: https://github.com/SerenityOS/serenity/commit/94a96499453 Pull-request: https://github.com/SerenityOS/serenity/pull/737
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue