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/AudioStreamInternalCapture.h b/media/libaaudio/src/client/AudioStreamInternalCapture.h
index 6436a53..1d65d87 100644
--- a/media/libaaudio/src/client/AudioStreamInternalCapture.h
+++ b/media/libaaudio/src/client/AudioStreamInternalCapture.h
@@ -46,7 +46,7 @@
}
protected:
- void advanceClientToMatchServerPosition() override;
+ void advanceClientToMatchServerPosition(int32_t serverOffset = 0) override;
/**
* Low level data processing that will not block. It will just read or write as much as it can.