Repository navigation
fix(audio): bound playback backlog and clear acknowledgement - #29
Merged
malhashemi merged 4 commits intoOct 7, 2026
Merged
Conversation
Reset pending resampler audio and wait for the renderer to acknowledge clearing its ring. Cover overflow, repeated clears and real sample-rate conversion without devices. Co-authored-by: OpenAI <noreply@openai.com>
Acota a un segundo el audio pendiente del resampler y descarta las muestras más antiguas. Si el renderer no confirma una limpieza en un segundo, el engine falla para cerrar la llamada en vez de quedar silenciado. Co-Authored-By: OpenAI <noreply@openai.com>
…ropped early The engine decoded up to 32 packets before moving any audio to the speaker ring, so a batch over one second overflowed the pending cap and dropped its oldest audio even when the ring had room. Flush after every packet instead.
Owner
|
Thank you @francocarballar, great work on this! Both the backlog cap and the clear-acknowledgement timeout look good. I pushed one small follow-up commit (41fba42): playback is now flushed into the speaker ring after each packet, so a big batch of packets can't overflow the one-second cap while the ring still has room, plus a test for it. Merging now, and thanks again for all the care you've put into these PRs. 🙏 |
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.
Purpose
The native audio engine moves decoded voice output to the local speaker.
The resampler converts samples to the output device’s rate.
The renderer drains samples from a ring buffer, a short queue between conversion and playback.
A growing queue can make older speech play late.
Playback flow
The resampler now keeps at most one second of pending output.
On overflow, the resampler drops the oldest samples and keeps the newest audio.
That cap bounds this queue, but it cannot guarantee end-to-end audio latency.
Before refilling, the engine clears its pending samples and signals a ring-buffer reset.
The renderer clears that ring buffer and acknowledges the reset.
If no acknowledgement arrives within one second, the engine exits with an error instead of waiting indefinitely.
The error uses the existing call shutdown path; it does not repair a failed audio device.
Related issue
Issue #28 describes speech remaining in local audio buffers after interruption.
This PR bounds the playback queue and times out if the renderer does not acknowledge a clear.
It does not connect interruption events to the helper’s clear command, so it does not close #28.
Limits and verification
Linux native tests passed with 11 tests.
One manual DSP timing diagnostic was ignored.
Clippy, formatting, and whitespace checks passed.
Real-call testing on macOS has not been performed.
Please test a real call on macOS during review.