use "" instead of undefined for audio output default and on syncDevice + logging

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo K
2025-07-03 13:13:05 +02:00
parent 51cd406ac0
commit ea4002e0b7

View File

@@ -117,7 +117,7 @@ export function useLivekit(
// deviceId here, because it will be set by the native app. // deviceId here, because it will be set by the native app.
// (also the id does not need to match a browser device id) // (also the id does not need to match a browser device id)
deviceId: controlledAudioDevices deviceId: controlledAudioDevices
? undefined ? ""
: getValue(devices.audioOutput.selected$)?.id, : getValue(devices.audioOutput.selected$)?.id,
}, },
e2ee, e2ee,
@@ -333,13 +333,23 @@ export function useLivekit(
selected$: Observable<SelectedDevice | undefined>, selected$: Observable<SelectedDevice | undefined>,
): Subscription => ): Subscription =>
selected$.subscribe((device) => { selected$.subscribe((device) => {
let d = device;
if (controlledAudioDevices && kind === "audiooutput") {
d = { id: "" };
}
logger.info(
"[LivekitRoom] syncDevice room.getActiveDevice(kind) !== d.id :",
room.getActiveDevice(kind),
" !== ",
d?.id,
);
if ( if (
!(kind === "audioinput" && platform === "ios") && !(kind === "audioinput" && platform === "ios") &&
device !== undefined && d !== undefined &&
room.getActiveDevice(kind) !== device.id room.getActiveDevice(kind) !== d.id
) { ) {
room room
.switchActiveDevice(kind, device.id) .switchActiveDevice(kind, d.id)
.catch((e) => .catch((e) =>
logger.error(`Failed to sync ${kind} device with LiveKit`, e), logger.error(`Failed to sync ${kind} device with LiveKit`, e),
); );