Skip to content

Using BluetoothAD2PSink in FreeRTOS class in C++ #629

Answered by pschatzmann
leonardgen asked this question in Q&A
Discussion options

You must be logged in to vote

I think the problem is, like I stated above, that you allocate App on the stack and as soon as setup() is left, it does not exist any more ! This is crashing when you try to access it from the FreeRTOS task.

Move it out to a global variable or allocate it with new on the heap!

I also suggest that you replace the pointers in your App class with regular class objects: use I2SStream i2s;
BluetoothA2DPSink a2dp_sink: this way the destruction of the object will not lead to any memory leaks

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@pschatzmann
Comment options

@leonardgen
Comment options

Answer selected by pschatzmann
Comment options

You must be logged in to vote
1 reply
@pschatzmann
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants