SoundPlayer: Log loader errors and otherwise ignore them for now

Playback can resume after encountering loader errors (though not
always). Ideally, these should be visible to the user and the loader
state should be reset after encountering such errors. This patch
also has the side effect of not crashing on seek when playing MP3 files
(However, it still does not seek to the correct location) :^)
This commit is contained in:
Arda Cinar 2023-01-16 22:48:37 +03:00 committed by Jelle Raaijmakers
parent cbb6f8de65
commit f7fe9e3355
Notes: sideshowbarker 2024-07-17 01:34:21 +09:00

View File

@ -114,10 +114,16 @@ void PlaybackManager::next_buffer()
return;
}
// FIXME: This should handle parsing failures gracefully and show them to the user.
auto buffer = m_loader->get_more_samples(m_samples_to_load_per_buffer).release_value();
auto buffer_or_error = m_loader->get_more_samples(m_samples_to_load_per_buffer);
if (buffer_or_error.is_error()) {
// FIXME: These errors should be shown to the user instead of being logged and then ignored
dbgln("Error while loading samples: {}", buffer_or_error.error().description);
return;
}
auto buffer = buffer_or_error.release_value();
m_current_buffer.swap(buffer);
VERIFY(m_resampler.has_value());
m_resampler->reset();
// FIXME: Handle OOM better.
auto resampled = MUST(FixedArray<Audio::Sample>::try_create(m_resampler->resample(move(m_current_buffer)).span()));