diff --git a/CHANGELOG.md b/CHANGELOG.md index 2faefcf0..18274814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Remove analyser node on unmount of useLocalAudioInputActivity hook + ## [3.7.0] - 2023-04-25 ### Added diff --git a/src/hooks/sdk/useLocalAudioInputActivity.tsx b/src/hooks/sdk/useLocalAudioInputActivity.tsx index bbfbfb83..440afb84 100644 --- a/src/hooks/sdk/useLocalAudioInputActivity.tsx +++ b/src/hooks/sdk/useLocalAudioInputActivity.tsx @@ -5,6 +5,7 @@ import { useEffect } from 'react'; import { useAudioVideo } from '../../providers/AudioVideoProvider'; import { useAudioInputs } from '../../providers/DevicesProvider'; +import { RemovableAnalyserNode } from 'amazon-chime-sdk-js'; export const useLocalAudioInputActivity = (cb: (decimal: number) => void) => { const audioVideo = useAudioVideo(); @@ -15,7 +16,7 @@ export const useLocalAudioInputActivity = (cb: (decimal: number) => void) => { return; } - let analyserNode: AnalyserNode | null; + let analyserNode: RemovableAnalyserNode | null; let restart = false; let data: Uint8Array; let frameIndex: number; @@ -80,6 +81,7 @@ export const useLocalAudioInputActivity = (cb: (decimal: number) => void) => { return () => { isMounted = false; + analyserNode?.removeOriginalInputs(); }; }, [audioVideo, selectedDevice, cb]); };