Add MixingAudioDeviceModule and loopback mixing transport#28
Open
paterkleomenis wants to merge 1 commit intodesktop-app:masterfrom
Open
Add MixingAudioDeviceModule and loopback mixing transport#28paterkleomenis wants to merge 1 commit intodesktop-app:masterfrom
paterkleomenis wants to merge 1 commit intodesktop-app:masterfrom
Conversation
Introduces infrastructure to mix system-audio loopback into the outgoing
microphone stream during a call, on both Linux and Windows.
New types (in webrtc_create_adm.cpp, anonymous namespace):
LoopbackCollector
Thread-safe mono ring buffer (max 2 s at 48 kHz). Loopback capture
threads call pushSamples(); MixingAudioTransport calls readAndMix()
to saturating-add loopback audio into the mic frame.
DirectLoopbackCapture (Linux only, guarded by WEBRTC_LINUX)
Background std::thread that opens the PulseAudio monitor source via
alcCaptureOpenDevice (stereo preferred, mono fallback), feeds decoded
frames into LoopbackCollector, and stops cleanly on destruction.
findMonitorDevice() prefers the monitor that matches the current
default playback sink.
MixingAudioTransport
webrtc::AudioTransport decorator. When mixing is enabled it copies the
mic buffer, calls LoopbackCollector::readAndMix, then forwards the
blended frame to the inner transport. Disabled path is zero-overhead.
MixingAudioDeviceModule (details namespace)
webrtc::AudioDeviceModule wrapper. Installs MixingAudioTransport in
RegisterAudioCallback(), starts/stops DirectLoopbackCapture (Linux) or
a dedicated loopback ADM + LoopbackAdmTransport (Windows) when
setLoopbackEnabled() is toggled via MixingAudioControl.
New public API (webrtc_create_adm.h):
MixingAudioControl
Shared handle that survives ADM recreation. setLoopbackEnabled() /
loopbackEnabled() let callers toggle mixing at any time; the control
re-applies pending state whenever a new MixingAudioDeviceModule
attaches itself.
MixingAudioDeviceModuleCreator(innerCreator, control)
Returns a creator lambda that wraps any ADM (e.g. the OpenAL ADM)
inside a MixingAudioDeviceModule.
This was referenced Mar 5, 2026
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.
Introduces infrastructure to mix system-audio loopback into the outgoing microphone stream during a call, on both Linux and Windows.
New types (in webrtc_create_adm.cpp, anonymous namespace):
LoopbackCollector
Thread-safe mono ring buffer (max 2 s at 48 kHz). Loopback capture
threads call pushSamples(); MixingAudioTransport calls readAndMix()
to saturating-add loopback audio into the mic frame.
DirectLoopbackCapture (Linux only, guarded by WEBRTC_LINUX)
Background std::thread that opens the PulseAudio monitor source via
alcCaptureOpenDevice (stereo preferred, mono fallback), feeds decoded
frames into LoopbackCollector, and stops cleanly on destruction.
findMonitorDevice() prefers the monitor that matches the current
default playback sink.
MixingAudioTransport
webrtc::AudioTransport decorator. When mixing is enabled it copies the
mic buffer, calls LoopbackCollector::readAndMix, then forwards the
blended frame to the inner transport. Disabled path is zero-overhead.
MixingAudioDeviceModule (details namespace)
webrtc::AudioDeviceModule wrapper. Installs MixingAudioTransport in
RegisterAudioCallback(), starts/stops DirectLoopbackCapture (Linux) or
a dedicated loopback ADM + LoopbackAdmTransport (Windows) when
setLoopbackEnabled() is toggled via MixingAudioControl.
New public API (webrtc_create_adm.h):
MixingAudioControl
Shared handle that survives ADM recreation. setLoopbackEnabled() /
loopbackEnabled() let callers toggle mixing at any time; the control
re-applies pending state whenever a new MixingAudioDeviceModule
attaches itself.
MixingAudioDeviceModuleCreator(innerCreator, control)
Returns a creator lambda that wraps any ADM (e.g. the OpenAL ADM)
inside a MixingAudioDeviceModule.