✨(frontend) disable noise reduction on mobile devices
Prevent enabling noise reduction on mobile to avoid performance issues from resource-intensive audio processing.
This commit is contained in:
committed by
aleb_the_flash
parent
1fe1a557ad
commit
3de4cc01dc
@@ -3,9 +3,11 @@ import { Track } from 'livekit-client'
|
|||||||
import { useRoomContext } from '@livekit/components-react'
|
import { useRoomContext } from '@livekit/components-react'
|
||||||
import { RnnNoiseProcessor } from '../processors/RnnNoiseProcessor'
|
import { RnnNoiseProcessor } from '../processors/RnnNoiseProcessor'
|
||||||
import { usePersistentUserChoices } from './usePersistentUserChoices'
|
import { usePersistentUserChoices } from './usePersistentUserChoices'
|
||||||
|
import { useIsMobile } from '@/utils/useIsMobile'
|
||||||
|
|
||||||
export const useNoiseReduction = () => {
|
export const useNoiseReduction = () => {
|
||||||
const room = useRoomContext()
|
const room = useRoomContext()
|
||||||
|
const isMobile = useIsMobile()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
userChoices: { noiseReductionEnabled },
|
userChoices: { noiseReductionEnabled },
|
||||||
@@ -16,7 +18,7 @@ export const useNoiseReduction = () => {
|
|||||||
)?.audioTrack
|
)?.audioTrack
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!audioTrack) return
|
if (!audioTrack || isMobile) return
|
||||||
|
|
||||||
const processor = audioTrack?.getProcessor()
|
const processor = audioTrack?.getProcessor()
|
||||||
|
|
||||||
@@ -26,5 +28,5 @@ export const useNoiseReduction = () => {
|
|||||||
} else if (!noiseReductionEnabled && processor) {
|
} else if (!noiseReductionEnabled && processor) {
|
||||||
audioTrack.stopProcessor()
|
audioTrack.stopProcessor()
|
||||||
}
|
}
|
||||||
}, [audioTrack, noiseReductionEnabled])
|
}, [audioTrack, noiseReductionEnabled, isMobile])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { ActiveSpeaker } from '@/features/rooms/components/ActiveSpeaker'
|
|||||||
import { usePersistentUserChoices } from '@/features/rooms/livekit/hooks/usePersistentUserChoices'
|
import { usePersistentUserChoices } from '@/features/rooms/livekit/hooks/usePersistentUserChoices'
|
||||||
import { ReactNode } from 'react'
|
import { ReactNode } from 'react'
|
||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
|
import { useIsMobile } from '@/utils/useIsMobile'
|
||||||
|
|
||||||
type RowWrapperProps = {
|
type RowWrapperProps = {
|
||||||
heading: string
|
heading: string
|
||||||
@@ -141,6 +142,8 @@ export const AudioTab = ({ id }: AudioTabProps) => {
|
|||||||
return defaultItem.value
|
return defaultItem.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isMobile = useIsMobile()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabPanel padding={'md'} flex id={id}>
|
<TabPanel padding={'md'} flex id={id}>
|
||||||
<RowWrapper heading={t('audio.microphone.heading')}>
|
<RowWrapper heading={t('audio.microphone.heading')}>
|
||||||
@@ -190,20 +193,22 @@ export const AudioTab = ({ id }: AudioTabProps) => {
|
|||||||
<SoundTester />
|
<SoundTester />
|
||||||
</RowWrapper>
|
</RowWrapper>
|
||||||
)}
|
)}
|
||||||
<RowWrapper heading={t('audio.noiseReduction.heading')} beta>
|
{!isMobile && (
|
||||||
<Switch
|
<RowWrapper heading={t('audio.noiseReduction.heading')} beta>
|
||||||
aria-label={t(
|
<Switch
|
||||||
`audio.noiseReduction.ariaLabel.${noiseReductionEnabled ? 'disable' : 'enable'}`
|
aria-label={t(
|
||||||
)}
|
`audio.noiseReduction.ariaLabel.${noiseReductionEnabled ? 'disable' : 'enable'}`
|
||||||
isSelected={noiseReductionEnabled}
|
)}
|
||||||
onChange={(v) => {
|
isSelected={noiseReductionEnabled}
|
||||||
saveNoiseReductionEnabled(v)
|
onChange={(v) => {
|
||||||
}}
|
saveNoiseReductionEnabled(v)
|
||||||
>
|
}}
|
||||||
{t('audio.noiseReduction.label')}
|
>
|
||||||
</Switch>
|
{t('audio.noiseReduction.label')}
|
||||||
<div />
|
</Switch>
|
||||||
</RowWrapper>
|
<div />
|
||||||
|
</RowWrapper>
|
||||||
|
)}
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user