Skip to content

Commit 8f1e9cc

Browse files
authored
Cleanup legacy audio engine's audio context in dispose() (#16412)
1 parent 6c4b87c commit 8f1e9cc

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

packages/dev/core/src/Audio/audioEngine.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ export class AudioEngine implements IAudioEngine {
335335

336336
this.onAudioUnlockedObservable.clear();
337337
this.onAudioLockedObservable.clear();
338+
339+
this._audioContext?.close();
340+
this._audioContext = null;
338341
}
339342

340343
/**

packages/dev/core/test/unit/Audio/helpers/mockedAudioObjects.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export class MockedAudioObjects {
100100
return {
101101
currentTime: 0,
102102
state: "running",
103+
close: jest.fn().mockName("close").mockImplementation(() => {
104+
this.audioContext.state = "closed";
105+
return Promise.resolve();
106+
}),
103107
createBufferSource: jest.fn().mockName("createBufferSource").mockImplementation(() => {
104108
const bufferSource = new AudioBufferSourceNodeMock;
105109
this._audioBufferSources.push(bufferSource);

0 commit comments

Comments
 (0)