Conversation
While a channel has no negotiated codec (CT_NONE), DecodeReceiveData() skipped both decode branches and left vecvecsData[iChanCnt] unwritten. That buffer is indexed by position in the connected-channel list, so with -R a new client in a reused channel was recorded with the audio last decoded at that position. Separately, the per-channel Opus decoders kept the previous client's state, so the new client's recording opened with the end of the previous client's audio. Zero the buffer in the CT_NONE branch, and reset the channel's four decoders when the channel is freed. Both run on the decode path. Fixes jamulussoftware#3901 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughDecodeReceiveData now clears a channel’s audio buffer when no codec is selected. When decoding detects a client disconnect, the server resets the channel’s legacy OPUS and OPUS64 decoder states before freeing the channel. ChangesChannel audio cleanup
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change clears audio when no codec is selected and resets decoder state before channel reuse. No actionable merge-blocking risk introduced by this change remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 AI: Short description of changes
A new client that takes a reused channel inherits two pieces of the previous client's audio, and with
-Rboth land in the new client's recording. Measured onmainat7ebf8f87: test client A sends a 440 Hz tone and disconnects, and client B joins 100 to 500 ms later sending only silence.CT_NONEbranch writes nothing tovecvecsData[iChanCnt], which is indexed by position in the connected-channel list. B's pre-identification recording held A's tone in 12 of 13 runs. It was usually one 128-sample frame, but 256, 768 and 896 samples also occurred, each frame a repeat of the same stale buffer.This PR zeroes the buffer in the
CT_NONEbranch, and resets the channel's four decoders in theGS_CHAN_NOW_DISCONNECTEDbranch, just beforeFreeChannel(). Both run on the decode path, and neither runs while a client is connected with a negotiated codec. Resetting the decoders in theCT_NONEbranch instead missed one case: a new client that never passes throughCT_NONE(no pre-identification recording). To force that case, test client B sent its transport properties unrequested right after its first packet.mainCT_NONEinstead, B forced pastCT_NONECT_NONEThe RMS 326 is the reset decoder's own start-up output: it is the same when A sends silence. Two statements in #3901 were incomplete: the stale audio is not always one frame, and zeroing the buffer alone does not stop the leak.
CHANGELOG: Server: Fixed the start of a new client's recording containing audio from the previous client in the same channel.
Context: Fixes an issue?
Fixes: #3901
Does this change need documentation? What needs to be documented and how?
No.
Status of this Pull Request
Working implementation.
What is missing until this pull request can be merged?
Review. ThreadSanitizer churn runs, with test clients joining and leaving repeatedly (480 connections in the default mode, 240 with
-T), reported no race involving the new lines.clang-formatclean; no new compiler warnings.Checklist
🤖 This message was written by AI and reviewed by @mcfnord.