Skip to content

Update now playing when a decoding error occurs when paused#904

Open
sbooth wants to merge 3 commits into
mainfrom
error-when-paused
Open

Update now playing when a decoding error occurs when paused#904
sbooth wants to merge 3 commits into
mainfrom
error-when-paused

Conversation

@sbooth
Copy link
Copy Markdown
Owner

@sbooth sbooth commented Apr 19, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 19, 2026 13:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts AudioPlayer’s decoder-cancellation event handling so the “now playing” decoder is updated appropriately when decoding fails while playback is paused.

Changes:

  • Track the next active decoder after removing a canceled decoder state.
  • When paused, update nowPlaying to the next active decoder; otherwise clear nowPlaying and stop the engine when no decoders remain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return queuedDecoders_.empty() && activeDecoders_.empty();
}();
if (nextDecoder != nil) {
if (bits::is_clear(loadFlags(), Flags::isPlaying)) {
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bits::is_clear(loadFlags(), Flags::isPlaying) is true for both paused and stopped states. With this change, a user-initiated stop() (or any time the engine isn’t running) can trigger setNowPlaying(nextDecoder) during decoder cancellation, causing spurious nowPlayingChanged: delegate callbacks while stopping. To match the PR intent (“when paused”), gate this on the paused state (e.g., isPaused() or Flags::engineIsRunning set while Flags::isPlaying clear) rather than only checking Flags::isPlaying.

Suggested change
if (bits::is_clear(loadFlags(), Flags::isPlaying)) {
const auto flags = loadFlags();
if (bits::is_set(flags, Flags::engineIsRunning) && bits::is_clear(flags, Flags::isPlaying)) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants