Make the SIP audio mixer input buffer size configurable#727
Open
dshah1333 wants to merge 1 commit into
Open
Conversation
The mixer's per-input buffer defaults to media-sdk's 5 frames (100 ms), which can be too small for bursty inputs: chunks larger than the buffer overflow on arrival and underrun between them, restarting the mixer and injecting silence. Add a `mixer_input_buffer_frames` config option that passes `mixer.WithInputBufferFrames(n)` to the room and DTMF mixers when n > 0. Default unchanged (0 = library default), so existing deployments are unaffected.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #727 +/- ##
==========================================
+ Coverage 65.25% 66.36% +1.11%
==========================================
Files 51 41 -10
Lines 6588 7534 +946
==========================================
+ Hits 4299 5000 +701
- Misses 1915 2080 +165
- Partials 374 454 +80 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Adds a
mixer_input_buffer_framesconfig option to size the SIP mixer's per-input buffer. Default unchanged (media-sdk's 5 frames / 100 ms) — opt-in, existing deployments unaffected.Why
The bridge mixes each input through media-sdk's mixer, whose input buffer defaults to 5 frames (100 ms). That can be too small for bursty sources: chunks longer than the buffer overflow on arrival and underrun between them, so the mixer restarts and emits silence — choppy outbound audio.
mixer.WithInputBufferFramesalready exists in media-sdk; the bridge just never passed it.Driving the real mixer offline with identical bursty input, only the buffer changed:
Change
mixer_input_buffer_frames(int;0= library default).mixer.WithInputBufferFrames(n)to the room and DTMF mixers only whenn > 0.Trade-off
A deeper buffer adds up to
n × 20 msof per-input latency (15 frames raises the rebuffer threshold from 60 ms to 160 ms), so the default stays at 5 and operators raise it only when they hit choppy realtime-over-SIP audio. The same 5→15 value is hardcoded in a fork (Bigly-Sales#6); this keeps it configurable instead. Related: livekit/media-sdk#38 tuned mixer timing but left the input buffer at 5.