SoundPlayer: Don't try to dereference null-pointer buffers

d049626f40 tried to resample the buffer
before checking if it points to a valid location.
This caused a crash, generally at the end of the file.
This commit is contained in:
Karol Kosek 2021-09-03 18:49:38 +02:00 committed by Andreas Kling
parent 0139a56aa5
commit d81ba98976
Notes: sideshowbarker 2024-07-19 17:15:47 +09:00

View file

@ -118,10 +118,11 @@ void PlaybackManager::next_buffer()
if (audio_server_remaining_samples < m_device_samples_per_buffer) {
m_current_buffer = m_loader->get_more_samples(m_source_buffer_size_bytes);
VERIFY(m_resampler.has_value());
m_resampler->reset();
m_current_buffer = Audio::resample_buffer(m_resampler.value(), *m_current_buffer);
if (m_current_buffer)
if (m_current_buffer) {
VERIFY(m_resampler.has_value());
m_resampler->reset();
m_current_buffer = Audio::resample_buffer(m_resampler.value(), *m_current_buffer);
m_connection->enqueue(*m_current_buffer);
}
}
}