reduce changes and switch input device on sync device

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo K
2025-07-03 16:22:39 +02:00
parent 88710688f8
commit 2752df1c15
2 changed files with 5 additions and 10 deletions

View File

@@ -245,6 +245,7 @@ export function useLivekit(
audioMuteUpdating.current = true; audioMuteUpdating.current = true;
trackPublication = await participant.setMicrophoneEnabled( trackPublication = await participant.setMicrophoneEnabled(
buttonEnabled.current.audio, buttonEnabled.current.audio,
room.options.audioCaptureDefaults,
); );
audioMuteUpdating.current = false; audioMuteUpdating.current = false;
break; break;
@@ -252,6 +253,7 @@ export function useLivekit(
videoMuteUpdating.current = true; videoMuteUpdating.current = true;
trackPublication = await participant.setCameraEnabled( trackPublication = await participant.setCameraEnabled(
buttonEnabled.current.video, buttonEnabled.current.video,
room.options.videoCaptureDefaults,
); );
videoMuteUpdating.current = false; videoMuteUpdating.current = false;
break; break;
@@ -315,13 +317,7 @@ export function useLivekit(
logger.error("Failed to sync video mute state with LiveKit", e); logger.error("Failed to sync video mute state with LiveKit", e);
}); });
} }
}, [ }, [room, muteStates, connectionState]);
room,
muteStates,
connectionState,
devices.audioInput.selected$,
devices.videoInput.selected$,
]);
useEffect(() => { useEffect(() => {
// Sync the requested devices with LiveKit's devices // Sync the requested devices with LiveKit's devices
@@ -331,14 +327,13 @@ export function useLivekit(
selected$: Observable<SelectedDevice | undefined>, selected$: Observable<SelectedDevice | undefined>,
): Subscription => ): Subscription =>
selected$.subscribe((device) => { selected$.subscribe((device) => {
logger.warn( logger.info(
"[LivekitRoom] syncDevice room.getActiveDevice(kind) !== d.id :", "[LivekitRoom] syncDevice room.getActiveDevice(kind) !== d.id :",
room.getActiveDevice(kind), room.getActiveDevice(kind),
" !== ", " !== ",
device?.id, device?.id,
); );
if ( if (
!(kind === "audioinput" && platform === "ios") &&
device !== undefined && device !== undefined &&
room.getActiveDevice(kind) !== device.id room.getActiveDevice(kind) !== device.id
) { ) {

View File

@@ -90,7 +90,7 @@ export function useMuteStates(isJoined: boolean): MuteStates {
useEffect(() => { useEffect(() => {
// If audio is enabled, we need to request the device names again, // If audio is enabled, we need to request the device names again,
// because iOS will not be able to switch to the correct device after un-muting. // because iOS will not be able to switch to the correct device after un-muting.
// This is one of the main changes that makes iOS work bluetooth audio devices. // This is one of the main changes that makes iOS work with bluetooth audio devices.
if (audio.enabled) { if (audio.enabled) {
devices.requestDeviceNames(); devices.requestDeviceNames();
} }