aaudio: fix race at start of stream

When an MMAP stream is started, it is possible for the
beginning of the sound to be lost. One reason is because
the written data is placed right in front of the DSP read position.
But the DSP position is not well known when the stream is starting
because we only have a few timestamps.
If the DSP advances before the data is written then the first burst
might be skipped

This CL places the initial write one burst ahead of the estimated DSP
position.

The same code is used to synchronize the read/write counters
when a flush() occurs. In that case the serverMargin is zero.

Bug: 156313728
Bug: 157510931
Bug: 158547650
Test: atest CtsNativeMediaAAudioTestCases
Test: see bugs for other test cases
Change-Id: I96170a924c69eee080a497b52cc6c1f3498c5455
diff --git a/media/libaaudio/src/client/AudioStreamInternalPlay.h b/media/libaaudio/src/client/AudioStreamInternalPlay.h
index 2e93157..be95da6 100644
--- a/media/libaaudio/src/client/AudioStreamInternalPlay.h
+++ b/media/libaaudio/src/client/AudioStreamInternalPlay.h
@@ -65,7 +65,9 @@
 
 protected:
 
-    void advanceClientToMatchServerPosition() override;
+    void prepareBuffersForStart() override;
+
+    void advanceClientToMatchServerPosition(int32_t serverMargin = 0) override;
 
     void onFlushFromServer() override;