Skip to content

Commit 21ee7f0

Browse files
committed
input mixer mute mode
1 parent e114436 commit 21ee7f0

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

modules/audio_device/audio_engine_device.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ extern NSString* const kAudioEngineInputMixerNodeKey;
104104
class AudioEngineDevice : public AudioDeviceModule, public AudioSessionObserver {
105105
public:
106106
enum RenderMode { Device = 0, Manual = 1 };
107-
enum MuteMode { VoiceProcessing = 0, RestartEngine = 1 };
107+
enum MuteMode {
108+
// Mute input using voice processing
109+
VoiceProcessing = 0,
110+
// Mute by restarting engine
111+
RestartEngine = 1,
112+
// Mute input by muting the input mixer node
113+
InputMixer = 2,
114+
};
108115

109116
// Represents the state of the audio engine, including input/output status,
110117
// rendering mode, and various configuration flags.

modules/audio_device/audio_engine_device.mm

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@
17571757
// Always unmute vp if restart mute mode.
17581758
if (state.next.mute_mode == MuteMode::RestartEngine &&
17591759
inputNode().voiceProcessingInputMuted) {
1760-
LOGI() << "setVoiceProcessingInputMuted: un-muting vp for restart mute mode";
1760+
LOGI() << "Update mute (voice processing) unmuting vp for restart engine mode";
17611761
inputNode().voiceProcessingInputMuted = false;
17621762
}
17631763

@@ -2028,7 +2028,7 @@
20282028

20292029
// If disabling input, always unmute the voice-processing input mute.
20302030
if (inputNode().voiceProcessingEnabled && inputNode().voiceProcessingInputMuted) {
2031-
LOGI() << "setVoiceProcessingInputMuted (stop-recording): " << 0;
2031+
LOGI() << "Update mute (voice processing) unmuting vp for stop-recording";
20322032
inputNode().voiceProcessingInputMuted = false;
20332033
}
20342034

@@ -2084,10 +2084,21 @@
20842084
if (state.next.mute_mode == MuteMode::VoiceProcessing && state.next.IsInputEnabled() &&
20852085
inputNode().voiceProcessingEnabled &&
20862086
inputNode().voiceProcessingInputMuted != state.next.input_muted) {
2087-
LOGI() << "setVoiceProcessingInputMuted (runtime): " << state.next.input_muted;
2087+
LOGI() << "Update mute (voice processing) runtime update" << state.next.input_muted;
20882088
inputNode().voiceProcessingInputMuted = state.next.input_muted;
20892089
}
20902090

2091+
// Run-time mute toggling if mixer mute mode.
2092+
if (state.next.mute_mode == MuteMode::InputMixer && state.next.IsInputEnabled() &&
2093+
input_mixer_node_ != nil) {
2094+
// Only update if the volume has changed.
2095+
float mixer_volume = state.next.input_muted ? 0.0f : 1.0f;
2096+
if (input_mixer_node_.outputVolume != mixer_volume) {
2097+
LOGI() << "Update mute (input mixer) runtime update" << state.next.input_muted;
2098+
input_mixer_node_.outputVolume = mixer_volume;
2099+
}
2100+
}
2101+
20912102
#if !TARGET_OS_TV
20922103
if (state.next.IsInputEnabled() && inputNode().voiceProcessingEnabled &&
20932104
(!state.prev.IsInputEnabled() ||

sdk/objc/api/peerconnection/RTCAudioDeviceModule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef NS_ENUM(NSInteger, RTCAudioEngineMuteMode) {
3737
RTCAudioEngineMuteModeUnknown = -1,
3838
RTCAudioEngineMuteModeVoiceProcessing = 0,
3939
RTCAudioEngineMuteModeRestartEngine = 1,
40+
RTCAudioEngineMuteModeInputMixer = 2,
4041
};
4142

4243
typedef struct {

0 commit comments

Comments
 (0)