Skip to content

Commit

Permalink
Close worker on stop in Voice Focus inline worklet (aws#2320)
Browse files Browse the repository at this point in the history
* Close worker on stop in Voice Focus inline worklet

* Update CHANGELOG

* Rebase and move CHANGELOG details to 3.6.0

Co-authored-by: Richard Huang <[email protected]>
Co-authored-by: Trung Le <[email protected]>
  • Loading branch information
3 people authored Jul 1, 2022
1 parent 29680c0 commit 0c37ea9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

### Fixed
- Fix issue closing a web worker in Amazon Voice Focus's inline worklet.

## [3.5.0] - 2022-06-02

Expand Down
7 changes: 7 additions & 0 deletions libs/voicefocus/worklet-inline-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ class VoiceFocusInlineNode extends types_js_1.VoiceFocusAudioWorkletNode {
});
}
stop() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
this.port.postMessage({ message: 'stop' });
try {
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.terminate();
}
catch (e) {
console.error("failed to terminate worker:", e);
}
this.disconnect();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/voicefocus/VoiceFocusTransformDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VoiceFocusTransformDevice implements AudioTransformDevice, AudioMixObserve
/** mixDestNode is the Audio Destination Node where farEndStreams got mixed into one stream.*/
private mixDestNode: MediaStreamAudioDestinationNode | undefined = undefined,

/** mixSourceNode is the Audio Source Node where the stream out of mixDestNode got transfered into Audio Worklet Node for processing.*/
/** mixSourceNode is the Audio Source Node where the stream out of mixDestNode got transferred into Audio Worklet Node for processing.*/
private mixSourceNode: MediaStreamAudioSourceNode | undefined = undefined
) {}

Expand Down

0 comments on commit 0c37ea9

Please sign in to comment.