diff --git a/src/state/CallViewModel/localMember/Publisher.test.ts b/src/state/CallViewModel/localMember/Publisher.test.ts index a2d7baa94..f48612de3 100644 --- a/src/state/CallViewModel/localMember/Publisher.test.ts +++ b/src/state/CallViewModel/localMember/Publisher.test.ts @@ -28,6 +28,7 @@ import { Publisher } from "./Publisher"; import { type Connection } from "../remoteMembers/Connection"; import { type MuteStates } from "../../MuteStates"; import { + autoGainControlSetting, micCutoffEnabled, micCutoffThresholdDb, rnnoiseNoiseSuppression, @@ -395,6 +396,7 @@ describe("Publisher", () => { rnnoiseNoiseSuppressionPreset.setValue("conservative"); micCutoffEnabled.setValue(false); micCutoffThresholdDb.setValue(MIC_CUTOFF_DEFAULT_DB); + autoGainControlSetting.setValue(true); }); it("enabling setting applies RNNoise processor on microphone track", async () => { @@ -506,6 +508,31 @@ describe("Publisher", () => { ); }); + it("preserves the auto gain control setting when restarting the microphone track", async () => { + autoGainControlSetting.setValue(false); + const micTrack = createMockLocalTrack( + Track.Source.Microphone, + ) as LocalTrack & { restartTrack: (...args: unknown[]) => void }; + trackPublications.push({ + source: Track.Source.Microphone, + track: micTrack, + audioTrack: micTrack, + } as unknown as LocalTrackPublication); + localParticipant.emit( + ParticipantEvent.LocalTrackPublished, + trackPublications[0], + ); + + rnnoiseNoiseSuppression.setValue(true); + await flushPromises(); + + expect(micTrack.restartTrack).toHaveBeenCalledWith( + expect.objectContaining({ + autoGainControl: false, + }), + ); + }); + it("restarts a newly-created publisher microphone track with native suppression disabled when RNNoise is already enabled", async () => { await publisher.destroy(); rnnoiseNoiseSuppression.setValue(true); diff --git a/src/state/CallViewModel/localMember/Publisher.ts b/src/state/CallViewModel/localMember/Publisher.ts index 03af3bc17..579c037cd 100644 --- a/src/state/CallViewModel/localMember/Publisher.ts +++ b/src/state/CallViewModel/localMember/Publisher.ts @@ -43,6 +43,7 @@ import { } from "../../../audio/RNNoiseProcessor.ts"; import { shouldEnableNativeNoiseSuppression } from "../../../audio/noiseSuppressionPolicy.ts"; import { + autoGainControlSetting, echoCancellationSetting, micCutoffEnabled, micCutoffThresholdDb, @@ -602,6 +603,7 @@ export class Publisher { await audioTrack.restartTrack({ deviceId: devices.audioInput.selected$.value?.id, + autoGainControl: autoGainControlSetting.getValue(), echoCancellation: echoCancellationSetting.getValue(), noiseSuppression: shouldEnableNativeNoiseSuppression({ urlNoiseSuppression: noiseSuppressionSetting.getValue(),