aaudio: prevent deadlock when stop() calls disconnect()

Move all calls to send the timestamp into the one timestamp thread.

There was a clear code path that could lead to a deadlock.
If the call to get the timestamp from the HAL returned
an unexpected error code then it would call disconnect().
If that happened below the call to stop() then the
deadlock would occur.

The sequence of calls was AAudioServiceStreamBase::stop()
  which locked mLock,
  then called AAudioServiceStreamBase::stop_l(),
  which called AAudioServiceStreamBase:sendCurrentTimeStamp(),
  which called AAudioServiceStreamMMAP::getFreeRunningPosition(),
  which called disconnect(),
  which locked mLock AGAIN.

It is not clear what would trigger the error return
from the HAL but a routing change may be involved.

The bug was discovered during stress tests and we do not
have a clear repro case.

Bug: 182852602
Bug: 153358911
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: I575f75ece9b459e7412bca293d7338babe76b3a7
Merged-In: I575f75ece9b459e7412bca293d7338babe76b3a7
(cherry picked from commit 45da1b7e3231bf3475cb9ca1a2243a27355c0466)
(cherry picked from commit 9dd928e100d38c42f68c04c01f09fa8c8cb606d3)
1 file changed