Skip to content

fix(mod_conference): prime conference input buffers#3045

Open
Aglcr7 wants to merge 3 commits into
signalwire:masterfrom
Aglcr7:codex/fix-freeswitch-3024-conference-underflow-202605282140
Open

fix(mod_conference): prime conference input buffers#3045
Aglcr7 wants to merge 3 commits into
signalwire:masterfrom
Aglcr7:codex/fix-freeswitch-3024-conference-underflow-202605282140

Conversation

@Aglcr7

@Aglcr7 Aglcr7 commented May 29, 2026

Copy link
Copy Markdown

Closes #3024.

Summary

  • replace the mixer-side last-frame replay/concealment workaround with input-buffer priming
  • keep a small real-audio cushion in each member audio_buffer before the conference mixer starts consuming it
  • when a primed input buffer briefly drains below one complete frame, wait 1 ms and retry a real read before marking it unprimed
  • mark the buffer unprimed again if it still cannot provide a complete real frame, so it re-primes from the input thread instead of replaying synthetic audio
  • clear and unprime the input buffer when member media is configured/reset

Why

The issue is an input-thread underflow: the mixer can become phase-locked to a member input thread and sample the buffer just before the next real frame arrives. The previous approach concealed that by replaying the last frame, but that can corrupt FSK tones because it synthesizes audio. This version avoids replay and only mixes frames that came from the input thread.

Testing

  • git diff --check
  • verified no remaining audio_underflow / replay helper references in mod_conference

Full compile/test was not available in my Windows workspace because gcc, clang, cl, make, and cmake were not present in PATH.

@figaro2015

Copy link
Copy Markdown
Contributor

We had a similar fix implemented already. Unfortunately, this fix won't work for the FSK tones. The real fix should be eliminating the actual input thread underflow condition.

@Aglcr7 Aglcr7 changed the title fix(mod_conference): conceal transient mixer underflows fix(mod_conference): prime conference input buffers May 29, 2026
@Aglcr7

Aglcr7 commented May 29, 2026

Copy link
Copy Markdown
Author

Thanks @figaro2015, I reworked the patch around that point.

The updated commits (4eed0b2, refined by 1e1fb29) remove the last-frame replay/concealment path and instead prime each member input audio_buffer with a small real-audio cushion before the mixer consumes it. If a primed buffer briefly drains below a complete frame, the mixer gives the input thread a 1 ms grace period and retries a real read; if no complete real frame arrives, the buffer is marked unprimed and has to re-prime from the input thread again. That keeps the fix on real input frames and avoids synthesizing/repeating samples, which should be compatible with FSK tones.

Local checks: git diff --check, plus verified the old audio_underflow / replay helper references are gone. I still cannot compile in this Windows workspace because the C toolchain is unavailable here.

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.

Core of the conference mixer wrongly inserts silence packets which cause audio distortion

2 participants