Loading media/libaaudio/src/client/AudioStreamInternal.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -713,3 +713,7 @@ int32_t AudioStreamInternal::getFramesPerBurst() const { aaudio_result_t AudioStreamInternal::joinThread(void** returnArg) { return AudioStream::joinThread(returnArg, calculateReasonableTimeout(getFramesPerBurst())); } bool AudioStreamInternal::isClockModelInControl() const { return isActive() && mAudioEndpoint.isFreeRunning() && mClockModel.isRunning(); } media/libaaudio/src/client/AudioStreamInternal.h +8 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,14 @@ protected: */ bool isInService() const { return mInService; } /** * Is the service FIFO position currently controlled by the AAudio service or HAL, * or set based on the Clock Model. * * @return true if the ClockModel is currently determining the FIFO position */ bool isClockModelInControl() const; IsochronousClockModel mClockModel; // timing model for chasing the HAL AudioEndpoint mAudioEndpoint; // source for reads or sink for writes Loading media/libaaudio/src/client/AudioStreamInternalCapture.cpp +4 −9 Original line number Diff line number Diff line Loading @@ -210,17 +210,12 @@ aaudio_result_t AudioStreamInternalCapture::readNowWithConversion(void *buffer, } int64_t AudioStreamInternalCapture::getFramesWritten() { int64_t framesWrittenHardware; if (isActive()) { framesWrittenHardware = mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()); } else { framesWrittenHardware = mAudioEndpoint.getDataWriteCounter(); } // Prevent retrograde motion. const int64_t framesWrittenHardware = isClockModelInControl() ? mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()) : mAudioEndpoint.getDataWriteCounter(); // Add service offset and prevent retrograde motion. mLastFramesWritten = std::max(mLastFramesWritten, framesWrittenHardware + mFramesOffsetFromService); //ALOGD("getFramesWritten() returns %lld", // (long long)mLastFramesWritten); return mLastFramesWritten; } Loading media/libaaudio/src/client/AudioStreamInternalPlay.cpp +9 −19 Original line number Diff line number Diff line Loading @@ -242,27 +242,17 @@ aaudio_result_t AudioStreamInternalPlay::writeNowWithConversion(const void *buff return framesWritten; } int64_t AudioStreamInternalPlay::getFramesRead() { int64_t framesReadHardware; if (isActive()) { framesReadHardware = mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()); } else { framesReadHardware = mAudioEndpoint.getDataReadCounter(); } int64_t framesRead = framesReadHardware + mFramesOffsetFromService; // Prevent retrograde motion. if (framesRead < mLastFramesRead) { framesRead = mLastFramesRead; } else { mLastFramesRead = framesRead; } return framesRead; int64_t AudioStreamInternalPlay::getFramesRead() { const int64_t framesReadHardware = isClockModelInControl() ? mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()) : mAudioEndpoint.getDataReadCounter(); // Add service offset and prevent retrograde motion. mLastFramesRead = std::max(mLastFramesRead, framesReadHardware + mFramesOffsetFromService); return mLastFramesRead; } int64_t AudioStreamInternalPlay::getFramesWritten() { int64_t framesWritten = mAudioEndpoint.getDataWriteCounter() int64_t AudioStreamInternalPlay::getFramesWritten() { const int64_t framesWritten = mAudioEndpoint.getDataWriteCounter() + mFramesOffsetFromService; return framesWritten; } Loading media/libaaudio/src/client/IsochronousClockModel.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,14 @@ void IsochronousClockModel::stop(int64_t nanoTime) { mState = STATE_STOPPED; } bool IsochronousClockModel::isStarting() { bool IsochronousClockModel::isStarting() const { return mState == STATE_STARTING; } bool IsochronousClockModel::isRunning() const { return mState == STATE_RUNNING; } void IsochronousClockModel::processTimestamp(int64_t framePosition, int64_t nanoTime) { // ALOGD("processTimestamp() - framePosition = %lld at nanoTime %llu", // (long long)framePosition, Loading Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -713,3 +713,7 @@ int32_t AudioStreamInternal::getFramesPerBurst() const { aaudio_result_t AudioStreamInternal::joinThread(void** returnArg) { return AudioStream::joinThread(returnArg, calculateReasonableTimeout(getFramesPerBurst())); } bool AudioStreamInternal::isClockModelInControl() const { return isActive() && mAudioEndpoint.isFreeRunning() && mClockModel.isRunning(); }
media/libaaudio/src/client/AudioStreamInternal.h +8 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,14 @@ protected: */ bool isInService() const { return mInService; } /** * Is the service FIFO position currently controlled by the AAudio service or HAL, * or set based on the Clock Model. * * @return true if the ClockModel is currently determining the FIFO position */ bool isClockModelInControl() const; IsochronousClockModel mClockModel; // timing model for chasing the HAL AudioEndpoint mAudioEndpoint; // source for reads or sink for writes Loading
media/libaaudio/src/client/AudioStreamInternalCapture.cpp +4 −9 Original line number Diff line number Diff line Loading @@ -210,17 +210,12 @@ aaudio_result_t AudioStreamInternalCapture::readNowWithConversion(void *buffer, } int64_t AudioStreamInternalCapture::getFramesWritten() { int64_t framesWrittenHardware; if (isActive()) { framesWrittenHardware = mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()); } else { framesWrittenHardware = mAudioEndpoint.getDataWriteCounter(); } // Prevent retrograde motion. const int64_t framesWrittenHardware = isClockModelInControl() ? mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()) : mAudioEndpoint.getDataWriteCounter(); // Add service offset and prevent retrograde motion. mLastFramesWritten = std::max(mLastFramesWritten, framesWrittenHardware + mFramesOffsetFromService); //ALOGD("getFramesWritten() returns %lld", // (long long)mLastFramesWritten); return mLastFramesWritten; } Loading
media/libaaudio/src/client/AudioStreamInternalPlay.cpp +9 −19 Original line number Diff line number Diff line Loading @@ -242,27 +242,17 @@ aaudio_result_t AudioStreamInternalPlay::writeNowWithConversion(const void *buff return framesWritten; } int64_t AudioStreamInternalPlay::getFramesRead() { int64_t framesReadHardware; if (isActive()) { framesReadHardware = mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()); } else { framesReadHardware = mAudioEndpoint.getDataReadCounter(); } int64_t framesRead = framesReadHardware + mFramesOffsetFromService; // Prevent retrograde motion. if (framesRead < mLastFramesRead) { framesRead = mLastFramesRead; } else { mLastFramesRead = framesRead; } return framesRead; int64_t AudioStreamInternalPlay::getFramesRead() { const int64_t framesReadHardware = isClockModelInControl() ? mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()) : mAudioEndpoint.getDataReadCounter(); // Add service offset and prevent retrograde motion. mLastFramesRead = std::max(mLastFramesRead, framesReadHardware + mFramesOffsetFromService); return mLastFramesRead; } int64_t AudioStreamInternalPlay::getFramesWritten() { int64_t framesWritten = mAudioEndpoint.getDataWriteCounter() int64_t AudioStreamInternalPlay::getFramesWritten() { const int64_t framesWritten = mAudioEndpoint.getDataWriteCounter() + mFramesOffsetFromService; return framesWritten; } Loading
media/libaaudio/src/client/IsochronousClockModel.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,14 @@ void IsochronousClockModel::stop(int64_t nanoTime) { mState = STATE_STOPPED; } bool IsochronousClockModel::isStarting() { bool IsochronousClockModel::isStarting() const { return mState == STATE_STARTING; } bool IsochronousClockModel::isRunning() const { return mState == STATE_RUNNING; } void IsochronousClockModel::processTimestamp(int64_t framePosition, int64_t nanoTime) { // ALOGD("processTimestamp() - framePosition = %lld at nanoTime %llu", // (long long)framePosition, Loading