summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Petersson <joel.anders.petersson@gmail.com>2023-05-01 19:07:37 +0200
committerJelle Raaijmakers <jelle@gmta.nl>2023-05-02 09:15:20 +0200
commite98315de6b290a1cf9ee31bda3d6289bb9bebae5 (patch)
tree00873be08b8699c32670ced5e38d38eee3333b44
parentf1d8e551688c627fa9a32d3279c1fc6b7b73596a (diff)
downloadserenity-e98315de6b290a1cf9ee31bda3d6289bb9bebae5.zip
SoundPlayer: Fix glitchy visualization on pause/stop
Previously when pausing or stoping a track in SoundPlayer, the visualizations would glitch out. This was caused by them being updated with the same buffer over and over. With this patch a pause action will freeze the visualization at the point of the pause and a stop action will reset the visualization so it displays nothing until a track is started.
-rw-r--r--Userland/Applications/SoundPlayer/Player.cpp3
-rw-r--r--Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Applications/SoundPlayer/Player.cpp b/Userland/Applications/SoundPlayer/Player.cpp
index fcc5a2d09d..ee479d017c 100644
--- a/Userland/Applications/SoundPlayer/Player.cpp
+++ b/Userland/Applications/SoundPlayer/Player.cpp
@@ -21,7 +21,8 @@ Player::Player(Audio::ConnectionToServer& audio_client_connection)
auto played_seconds = samples_played / sample_rate;
time_elapsed(played_seconds);
- sound_buffer_played(m_playback_manager.current_buffer(), m_playback_manager.device_sample_rate(), samples_played);
+ if (play_state() == PlayState::Playing)
+ sound_buffer_played(m_playback_manager.current_buffer(), m_playback_manager.device_sample_rate(), samples_played);
};
m_playback_manager.on_finished_playing = [&]() {
set_play_state(PlayState::Stopped);
diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
index 7d63df2a93..57345df9e7 100644
--- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
+++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
@@ -213,6 +213,10 @@ void SoundPlayerWidgetAdvancedView::play_state_changed(Player::PlayState state)
m_stop_action->set_enabled(state != PlayState::Stopped && state != PlayState::NoFileLoaded);
m_playback_progress_slider->set_enabled(state != PlayState::NoFileLoaded);
+ if (state == PlayState::Stopped) {
+ m_playback_progress_slider->set_value(m_playback_progress_slider->min(), GUI::AllowCallback::No);
+ m_visualization->reset_buffer();
+ }
}
void SoundPlayerWidgetAdvancedView::loop_mode_changed(Player::LoopMode)