Tone.js
Tone.js copied to clipboard
actually close audio context when disposing it
When looking into #1037 I found that, contrary to the docs, calling context.dispose() does not really close the audio context. Looks like just an oversight. This fixes the following bug:
Tone.getContext().dispose();
// ...
console.log(Tone.getContext().state); // "running", expected "closed"
Codecov Report
Merging #1041 (a8ac712) into dev (1bedd96) will increase coverage by
0.01%. The diff coverage is100.00%.
@@ Coverage Diff @@
## dev #1041 +/- ##
==========================================
+ Coverage 98.44% 98.46% +0.01%
==========================================
Files 184 184
Lines 7712 7715 +3
Branches 678 678
==========================================
+ Hits 7592 7596 +4
Misses 34 34
+ Partials 86 85 -1
| Impacted Files | Coverage Δ | |
|---|---|---|
| Tone/core/context/Context.ts | 98.03% <100.00%> (+0.71%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 1bedd96...a8ac712. Read the comment docs.
oops just noticed this causes some test fails, will look into soon
this should do the trick and also ensure no existing code is broken by this change in case any users were already directly calling context.close() immediately after context.dispose() before the async close process resolves
Thank you @marcelblum for this PR and for all your help in the repo in general! very much appreciated.