Skip to content

Make the SIP audio mixer input buffer size configurable#727

Open
dshah1333 wants to merge 1 commit into
livekit:mainfrom
dshah1333:configurable-mixer-input-buffer
Open

Make the SIP audio mixer input buffer size configurable#727
dshah1333 wants to merge 1 commit into
livekit:mainfrom
dshah1333:configurable-mixer-input-buffer

Conversation

@dshah1333

Copy link
Copy Markdown

Summary

Adds a mixer_input_buffer_frames config 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.WithInputBufferFrames already exists in media-sdk; the bridge just never passed it.

Driving the real mixer offline with identical bursty input, only the buffer changed:

input buffer mixer restarts input frames dropped injected silence
5 frames (100 ms) 85 172 / 602 ~3.4 s / 12 s
15 frames (300 ms) 0 0 0
steady input, either size 0 0 0

Change

  • New mixer_input_buffer_frames (int; 0 = library default).
  • Passes mixer.WithInputBufferFrames(n) to the room and DTMF mixers only when n > 0.
  • Unit test + a doc comment on the latency trade-off.

Trade-off

A deeper buffer adds up to n × 20 ms of 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.

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.
@CLAassistant

CLAassistant commented Jun 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.36%. Comparing base (0460b40) to head (e37c27a).
⚠️ Report is 312 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dshah1333 dshah1333 marked this pull request as ready for review June 19, 2026 23:09
@dshah1333 dshah1333 requested a review from a team as a code owner June 19, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants