Loading media/libaaudio/src/client/AudioStreamInternal.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,8 @@ aaudio_result_t AudioStreamInternal::requestStart() // Clear any stale timestamps from the previous run. drainTimestampsFromService(); prepareBuffersForStart(); // tell subclasses to get ready aaudio_result_t result = mServiceInterface.startStream(mServiceStreamHandle); if (result == AAUDIO_ERROR_INVALID_HANDLE) { ALOGD("%s() INVALID_HANDLE, stream was probably stolen", __func__); Loading media/libaaudio/src/client/AudioStreamInternal.h +3 −1 Original line number Diff line number Diff line Loading @@ -123,7 +123,9 @@ protected: aaudio_result_t stopCallback(); virtual void advanceClientToMatchServerPosition() = 0; virtual void prepareBuffersForStart() {} virtual void advanceClientToMatchServerPosition(int32_t serverMargin = 0) = 0; virtual void onFlushFromServer() {} Loading media/libaaudio/src/client/AudioStreamInternalCapture.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ AudioStreamInternalCapture::AudioStreamInternalCapture(AAudioServiceInterface & AudioStreamInternalCapture::~AudioStreamInternalCapture() {} void AudioStreamInternalCapture::advanceClientToMatchServerPosition() { void AudioStreamInternalCapture::advanceClientToMatchServerPosition(int32_t serverMargin) { int64_t readCounter = mAudioEndpoint->getDataReadCounter(); int64_t writeCounter = mAudioEndpoint->getDataWriteCounter(); int64_t writeCounter = mAudioEndpoint->getDataWriteCounter() + serverMargin; // Bump offset so caller does not see the retrograde motion in getFramesRead(). int64_t offset = readCounter - writeCounter; Loading media/libaaudio/src/client/AudioStreamInternalCapture.h +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public: } 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. Loading media/libaaudio/src/client/AudioStreamInternalPlay.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -86,8 +86,13 @@ aaudio_result_t AudioStreamInternalPlay::requestFlush() { return mServiceInterface.flushStream(mServiceStreamHandle); } void AudioStreamInternalPlay::advanceClientToMatchServerPosition() { int64_t readCounter = mAudioEndpoint->getDataReadCounter(); void AudioStreamInternalPlay::prepareBuffersForStart() { // Prevent stale data from being played. mAudioEndpoint->eraseDataMemory(); } void AudioStreamInternalPlay::advanceClientToMatchServerPosition(int32_t serverMargin) { int64_t readCounter = mAudioEndpoint->getDataReadCounter() + serverMargin; int64_t writeCounter = mAudioEndpoint->getDataWriteCounter(); // Bump offset so caller does not see the retrograde motion in getFramesRead(). Loading Loading @@ -145,7 +150,9 @@ aaudio_result_t AudioStreamInternalPlay::processDataNow(void *buffer, int32_t nu if (mNeedCatchUp.isRequested()) { // Catch an MMAP pointer that is already advancing. // This will avoid initial underruns caused by a slow cold start. advanceClientToMatchServerPosition(); // We add a one burst margin in case the DSP advances before we can write the data. // This can help prevent the beginning of the stream from being skipped. advanceClientToMatchServerPosition(getFramesPerBurst()); mNeedCatchUp.acknowledge(); } Loading Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,8 @@ aaudio_result_t AudioStreamInternal::requestStart() // Clear any stale timestamps from the previous run. drainTimestampsFromService(); prepareBuffersForStart(); // tell subclasses to get ready aaudio_result_t result = mServiceInterface.startStream(mServiceStreamHandle); if (result == AAUDIO_ERROR_INVALID_HANDLE) { ALOGD("%s() INVALID_HANDLE, stream was probably stolen", __func__); Loading
media/libaaudio/src/client/AudioStreamInternal.h +3 −1 Original line number Diff line number Diff line Loading @@ -123,7 +123,9 @@ protected: aaudio_result_t stopCallback(); virtual void advanceClientToMatchServerPosition() = 0; virtual void prepareBuffersForStart() {} virtual void advanceClientToMatchServerPosition(int32_t serverMargin = 0) = 0; virtual void onFlushFromServer() {} Loading
media/libaaudio/src/client/AudioStreamInternalCapture.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ AudioStreamInternalCapture::AudioStreamInternalCapture(AAudioServiceInterface & AudioStreamInternalCapture::~AudioStreamInternalCapture() {} void AudioStreamInternalCapture::advanceClientToMatchServerPosition() { void AudioStreamInternalCapture::advanceClientToMatchServerPosition(int32_t serverMargin) { int64_t readCounter = mAudioEndpoint->getDataReadCounter(); int64_t writeCounter = mAudioEndpoint->getDataWriteCounter(); int64_t writeCounter = mAudioEndpoint->getDataWriteCounter() + serverMargin; // Bump offset so caller does not see the retrograde motion in getFramesRead(). int64_t offset = readCounter - writeCounter; Loading
media/libaaudio/src/client/AudioStreamInternalCapture.h +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public: } 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. Loading
media/libaaudio/src/client/AudioStreamInternalPlay.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -86,8 +86,13 @@ aaudio_result_t AudioStreamInternalPlay::requestFlush() { return mServiceInterface.flushStream(mServiceStreamHandle); } void AudioStreamInternalPlay::advanceClientToMatchServerPosition() { int64_t readCounter = mAudioEndpoint->getDataReadCounter(); void AudioStreamInternalPlay::prepareBuffersForStart() { // Prevent stale data from being played. mAudioEndpoint->eraseDataMemory(); } void AudioStreamInternalPlay::advanceClientToMatchServerPosition(int32_t serverMargin) { int64_t readCounter = mAudioEndpoint->getDataReadCounter() + serverMargin; int64_t writeCounter = mAudioEndpoint->getDataWriteCounter(); // Bump offset so caller does not see the retrograde motion in getFramesRead(). Loading Loading @@ -145,7 +150,9 @@ aaudio_result_t AudioStreamInternalPlay::processDataNow(void *buffer, int32_t nu if (mNeedCatchUp.isRequested()) { // Catch an MMAP pointer that is already advancing. // This will avoid initial underruns caused by a slow cold start. advanceClientToMatchServerPosition(); // We add a one burst margin in case the DSP advances before we can write the data. // This can help prevent the beginning of the stream from being skipped. advanceClientToMatchServerPosition(getFramesPerBurst()); mNeedCatchUp.acknowledge(); } Loading