A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(app): share stream audio by default and reset the opt-out per stream (#1819)
Hampus137edc7cfbf2
diff --git a/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts b/fluxer_app/src/features/voice/engine/MediaEngineFacade.tsindex 3ecd4226c..a499204ad 100644--- a/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts+++ b/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts@@ -2326,6 +2326,7 @@ class MediaEngineFacade extends Store {sendUpdate?: boolean;playSound?: boolean;restartIfEnabled?: boolean;+ preserveStreamAudioPreferences?: boolean;},publishOptions?: TrackPublishOptions,): Promise<void> {diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsx b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsxindex ddefb42bf..d4db550f7 100644--- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsx+++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppScreenShareExecutionAdapter.tsx@@ -7,6 +7,7 @@ import {SoundType} from '@app/features/notification/utils/SoundUtils';import * as ModalCommands from '@app/features/ui/commands/ModalCommands';import * as SoundCommands from '@app/features/ui/commands/SoundCommands';import {getElectronAPI} from '@app/features/ui/utils/NativeUtils';+import * as VoiceSettingsCommands from '@app/features/voice/commands/VoiceSettingsCommands';import {getStreamKey} from '@app/features/voice/components/StreamKeys';import AdaptiveScreenShareEngine from '@app/features/voice/engine/AdaptiveScreenShareEngine';import type {NegotiationReason} from '@app/features/voice/engine/ScreenShareCodecNegotiation';@@ -691,11 +692,20 @@ class VoiceEngineV2AppScreenShareExecutionAdapter extends Store {playSound?: boolean;restartIfEnabled?: boolean;reason?: string;+ preserveStreamAudioPreferences?: boolean;},publishOptions?: TrackPublishOptions,): Promise<void> {assert.equal(typeof enabled, 'boolean');await this.controllerRouting.setEnabled(room, enabled, options, publishOptions);+ if (!enabled && options?.preserveStreamAudioPreferences !== true) {+ VoiceSettingsCommands.update({+ shareAppAudio: true,+ shareDesktopAudio: true,+ shareDeviceAudio: true,+ muteStreamAudio: false,+ });+ }}async executeScreenShareSetEnabledDirect(diff --git a/fluxer_app/src/features/voice/state/VoiceSettings.ts b/fluxer_app/src/features/voice/state/VoiceSettings.tsindex 59fe3649c..52ecdf5b8 100644--- a/fluxer_app/src/features/voice/state/VoiceSettings.ts+++ b/fluxer_app/src/features/voice/state/VoiceSettings.ts@@ -216,6 +216,18 @@ function applyScreenShareAudioConsentMigrationV1(parsed: Record<string, unknown>return true;}+function applyScreenShareAudioDefaultOnMigrationV1(parsed: Record<string, unknown>): boolean {+ if (parsed.screenShareAudioDefaultOnMigratedV1 === true) {+ return false;+ }+ parsed.shareAppAudio = true;+ parsed.shareDesktopAudio = true;+ parsed.shareDeviceAudio = true;+ parsed.muteStreamAudio = false;+ parsed.screenShareAudioDefaultOnMigratedV1 = true;+ return true;+}+function applyStreamingModeDefaultMigrationV1(parsed: Record<string, unknown>): boolean {if (parsed.streamingModeDefaultMigratedV1 === true) {return false;@@ -284,12 +296,13 @@ class VoiceSettings {streamingMode: StreamingMode = 'screenshare';streamingModeDefaultMigratedV1 = false;hideStreamPreview = false;- muteStreamAudio = true;- shareAppAudio = false;- shareDesktopAudio = false;- shareDeviceAudio = false;+ muteStreamAudio = false;+ shareAppAudio = true;+ shareDesktopAudio = true;+ shareDeviceAudio = true;screenShareAudioDeviceId = 'default';screenShareAudioConsentMigratedV1 = false;+ screenShareAudioDefaultOnMigratedV1 = false;outputVolumeRecalibratedV1 = false;backgroundImageId = NONE_BACKGROUND_ID;backgroundImages: Array<BackgroundImage> = [];@@ -424,6 +437,7 @@ class VoiceSettings {changed = applyPiPPopoutDefaultsMigration(parsed) || changed;changed = applyAdaptiveScreenShareQualityMigrationV2(parsed) || changed;changed = applyScreenShareAudioConsentMigrationV1(parsed) || changed;+ changed = applyScreenShareAudioDefaultOnMigrationV1(parsed) || changed;changed = applyStreamingModeDefaultMigrationV1(parsed) || changed;changed = applyOutputVolumeRecalibrationMigrationV1(parsed) || changed;if (changed) {@@ -463,6 +477,7 @@ class VoiceSettings {'shareDeviceAudio','screenShareAudioDeviceId','screenShareAudioConsentMigratedV1',+ 'screenShareAudioDefaultOnMigratedV1','outputVolumeRecalibratedV1','backgroundImageId','backgroundImages',diff --git a/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.ts b/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.tsindex 899310704..0fe3b8ea5 100644--- a/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.ts+++ b/fluxer_app/src/features/voice/utils/ScreenShareStartFlow.ts@@ -357,7 +357,11 @@ async function runConfiguredDisplayScreenShare(logger.warn('No active screen share to restart for Wayland portal source switch');return false;}- await MediaEngine.setScreenShareEnabled(false, {sendUpdate: false, playSound: false});+ await MediaEngine.setScreenShareEnabled(false, {+ sendUpdate: false,+ playSound: false,+ preserveStreamAudioPreferences: true,+ });}let nativeAudioArmed = false;const isOwnWindowShare = options?.isOwnWindow === true && sourceId?.startsWith('window:');