Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent previously-decoded (“stale”) audio remaining in the ring buffer from being rendered after the player is stopped/reset, by marking audio as stale and letting the render path discard it.
Changes:
- Set
Flags::audioStaleduringAudioPlayer::stop()so the next render cycle flushes the ring buffer. - Set
Flags::audioStaleduringAudioPlayer::reset()for the same render-time flush behavior.
Suppressed comments (1)
Sources/CSFBAudioEngine/Player/AudioPlayer.mm:842
- Same concern as
stop():reset()setsFlags::audioStale, but the flag is only cleared duringrender(). If the engine remains stopped after reset, this can block decoding (and potentially cause the decoding thread to poll) until playback is restarted and a render callback runs. Consider ensuring the decoding side doesn’t spin while waiting foraudioStaleto clear when the engine isn’t running.
// Discard any leftover audio during the next render cycle
setFlags(Flags::audioStale);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Sources/CSFBAudioEngine/Player/AudioPlayer.mm:1638
durationis computed in seconds (frames / sampleRate), but the timeout multiplies bynanosecondsPerMillisecond, producing a value 1000× too small (e.g., 0.25s becomes 0.25ms). This can cause the decoding thread to wake far more frequently than intended and waste CPU. Multiply bynanosecondsPerSecond(or convertdurationto milliseconds before usingnanosecondsPerMillisecond).
const auto duration = static_cast<double>(targetMaxFreeSpace - freeSpace) / audioBuffer_.format().mSampleRate;
return static_cast<int64_t>(duration * static_cast<double>(nanosecondsPerMillisecond));
sbooth
marked this pull request as draft
August 6, 2026 18:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.