Update now playing when a decoding error occurs when paused#904
Conversation
There was a problem hiding this comment.
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
nowPlayingto the next active decoder; otherwise clearnowPlayingand 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)) { |
There was a problem hiding this comment.
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.
| if (bits::is_clear(loadFlags(), Flags::isPlaying)) { | |
| const auto flags = loadFlags(); | |
| if (bits::is_set(flags, Flags::engineIsRunning) && bits::is_clear(flags, Flags::isPlaying)) { |
No description provided.