controlled with syncing but no output syncing

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo K
2025-07-03 14:18:44 +02:00
parent bbb10baf49
commit 0a838a9584
2 changed files with 16 additions and 15 deletions

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
? "default" ? undefined
: getValue(devices.audioOutput.selected$)?.id, : getValue(devices.audioOutput.selected$)?.id,
}, },
e2ee, e2ee,
@@ -329,23 +329,23 @@ export function useLivekit(
selected$: Observable<SelectedDevice | undefined>, selected$: Observable<SelectedDevice | undefined>,
): Subscription => ): Subscription =>
selected$.subscribe((device) => { selected$.subscribe((device) => {
let d = device; // let d = device;
if (controlledAudioDevices && kind === "audiooutput") { // if (controlledAudioDevices && kind === "audiooutput") {
d = { id: "default" }; // d = { id: "default" };
} // }
logger.warn( logger.warn(
"[LivekitRoom] syncDevice room.getActiveDevice(kind) !== d.id :", "[LivekitRoom] syncDevice room.getActiveDevice(kind) !== d.id :",
room.getActiveDevice(kind), room.getActiveDevice(kind),
" !== ", " !== ",
d?.id, device?.id,
); );
if ( if (
!(kind === "audioinput" && platform === "ios") && !(kind === "audioinput" && platform === "ios") &&
d !== undefined && device !== undefined &&
room.getActiveDevice(kind) !== d.id room.getActiveDevice(kind) !== device.id
) { ) {
room room
.switchActiveDevice(kind, d.id) .switchActiveDevice(kind, device.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),
); );
@@ -354,7 +354,9 @@ export function useLivekit(
const subscriptions = [ const subscriptions = [
syncDevice("audioinput", devices.audioInput.selected$), syncDevice("audioinput", devices.audioInput.selected$),
syncDevice("audiooutput", devices.audioOutput.selected$), !controlledAudioDevices
? syncDevice("audiooutput", devices.audioOutput.selected$)
: undefined,
syncDevice("videoinput", devices.videoInput.selected$), syncDevice("videoinput", devices.videoInput.selected$),
// Restart the audio input track whenever we detect that the active media // Restart the audio input track whenever we detect that the active media
// device has changed to refer to a different hardware device. We do this // device has changed to refer to a different hardware device. We do this
@@ -397,7 +399,7 @@ export function useLivekit(
]; ];
return (): void => { return (): void => {
for (const s of subscriptions) s.unsubscribe(); for (const s of subscriptions) s?.unsubscribe();
}; };
} }
}, [room, devices, connectionState, controlledAudioDevices]); }, [room, devices, connectionState, controlledAudioDevices]);

View File

@@ -392,10 +392,9 @@ export class MediaDevices {
public readonly audioOutput: MediaDevice< public readonly audioOutput: MediaDevice<
AudioOutputDeviceLabel, AudioOutputDeviceLabel,
SelectedAudioOutputDevice SelectedAudioOutputDevice
> = > = getUrlParams().controlledAudioDevices
// getUrlParams().controlledAudioDevices ? new ControlledAudioOutput(this.scope)
// ? new ControlledAudioOutput(this.scope): : new AudioOutput(this.usingNames$, this.scope);
new AudioOutput(this.usingNames$, this.scope);
public readonly videoInput: MediaDevice<DeviceLabel, SelectedDevice> = public readonly videoInput: MediaDevice<DeviceLabel, SelectedDevice> =
new VideoInput(this.usingNames$, this.scope); new VideoInput(this.usingNames$, this.scope);