Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/sdk/useLocalAudioInputActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -80,6 +81,7 @@ export const useLocalAudioInputActivity = (cb: (decimal: number) => void) => {

return () => {
isMounted = false;
analyserNode?.removeOriginalInputs();
};
}, [audioVideo, selectedDevice, cb]);
};
Expand Down