googlearchive / android-audio-high-performance

We now recommend you use the Oboe libraries:
https://github.com/google/oboe
Apache License 2.0
720 stars 275 forks source link

[aaudio/hello-aaudio] leaks a thread in error callback #103

Closed philburk closed 6 years ago

philburk commented 6 years ago

The error callback launches a thread to restart the stream when disconnected.

It creates a thread and stores a pointer in streamRestartThread, which is never deleted. Also streamRestartThread is never initialized.

I am also concerned that there might be a race condition when the restartStream std::function object goes out of scope.

A better approach might be what we do in Oboe.

std::thread t(oboe_aaudio_error_thread_proc, oboeStream, stream, static_cast<Result>(error));
t.detach();
ggfan commented 6 years ago

let me have a look at it.