From b144e650f2aa2a055b2323ee21fe8f09a3d4c8c6 Mon Sep 17 00:00:00 2001 From: Hampus Date: Thu, 20 Aug 2026 17:43:19 +0200 Subject: [PATCH] fix(voice): make deafen reach watched screen share audio (#1786) --- .../VoiceEngineV2AppMediaExecutionAdapter.tsx | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMediaExecutionAdapter.tsx b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMediaExecutionAdapter.tsx index afed61a3b..6edbd99e9 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMediaExecutionAdapter.tsx +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMediaExecutionAdapter.tsx @@ -51,7 +51,11 @@ import { getLocalMicrophonePublications, getPrimaryLocalMicrophonePublication, } from '@app/features/voice/engine/VoiceTrackPublicationUtils'; -import {asVoiceTrackSource, VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; +import { + asVoiceTrackSource, + isScreenShareAudioPublicationLike, + VoiceTrackSource, +} from '@app/features/voice/engine/VoiceTrackSource'; import { assertBoolean, assertNonEmptyString, @@ -1286,6 +1290,15 @@ export class VoiceEngineV2AppMediaExecutionAdapter extends Store { assertNonEmptyString(userId, 'applyLocalAudioPreferencesForUser.userId'); assertNullableObjectLike(room, 'applyLocalAudioPreferencesForUser.room'); if (!room) { + const connection = getVoiceConnectionContextFromMediaEngine(); + logger.warn(`Skipped audio preferences for user ${userId} because no room was attached`, { + userId, + guildId: connection?.guildId ?? null, + channelId: connection?.channelId ?? null, + connectionId: connection?.connectionId ?? null, + connecting: connection?.connecting ?? false, + reconnecting: connection?.reconnecting ?? false, + }); return; } room.remoteParticipants.forEach((participant) => { @@ -1496,8 +1509,16 @@ export class VoiceEngineV2AppMediaExecutionAdapter extends Store { }); room.remoteParticipants.forEach((participant) => { participant.audioTrackPublications.forEach((publication) => { - if (asVoiceTrackSource(publication.source) !== VoiceTrackSource.Microphone) return; + const isScreenShareAudio = isScreenShareAudioPublicationLike(publication); + const isMicrophone = asVoiceTrackSource(publication.source) === VoiceTrackSource.Microphone; + if (!isScreenShareAudio && !isMicrophone) return; try { + if (isScreenShareAudio) { + if (deafened && publication.isDesired) { + publication.setEnabled(false); + } + return; + } if (deafened) { if (publication.isDesired) { publication.setEnabled(false); @@ -1508,10 +1529,11 @@ export class VoiceEngineV2AppMediaExecutionAdapter extends Store { publication.setSubscribed(true); publication.setEnabled(true); } catch (error) { - logger.error('Failed to apply deaf state to remote microphone publication', { + logger.error('Failed to apply deaf state to remote audio publication', { error, deafened, identity: participant.identity, + isScreenShareAudio, trackSid: publication.trackSid, }); }