Skip to content

Commit a30c6af

Browse files
committed
Clean up analyser node on unmount of useLocalAudioInputActivity hook
1 parent 1ebd21b commit a30c6af

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Fixed
1919

20+
- Remove analyser node on unmount of useLocalAudioInputActivity hook
21+
2022
## [3.7.0] - 2023-04-25
2123

2224
### Added

src/hooks/sdk/useLocalAudioInputActivity.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect } from 'react';
55

66
import { useAudioVideo } from '../../providers/AudioVideoProvider';
77
import { useAudioInputs } from '../../providers/DevicesProvider';
8+
import { RemovableAnalyserNode } from 'amazon-chime-sdk-js';
89

910
export const useLocalAudioInputActivity = (cb: (decimal: number) => void) => {
1011
const audioVideo = useAudioVideo();
@@ -15,7 +16,7 @@ export const useLocalAudioInputActivity = (cb: (decimal: number) => void) => {
1516
return;
1617
}
1718

18-
let analyserNode: AnalyserNode | null;
19+
let analyserNode: RemovableAnalyserNode | null;
1920
let restart = false;
2021
let data: Uint8Array;
2122
let frameIndex: number;
@@ -80,6 +81,7 @@ export const useLocalAudioInputActivity = (cb: (decimal: number) => void) => {
8081

8182
return () => {
8283
isMounted = false;
84+
analyserNode?.removeOriginalInputs();
8385
};
8486
}, [audioVideo, selectedDevice, cb]);
8587
};

0 commit comments

Comments
 (0)