Add mic-only muting and playback volume control to MixingAudioDeviceModule#24
Open
paterkleomenis wants to merge 2 commits intodesktop-app:masterfrom
Open
Add mic-only muting and playback volume control to MixingAudioDeviceModule#24paterkleomenis wants to merge 2 commits intodesktop-app:masterfrom
paterkleomenis wants to merge 2 commits intodesktop-app:masterfrom
Conversation
9fc6523 to
a713995
Compare
a713995 to
f2ebab8
Compare
This was referenced Feb 22, 2026
461db3e to
447ba22
Compare
Contributor
|
The PR has conflicts |
Contributor
|
This PR also has the commit from #26, it's a problem |
447ba22 to
1088f5e
Compare
Contributor
This isn't fixed |
1088f5e to
6fea61e
Compare
Contributor
|
You made it worse. What I meant is that the commit either should go to the other PR and this PR get closed or this PR should explicitly mark that it depends on the other one. But you squashed the commits and the problem is still isn't fixed: once the other PR is merged, this one will conflict. |
Contributor
6fea61e to
db2b20d
Compare
Contributor
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.
…odule
When screen audio is being shared in a call, muting the microphone should
not kill the system-audio stream. The two new runtime controls address this:
setMicrophoneMuted(bool)
Zeroes out the mic samples inside MixingAudioTransport::RecordedDataIsAvailable
before they reach WebRTC, while keeping the audio channel open so that
loopback (system audio) continues to flow through unchanged.
setPlaybackVolume(float)
Scales every decoded playback sample by the given factor (0.0-1.0) in
MixingAudioTransport::NeedMorePlayData, providing per-call software volume
control independent of the system mixer.
Both controls are exposed on the shared MixingAudioControl handle with their
respective atomic fields, so changes take effect immediately without any
lock held in the hot path.
State is persisted in MixingAudioControl and re-applied whenever a new
MixingAudioDeviceModule attaches (e.g. after an ADM restart) or whenever
RegisterAudioCallback() installs a fresh MixingAudioTransport.
db2b20d to
62820ea
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
Adds two runtime controls to
MixingAudioDeviceModule/MixingAudioControl:Changes
All changes are in
webrtc/webrtc_create_adm.cppandwebrtc/webrtc_create_adm.h.MixingAudioTransportRecordedDataIsAvailable— when_microphoneMutedis set, the mic buffer is zeroed before the loopback mix step and before forwarding to the inner transport. Loopback audio (if enabled) is mixed into the zeroed buffer, so system audio still reaches the remote peer.NeedMorePlayData— after the inner transport fills the playback buffer, every sample is multiplied by_playbackVolume(float, 0.0–1.0). At unity gain (1.0) the branch is skipped entirely — no performance cost when unused.Both atomics are written relaxed; the hot-path reads are relaxed too (no synchronisation needed — stale values are safe).
MixingAudioDeviceModuleNew
setMicrophoneMuted(bool)andsetPlaybackVolume(float)methods forwarded to the activeMixingAudioTransport. State is also re-applied whenRegisterAudioCallback()installs a fresh transport (e.g. after an ADM restart).MixingAudioControl(public API)State is persisted in
MixingAudioControland re-applied whenever a newMixingAudioDeviceModuleattaches (viaattach()), so callers can set these before the ADM is created.Platform
Linux and Windows. macOS is unaffected.