microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
44 stars 25 forks source link

`audio.stop()` & `microphone.stop_recording()` should only return when fully stopped #206

Open microbit-carlos opened 5 months ago

microbit-carlos commented 5 months ago

With audio it can take quite a few milliseconds before audio.is_playing() returns False:

>>> audio.play(microbit.Sound.HELLO, wait=False); audio.stop(); audio.is_playing()
True
>>> audio.play(microbit.Sound.HELLO, wait=False); audio.stop(); sleep(6); audio.is_playing()
False

With microphone the wait is a lot shorter, but still present:

>>> af = audio.AudioFrame(1000)
>>> microphone.record_into(af, wait=False); microphone.stop_recording(); microphone.is_recording()
True
>>> microphone.record_into(af, wait=False); microphone.stop_recording(); sleep(1); microphone.is_recording()
False