Skip to content

Commit

Permalink
Fix closing of AudioContext that is already closed
Browse files Browse the repository at this point in the history
When you were retrying after being done, the 'retry' handler was
trying to close the AudioContext that had already been closed by
the 'done' handler thus throwing an exception. Fixed by checking
the AudioContext's state for being closed already before trying
to close it.
  • Loading branch information
otacke committed May 27, 2021
1 parent 532a8a6 commit 602eb62
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/Recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ export default class Recorder extends H5P.EventDispatcher {
this.stream.getAudioTracks().forEach(track => track.stop());
this.sourceNode.disconnect();
this.scriptProcessorNode.disconnect();
this.audioContext.close();
if (this.audioContext.state !== 'closed') {
this.audioContext.close();
}

delete this.userMedia;
}
Expand Down

0 comments on commit 602eb62

Please sign in to comment.