Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/state/CallViewModel/localMember/Publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Publisher } from "./Publisher";
import { type Connection } from "../remoteMembers/Connection";
import { type MuteStates } from "../../MuteStates";
import {
autoGainControlSetting,
micCutoffEnabled,
micCutoffThresholdDb,
rnnoiseNoiseSuppression,
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/state/CallViewModel/localMember/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
} from "../../../audio/RNNoiseProcessor.ts";
import { shouldEnableNativeNoiseSuppression } from "../../../audio/noiseSuppressionPolicy.ts";
import {
autoGainControlSetting,
echoCancellationSetting,
micCutoffEnabled,
micCutoffThresholdDb,
Expand Down Expand Up @@ -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(),
Expand Down
Loading