Add MixingAudioDeviceModule and loopback mixing transport#26
Closed
paterkleomenis wants to merge 1 commit intodesktop-app:masterfrom
Closed
Add MixingAudioDeviceModule and loopback mixing transport#26paterkleomenis wants to merge 1 commit intodesktop-app:masterfrom
paterkleomenis wants to merge 1 commit intodesktop-app:masterfrom
Conversation
This was referenced Feb 22, 2026
Contributor
|
This PR now conflicts with #22 creating the same files |
ecbbebe to
24b74d0
Compare
Contributor
Author
Unfortunately, it appears that introducing the changes in PR 24 without also including the commit from PR 26 is impossible, so if/when PR 26 is merged, I will rebase 24 for it to work correctly. In the meantime, if you want to test all of them, you can just include PR 24 which also contains the changes in 26 (or, since the changes are so dependent on each other, would you be okay with merging them in one PR?) |
Contributor
|
The PR has conflicts |
24b74d0 to
a6e12de
Compare
…back volume control
Introduces MixingAudioDeviceModule and MixingAudioControl to mix
system-audio loopback into the outgoing microphone stream, plus two
runtime controls for mic-only muting and per-call playback volume.
MixingAudioDeviceModule (ADM wrapper):
Installs MixingAudioTransport in RegisterAudioCallback(),
starts/stops DirectLoopbackCapture (Linux) or a dedicated loopback
ADM + LoopbackAdmTransport (Windows) when setLoopbackEnabled() is
toggled via MixingAudioControl.
MixingAudioTransport:
setMicrophoneMuted(bool) -- zeroes mic samples before forwarding
to WebRTC while keeping the channel open so loopback audio
continues to flow through unchanged.
setPlaybackVolume(float) -- scales decoded playback samples by the
given factor (0.0-1.0), providing per-call software volume
control independent of the system mixer.
MixingAudioControl (public API):
Shared handle that survives ADM recreation. setLoopbackEnabled(),
setMicrophoneMuted() and setPlaybackVolume() let callers control
mixing at any time; state is re-applied whenever a new
MixingAudioDeviceModule attaches.
MixingAudioDeviceModuleCreator(innerCreator, control):
Returns a creator lambda that wraps any ADM inside a
MixingAudioDeviceModule.
Platform: Linux and Windows. macOS is unaffected.
a6e12de to
db2b20d
Compare
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
Introduces infrastructure to mix system-audio loopback into the outgoing microphone stream during a call, on both Linux and Windows.
This PR does not include mic muting or playback volume control — those are in the follow-up PR.
Changes
All changes are in
webrtc/webrtc_create_adm.cppandwebrtc/webrtc_create_adm.h.New internal types (anonymous namespace)
LoopbackCollectorThread-safe mono ring buffer (max 2 s at 48 kHz). Loopback capture threads call
pushSamples();MixingAudioTransportcallsreadAndMix()to saturating-add loopback audio into each mic frame. Stereo input is downmixed to mono on push.DirectLoopbackCapture(Linux only, guarded byWEBRTC_LINUX)Background
std::threadthat opens the PulseAudio monitor source viaalcCaptureOpenDevice(stereo preferred, mono fallback), feeds decoded frames intoLoopbackCollector, and stops cleanly on destruction.findMonitorDevice()prefers the monitor that matches the current default playback sink.MixingAudioTransportwebrtc::AudioTransportdecorator. When mixing is enabled it copies the mic buffer, callsLoopbackCollector::readAndMix, then forwards the blended frame to the inner transport. The disabled path is zero-overhead (no copy, no lock).New internal class (details namespace)
MixingAudioDeviceModulewebrtc::AudioDeviceModulewrapper. InstallsMixingAudioTransportinRegisterAudioCallback(), starts/stopsDirectLoopbackCaptureon Linux (or a dedicated loopback ADM +LoopbackAdmTransporton Windows) whensetLoopbackEnabled()is toggled viaMixingAudioControl.New public API
MixingAudioControlShared handle that survives ADM recreation.
setLoopbackEnabled()/loopbackEnabled()let callers toggle mixing at any time; the control re-applies pending state whenever a newMixingAudioDeviceModuleattaches.MixingAudioDeviceModuleCreator(innerCreator, control)Returns a creator lambda that wraps any ADM (e.g. the OpenAL ADM) inside a
MixingAudioDeviceModule.Platform
Linux and Windows. macOS is unaffected.
Follow-up PR