earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 boards
GNU Lesser General Public License v2.1
1.88k stars 394 forks source link

Fix crash on audio end from IRQ, refactor A2DP #2189

Closed earlephilhower closed 1 month ago

earlephilhower commented 1 month ago

Fixes #2188

We get a call to stop the audio channel from a timer/IRQ context, so can't safely remove the IRQ handler for the AudioBufferManager. The SDK will panic.

Because the IRQ handler will be a noop if it's not uninstalled, we will instead just leave our shared handler in place and let it do nothing.

Use a common BluetoothLock RAII in BluetoothAudio to clen up the code and automatically lock BT for the AVRCP button methods.