fix(voice): stop the recorder writing over audio still in the resampler - #7079
Open
longcw wants to merge 2 commits into
Open
fix(voice): stop the recorder writing over audio still in the resampler#7079longcw wants to merge 2 commits into
longcw wants to merge 2 commits into
Conversation
The writer flushes each block up to _input_settled, which comes from frame arrival, but the default 24kHz input passes through a resampler into a 48kHz recording and a resampler emits only whole output frames. The writer puts silence where the last 24ms belongs, and take() then discards those samples because their place is behind the cursor. _Track now reports placed_through, and the encode thread keeps each write behind it. The clamp stays no more than MAX_RESAMPLER_LAG behind so that a stalled source cannot pin the cursor the two channels share.
The clamp let the cursor move on once a source went quiet for longer than MAX_RESAMPLER_LAG, which left the samples still inside its resampler behind the cursor. end_run() flushed them at their own place, and take() then discarded them. The writer now ends the run of a source that stopped delivering, so its tail is placed while the cursor can still reach it.
chenghao-mou
approved these changes
Sep 3, 2026
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.
Problem: The recorder writes each block up to
_input_settled, which is the arrival time of the frame. A resampler emits only whole output frames, so the tail of the audio is still inside it, and the writer puts silence in that place.take()discards those samples later, because their place is behind the cursor.Fix:
_Trackreportsplaced_through, the point the open run reaches, orNonewhen the resampler holds nothing back. The encode thread keeps each write behind that point.Context for reviewing and coding agents