From 0c37ea9e2befe26e3a335dd09d72023b6c1b0b87 Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Fri, 1 Jul 2022 09:25:41 -0700 Subject: [PATCH] Close worker on stop in Voice Focus inline worklet (#2320) * 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 Co-authored-by: Trung Le <58827450+ltrung@users.noreply.github.com> --- CHANGELOG.md | 1 + libs/voicefocus/worklet-inline-node.js | 7 +++++++ src/voicefocus/VoiceFocusTransformDevice.ts | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5881efb63..96d341d0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/libs/voicefocus/worklet-inline-node.js b/libs/voicefocus/worklet-inline-node.js index 0966effd25..4df20a1ddb 100644 --- a/libs/voicefocus/worklet-inline-node.js +++ b/libs/voicefocus/worklet-inline-node.js @@ -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(); }); } diff --git a/src/voicefocus/VoiceFocusTransformDevice.ts b/src/voicefocus/VoiceFocusTransformDevice.ts index 7c4fd28ee6..0050c00596 100644 --- a/src/voicefocus/VoiceFocusTransformDevice.ts +++ b/src/voicefocus/VoiceFocusTransformDevice.ts @@ -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 ) {}