Skip to content

Commit

Permalink
Also set audioOutput on audioElements when using webAudioMix (#1145)
Browse files Browse the repository at this point in the history
* Also set audioOutput on audioElements when using webAudioMix

* Create four-islands-try.md
  • Loading branch information
lukasIO authored May 21, 2024
1 parent 1e8465a commit 8ddf6a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-islands-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Also set audioOutput on audioElements when using webAudioMix
9 changes: 5 additions & 4 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
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;
Expand Down

0 comments on commit 8ddf6a6

Please sign in to comment.