Closed ggfan closed 7 years ago
I think another problem might be that stopStream() calls stream->requestStop which is asynchronous. This means there's no guarantee that the streams have actually stopped before they are restarted. Maybe stopStream() should block until the stream state changes to STOPPED, although this may not be desirable behaviour if called from the UI thread.
Phil - what do you think?
the behavior is exposed through stopStreams(), the stop then close logic is there already. The ones inside destructor may not be the cause of the problem, just add the similar change there to make is consistent.
Close() will block until the stream is stopped. Then it deletes the stream.
Good. Closing the output stream first will stop the data callback. If you close the input stream first then the output callback could try to read from a closed stream, which has been deleted. So this is the correct order.
Do you want to merge it? Or do you want me to merge it?
Phil, do you mean AAudioStream_requestStop()
will block until the stream is stopped? The docs explicitly state that the call is async: https://developer.android.com/ndk/reference/group___audio.html#ga6727be00b9cb4330981c20242ce32299
Oh, I see:
AAudioStream_requestStop()
- asynchronous
AAudioStream_close()
- synchronous
I will comment the code to this effect.
when tearing down echo engine, close play stream first, then close record stream