From 7b540cdb20fe3225b26251d0400300d0ebbd4dc7 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 31 May 2026 10:52:15 +0200 Subject: [PATCH] cellMusic: don't send status callback if we just keep playing automatically --- rpcs3/Emu/Cell/Modules/cellMusic.cpp | 6 +++--- rpcs3/Emu/Io/Null/null_music_handler.h | 2 +- rpcs3/Emu/Io/music_handler_base.h | 8 ++++---- rpcs3/rpcs3qt/qt_music_handler.cpp | 4 ++-- rpcs3/rpcs3qt/qt_music_handler.h | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMusic.cpp b/rpcs3/Emu/Cell/Modules/cellMusic.cpp index d3b40f729b..0d9d4ebf3c 100644 --- a/rpcs3/Emu/Cell/Modules/cellMusic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMusic.cpp @@ -102,7 +102,7 @@ struct music_state // Let's just play the next song for now if (current_selection_context.content_type == CELL_SEARCH_CONTENTTYPE_MUSICLIST && handler->get_state() == CELL_MUSIC_PB_STATUS_PLAY) { - if (const error_code error = set_playback_command(CELL_MUSIC_PB_CMD_NEXT)) + if (const error_code error = set_playback_command(CELL_MUSIC_PB_CMD_NEXT, true)) { cellMusic.error("Failed to play next track. error=0x%x", +error); } @@ -135,7 +135,7 @@ struct music_state } // NOTE: This function only uses CELL_MUSIC enums. CELL_MUSIC2 enums are identical. - error_code set_playback_command(s32 command) + error_code set_playback_command(s32 command, bool automatic = false) { switch (command) { @@ -196,7 +196,7 @@ struct music_state handler->fast_reverse(path); break; default: - handler->play(path); + handler->play(path, automatic); break; } diff --git a/rpcs3/Emu/Io/Null/null_music_handler.h b/rpcs3/Emu/Io/Null/null_music_handler.h index fcf2bf0f1c..f8f2258171 100644 --- a/rpcs3/Emu/Io/Null/null_music_handler.h +++ b/rpcs3/Emu/Io/Null/null_music_handler.h @@ -9,7 +9,7 @@ public: void stop() override { set_state(0); } // CELL_MUSIC_PB_STATUS_STOP void pause() override { set_state(2); } // CELL_MUSIC_PB_STATUS_PAUSE - void play(const std::string& /*path*/) override { set_state(1); } // CELL_MUSIC_PB_STATUS_PLAY + void play(const std::string& /*path*/, bool automatic = false) override { set_state(1, automatic); } // CELL_MUSIC_PB_STATUS_PLAY void fast_forward(const std::string& /*path*/) override { set_state(3); } // CELL_MUSIC_PB_STATUS_FASTFORWARD void fast_reverse(const std::string& /*path*/) override { set_state(4); } // CELL_MUSIC_PB_STATUS_FASTREVERSE void set_volume(f32 volume) override { m_volume = volume; } diff --git a/rpcs3/Emu/Io/music_handler_base.h b/rpcs3/Emu/Io/music_handler_base.h index 2fddeab359..28079c508a 100644 --- a/rpcs3/Emu/Io/music_handler_base.h +++ b/rpcs3/Emu/Io/music_handler_base.h @@ -15,17 +15,17 @@ public: virtual void stop() = 0; virtual void pause() = 0; - virtual void play(const std::string& path) = 0; + virtual void play(const std::string& path, bool automatic = false) = 0; virtual void fast_forward(const std::string& path) = 0; virtual void fast_reverse(const std::string& path) = 0; virtual void set_volume(f32 volume) = 0; virtual f32 get_volume() const = 0; - void set_state(u32 state) + void set_state(u32 state, bool automatic = false) { - m_state = state; + const bool changed = m_state.exchange(state) != state; - if (m_event_status_callback) + if (m_event_status_callback && (changed || !automatic)) { m_event_status_callback(state); } diff --git a/rpcs3/rpcs3qt/qt_music_handler.cpp b/rpcs3/rpcs3qt/qt_music_handler.cpp index 6152e9c098..f17e0e6d92 100644 --- a/rpcs3/rpcs3qt/qt_music_handler.cpp +++ b/rpcs3/rpcs3qt/qt_music_handler.cpp @@ -113,7 +113,7 @@ void qt_music_handler::pause() set_state(CELL_MUSIC_PB_STATUS_PAUSE); } -void qt_music_handler::play(const std::string& path) +void qt_music_handler::play(const std::string& path, bool automatic) { std::lock_guard lock(m_mutex); @@ -135,7 +135,7 @@ void qt_music_handler::play(const std::string& path) m_media_player->play(); }); - set_state(CELL_MUSIC_PB_STATUS_PLAY); + set_state(CELL_MUSIC_PB_STATUS_PLAY, automatic); } void qt_music_handler::fast_forward(const std::string& path) diff --git a/rpcs3/rpcs3qt/qt_music_handler.h b/rpcs3/rpcs3qt/qt_music_handler.h index 559995a4cb..876b9b22c8 100644 --- a/rpcs3/rpcs3qt/qt_music_handler.h +++ b/rpcs3/rpcs3qt/qt_music_handler.h @@ -16,7 +16,7 @@ public: void stop() override; void pause() override; - void play(const std::string& path) override; + void play(const std::string& path, bool automatic = false) override; void fast_forward(const std::string& path) override; void fast_reverse(const std::string& path) override; void set_volume(f32 volume) override;