Repository navigation
Keep buffered audio working after a soft reboot - #148
Merged
Merged
Conversation
After Ctrl-D, audio.play of a sound expression or AudioFrames, and speech, played one buffer and then hung without returning to the REPL. A soft reboot stops the board's components via microbit_hal_deinit, and stopping audio replaced each BufferedAudio's callback with a no-op. The callbacks are only connected when the module is created, which a soft reboot doesn't repeat, so nothing asked for the next buffer. For sound expressions the expression then stayed active for ever. The no-op was added in a3e92f7 so that buffers still scheduled on the now long-lived AudioContext couldn't call into a stopped module. Since 8b4381b stop() cancels the scheduled buffers and their onended handlers, which covers that without disconnecting the callback. Add tests for each kind of buffered audio after a soft reboot, and for stopping the program while each is playing, which only music had. Closes #112
|
Preview build will be at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After Ctrl-D,
audio.playof a sound expression orAudioFrames, andspeech, played one buffer and then hung without returning to the REPL. Music was unaffected as it uses the oscillator.Cause
A soft reboot stops the board's components via
microbit_hal_deinit, and stopping audio replaced eachBufferedAudio's callback with a no-op. The callbacks are only connected increateModule(), which a soft reboot doesn't repeat, so nothing asked for the next buffer. For sound expressions,isSoundExpressionActive()then stayed true for ever.The no-op came from #99, which made the
AudioContextlive for the whole page, so that buffers still scheduled couldn't call into a stopped module. Since 8b4381bstop()cancels the scheduled buffers and clears theironendedhandlers, which covers that case without disconnecting the callback.Change
boardStopped()now stops the buffered audio and leaves the callbacks connected.dispose()is removed.Tests
Closes #112