Skip to content

Commit

Permalink
Emit ActiveDeviceChanged event also for audio-output (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Jan 20, 2025
1 parent cd425c8 commit 58245a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-kings-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Emit ActiveDeviceChanged event also for audio-output
8 changes: 6 additions & 2 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
throw e;
}
}
if (needsUpdateWithoutTracks) {
this.localParticipant.activeDeviceMap.set(kind, deviceId);
if (needsUpdateWithoutTracks || kind === 'audiooutput') {
// if there are not active tracks yet or we're switching audiooutput, we need to manually update the active device map here as changing audio output won't result in a track restart
this.localParticipant.activeDeviceMap.set(
kind,
(kind === 'audiooutput' && this.options.audioOutput?.deviceId) || deviceId,
);
this.emit(RoomEvent.ActiveDeviceChanged, kind, deviceId);
}

Expand Down

0 comments on commit 58245a1

Please sign in to comment.