From 475f5a7daed067d53cc171c531668476922ed2f9 Mon Sep 17 00:00:00 2001 From: Hampus Date: Wed, 2 Sep 2026 17:32:43 +0200 Subject: [PATCH] fix(voice): refresh camera capture when the device changes (#2383) --- .../voice/commands/VoiceSettingsCommands.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.ts b/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.ts index 6fda77df3..3aa603ab6 100644 --- a/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.ts +++ b/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.ts @@ -106,7 +106,7 @@ const CAMERA_BACKGROUND_REFRESH_KEYS: Array = [ 'backgroundBlurStrength', 'mirrorCamera', ]; -const CAMERA_CAPTURE_REFRESH_KEYS: Array = ['cameraResolution']; +const CAMERA_CAPTURE_REFRESH_KEYS: Array = ['cameraResolution', 'videoDeviceId']; const SCREEN_SHARE_CODEC_REFRESH_KEYS: Array = [ 'preferredScreenShareCodec', 'screenShareAv1OptIn', @@ -138,8 +138,19 @@ function shouldRefreshCameraBackground(settings: VoiceSettingsPatch): boolean { return CAMERA_BACKGROUND_REFRESH_KEYS.some((key) => settings[key] !== undefined); } -function shouldRefreshCameraCapture(settings: VoiceSettingsPatch): boolean { - return CAMERA_CAPTURE_REFRESH_KEYS.some((key) => settings[key] !== undefined); +function readCameraCaptureRefreshValues(): VoiceSettingsPatch { + return { + cameraResolution: VoiceSettings.cameraResolution, + videoDeviceId: VoiceSettings.videoDeviceId, + }; +} + +function shouldRefreshCameraCapture( + settings: VoiceSettingsPatch, + before: VoiceSettingsPatch, + after: VoiceSettingsPatch, +): boolean { + return CAMERA_CAPTURE_REFRESH_KEYS.some((key) => settings[key] !== undefined && before[key] !== after[key]); } function shouldRefreshScreenShareCodecNegotiation(settings: VoiceSettingsPatch): boolean { @@ -155,6 +166,7 @@ function applyUpdatedVoiceSettings( refreshInput: boolean, options: VoiceSettingsUpdateOptions = {}, ): void { + const cameraCaptureBefore = readCameraCaptureRefreshValues(); VoiceSettings.updateSettings(settings); if (settings.muteStreamAudio !== undefined) { MediaEngine.setScreenShareAudioMuted(settings.muteStreamAudio); @@ -180,7 +192,7 @@ function applyUpdatedVoiceSettings( if (options.refreshCameraBackground !== false && shouldRefreshCameraBackground(settings)) { refreshCameraBackground(); } - if (shouldRefreshCameraCapture(settings)) { + if (shouldRefreshCameraCapture(settings, cameraCaptureBefore, readCameraCaptureRefreshValues())) { refreshCameraCapture(); } if (shouldRefreshScreenShareCodecNegotiation(settings)) {