aaudio: fix crash from callbacks during close
Move some code from release_l() into a new close_l().
Also stop callbacks before freeing memory in the
The AudioTrack and AudioRecord callbacks can occur
up until their destructors are called. This can lead
to race conditions if the AAudio stream is dismantled
while the AudioTrack or AudioRecord is still alive.
The AudioRecord was being deleted but not the AudioTrack.
That caused some streams to fail if they were using
a FixedBlockReader, which is used when the app
There was also a problem with a few functions like
AAudioStream_getFramesPerBurst() or AAudioStream_getTimestamp(),
which would crash if called after AAudioStream_release( for
Test: see bug for repro of the crash
Test: atest CtsNativeMediaAAudioTestCases
(cherry picked from commit 320910fcf1e7d7729f37f95f591093191414e73f)
13 files changed