-
|
Hi Everyone, I am trying to make a device that can play both audio from bluetooth or audio from an SD card and switch between these sources at the press of a button. I have been using pschatzmann's library for Bluetooth and this has worked well. I am also using Arduino-Audio-Tools for SD card playback but this has given me some trouble. Currently I have issues switching between these sources. That is, it starts in BT mode by default and I can switch between BT and SD without issue, but if a BT device is connected then it will crash upon switching. This crash is accompanied by malloc errors in console and a register dump. I am able to start in BT mode and play music, only switching between BT/SD after a BT device is connected causes the crash. The code uses a basic state machine with a playbackMode variable. This is setup so BT or SD will have an initialization stage before the main loop code runs. The stages are split up in if blocks like "currentState == initBluetooth" in handleBluetooth() and handleSDcard(). I think there is an issue with some of the BT variables not being deinitialized or reinitialized correctly but my experiments have not yielded much. I will include pastebin links to my source and error output. The code I linked is a simplified version and not very polished but includes all the same BT/SD parts. If anyone has any experience or suggestion for this, please comment! Thanks for reading! Error: https://pastebin.com/pvLTvDbW |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
I have the same issue. I'm trying to implement the bluetooth sink and mp3 player from files. ANd I have the similar problem - when switching from mp3 player to BT sink, it crashes, or just sometimes can connect to BT transmitter, but without any audio output. |
Beta Was this translation helpful? Give feedback.
-
|
I'd be surprised if you would run out of Memory with PSRAM.... |
Beta Was this translation helpful? Give feedback.
I was able to get further following this example: https://github.com/pschatzmann/arduino-audio-tools/blob/cc0fbb7da596824596d763d223550ba7c6c7d665/examples/examples-communication/a2dp/player-sd_a2dp-audiokit/player-sd_a2dp-audiokit.ino
This allowed me to switch between sources without reb…