soundd: fix audio glitch in get_sound_data when frames < sound length#37766
Open
Lidang-Jiang wants to merge 2 commits intocommaai:masterfrom
Open
soundd: fix audio glitch in get_sound_data when frames < sound length#37766Lidang-Jiang wants to merge 2 commits intocommaai:masterfrom
Lidang-Jiang wants to merge 2 commits intocommaai:masterfrom
Conversation
When the audio callback requests fewer frames than the sound's total length, subsequent callbacks did not recompute the local current_sound_frame and loops variables after each chunk write. This caused the tail of the sound to be duplicated instead of wrapping around to the beginning. Add per-iteration recomputation of current_sound_frame and loops inside the while loop, plus regression tests covering boundary conditions (wrap-around, single-play stop, multi-callback continuity). Fixes commaai#36285 Signed-off-by: Lidang-Jiang <[email protected]>
Contributor
Process replay diff reportReplays driving segments through this PR and compares the behavior to master. ✅ 0 changed, 66 passed, 0 errors |
Contributor
UI Previewmici: |
Signed-off-by: Lidang-Jiang <[email protected]>
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.
Summary
Fix boundary condition bug in
Soundd.get_sound_data()wherecurrent_sound_frameandloopswere not recomputed after each chunk write inside the while loop. When the audio callback requested fewer frames than the sound's total length, subsequent callbacks duplicated the tail of the sound instead of wrapping around to the beginning.current_sound_frameandloopsinside the while loop (2 lines)Fixes #36285
Before (bug reproduction)
After (bug fixed)
Test plan
test_soundd_standalone.py: boundary wrap, single-play stop, multi-callback stream, silence, volume scalingselfdrive/ui/tests/test_soundd.pyfor CI integration