From 223793a445bb1c23abf70d1964d19359cd1f81df Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Dec 2022 17:12:17 +0000 Subject: [PATCH] Make spatial audio Firefox-only Hopefully explained in comment: we have a heisenbug where we sometimes lack audio from a certain participant, so this simplifies the audio path by removing the workaround required to do AEC with spatial audio on chrome. --- src/input/Input.module.css | 9 +++ src/room/InCallView.tsx | 55 +++++++-------- src/settings/SettingsModal.tsx | 12 +++- src/settings/useSetting.ts | 21 +++++- src/video-grid/AudioContainer.tsx | 96 ------------------------- src/video-grid/VideoGrid.stories.tsx | 2 +- src/video-grid/VideoGrid.tsx | 2 +- src/video-grid/VideoTileContainer.tsx | 4 +- src/video-grid/useAudioOutputDevice.ts | 2 + src/video-grid/useFullscreen.tsx | 2 +- src/video-grid/useMediaStream.ts | 97 ++++++-------------------- 11 files changed, 94 insertions(+), 208 deletions(-) delete mode 100644 src/video-grid/AudioContainer.tsx diff --git a/src/input/Input.module.css b/src/input/Input.module.css index fce0a938..b9c7c7af 100644 --- a/src/input/Input.module.css +++ b/src/input/Input.module.css @@ -151,6 +151,15 @@ margin-right: 10px; } +.checkboxField.disabled, +.checkboxField.disabled .description { + color: var(--quinary-content); +} + +.checkboxField.disabled .checkbox { + border-color: var(--quinary-content); +} + .checkbox svg { display: none; } diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 431d8b06..eb238994 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -50,19 +50,19 @@ import { Avatar } from "../Avatar"; import { UserMenuContainer } from "../UserMenuContainer"; import { useRageshakeRequestModal } from "../settings/submit-rageshake"; import { RageshakeRequestModal } from "./RageshakeRequestModal"; -import { useMediaHandler } from "../settings/useMediaHandler"; import { useShowInspector, useSpatialAudio } from "../settings/useSetting"; import { useModalTriggerState } from "../Modal"; import { useAudioContext } from "../video-grid/useMediaStream"; import { useFullscreen } from "../video-grid/useFullscreen"; -import { AudioContainer } from "../video-grid/AudioContainer"; -import { useAudioOutputDevice } from "../video-grid/useAudioOutputDevice"; import { PosthogAnalytics } from "../PosthogAnalytics"; import { widget, ElementWidgetActions } from "../widget"; import { useJoinRule } from "./useJoinRule"; import { useUrlParams } from "../UrlParams"; import { usePrefersReducedMotion } from "../usePrefersReducedMotion"; -import { ConnectionState, ParticipantInfo } from "./useGroupCall"; +import { TileDescriptor } from "../video-grid/TileDescriptor"; +import { ParticipantInfo } from "./useGroupCall"; +import { AudioSink } from "../video-grid/AudioSink"; +import { useMediaHandler } from "../settings/useMediaHandler"; const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); // There is currently a bug in Safari our our code with cloning and sending MediaStreams @@ -91,18 +91,6 @@ interface Props { hideHeader: boolean; } -// Represents something that should get a tile on the layout, -// ie. a user's video feed or a screen share feed. -export interface TileDescriptor { - id: string; - member: RoomMember; - focused: boolean; - presenter: boolean; - callFeed?: CallFeed; - isLocal?: boolean; - connectionState: ConnectionState; -} - export function InCallView({ client, groupCall, @@ -145,15 +133,12 @@ export function InCallView({ const [spatialAudio] = useSpatialAudio(); - const [audioContext, audioDestination, audioRef] = useAudioContext(); - const { audioOutput } = useMediaHandler(); + const [audioContext, audioDestination] = useAudioContext(); const [showInspector] = useShowInspector(); const { modalState: feedbackModalState, modalProps: feedbackModalProps } = useModalTriggerState(); - useAudioOutputDevice(audioRef, audioOutput); - const { hideScreensharing } = useUrlParams(); useEffect(() => { @@ -347,16 +332,30 @@ export function InCallView({ [styles.maximised]: maximisedParticipant, }); + // If spatial audio is disabled, we render one audio tag for each participant + // (with spatial audio, all the audio goes via the Web Audio API) + // We also do this if there's a feed maximised because we only trigger spatial + // audio rendering for feeds that we're displaying, which will need to be fixed + // once we start having more participants than we can fit on a screen, but this + // is a workaround for now. + const { audioOutput } = useMediaHandler(); + const audioElements: JSX.Element[] = []; + if (!spatialAudio || maximisedParticipant) { + for (const item of items) { + if (item.isLocal) continue; // We don't want to render own audio + audioElements.push( + + ); + } + } + return (
-