From f7fe9e33557d2d28e5f533988af3abd3f653e294 Mon Sep 17 00:00:00 2001 From: Arda Cinar Date: Mon, 16 Jan 2023 22:48:37 +0300 Subject: [PATCH] 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) :^) --- Userland/Applications/SoundPlayer/PlaybackManager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp index 6ff75ec624..89aa11fc48 100644 --- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp +++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp @@ -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::try_create(m_resampler->resample(move(m_current_buffer)).span()));