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

SoundPlayer: Reduce sample buffer size and add a sample load event

This commit is contained in:
Cesar Torres 2021-03-21 13:43:27 +01:00 committed by Andreas Kling
parent 7aa5297835
commit f9e4bff487
3 changed files with 10 additions and 3 deletions

View file

@ -128,13 +128,16 @@ void PlaybackManager::load_next_buffer()
if (m_buffers.size() < 10) {
for (int i = 0; i < 20 && m_loader->loaded_samples() < m_loader->total_samples(); i++) {
auto buffer = m_loader->get_more_samples(PLAYBACK_MANAGER_BUFFER_SIZE);
if (buffer)
if (buffer) {
m_buffers.append(buffer);
}
}
}
if (m_next_ptr < m_buffers.size()) {
m_next_buffer = m_buffers.at(m_next_ptr++);
if (on_load_sample_buffer)
on_load_sample_buffer(*m_next_buffer);
} else {
m_next_buffer = nullptr;
}
@ -163,7 +166,6 @@ void PlaybackManager::next_buffer()
{
if (on_update)
on_update();
if (m_paused)
return;