From 8ddf6a64595a01fc4d699ba14dff2c8f86949d15 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Tue, 21 May 2024 09:23:26 +0200 Subject: [PATCH] Also set audioOutput on audioElements when using webAudioMix (#1145) * Also set audioOutput on audioElements when using webAudioMix * Create four-islands-try.md --- .changeset/four-islands-try.md | 5 +++++ src/room/Room.ts | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changeset/four-islands-try.md diff --git a/.changeset/four-islands-try.md b/.changeset/four-islands-try.md new file mode 100644 index 0000000000..c723ed40ac --- /dev/null +++ b/.changeset/four-islands-try.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Also set audioOutput on audioElements when using webAudioMix diff --git a/src/room/Room.ts b/src/room/Room.ts index f51b38c72f..f697aeba30 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -1086,11 +1086,12 @@ class Room extends (EventEmitter as new () => TypedEmitter) if (this.options.webAudioMix) { // @ts-expect-error setSinkId is not yet in the typescript type of AudioContext this.audioContext?.setSinkId(deviceId); - } else { - await Promise.all( - Array.from(this.remoteParticipants.values()).map((p) => p.setAudioOutput({ deviceId })), - ); } + // also set audio output on all audio elements, even if webAudioMix is enabled in order to workaround echo cancellation not working on chrome with non-default output devices + // see https://issues.chromium.org/issues/40252911#comment7 + await Promise.all( + Array.from(this.remoteParticipants.values()).map((p) => p.setAudioOutput({ deviceId })), + ); } catch (e) { this.options.audioOutput.deviceId = prevDeviceId; throw e;