diff options
author | Andy Hung <hunga@google.com> | 2015-08-21 22:24:03 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-21 22:24:03 +0000 |
commit | 37ea1d0de9b7c9ffbfa7cb1895dcbf4a4f92803a (patch) | |
tree | 080b0008cbef15608159afba75c6ccc1f3855efa | |
parent | 32a5c4fbedbccdeaa89a81ce1097961f8a9cfd74 (diff) | |
parent | e857d28d48e6088d4cf5fcbed7f411c73622b388 (diff) | |
download | frameworks_av-37ea1d0de9b7c9ffbfa7cb1895dcbf4a4f92803a.zip frameworks_av-37ea1d0de9b7c9ffbfa7cb1895dcbf4a4f92803a.tar.gz frameworks_av-37ea1d0de9b7c9ffbfa7cb1895dcbf4a4f92803a.tar.bz2 |
am e857d28d: Merge "TimestretchBufferProvider: getNextBuffer should follow API" into mnc-dev
* commit 'e857d28d48e6088d4cf5fcbed7f411c73622b388':
TimestretchBufferProvider: getNextBuffer should follow API
-rw-r--r-- | services/audioflinger/BufferProviders.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/services/audioflinger/BufferProviders.cpp b/services/audioflinger/BufferProviders.cpp index 3566ee2..a8be206 100644 --- a/services/audioflinger/BufferProviders.cpp +++ b/services/audioflinger/BufferProviders.cpp @@ -386,34 +386,37 @@ status_t TimestretchBufferProvider::getNextBuffer( // need to fetch more data const size_t outputDesired = pBuffer->frameCount - mRemaining; - mBuffer.frameCount = mPlaybackRate.mSpeed == AUDIO_TIMESTRETCH_SPEED_NORMAL - ? outputDesired : outputDesired * mPlaybackRate.mSpeed + 1; + size_t dstAvailable; + do { + mBuffer.frameCount = mPlaybackRate.mSpeed == AUDIO_TIMESTRETCH_SPEED_NORMAL + ? outputDesired : outputDesired * mPlaybackRate.mSpeed + 1; - status_t res = mTrackBufferProvider->getNextBuffer(&mBuffer, pts); + status_t res = mTrackBufferProvider->getNextBuffer(&mBuffer, pts); - ALOG_ASSERT(res == OK || mBuffer.frameCount == 0); - if (res != OK || mBuffer.frameCount == 0) { // not needed by API spec, but to be safe. - ALOGD("buffer error"); - if (mRemaining == 0) { - pBuffer->raw = NULL; - pBuffer->frameCount = 0; - return res; - } else { // return partial count - pBuffer->raw = mLocalBufferData; - pBuffer->frameCount = mRemaining; - return OK; + ALOG_ASSERT(res == OK || mBuffer.frameCount == 0); + if (res != OK || mBuffer.frameCount == 0) { // not needed by API spec, but to be safe. + ALOGV("upstream provider cannot provide data"); + if (mRemaining == 0) { + pBuffer->raw = NULL; + pBuffer->frameCount = 0; + return res; + } else { // return partial count + pBuffer->raw = mLocalBufferData; + pBuffer->frameCount = mRemaining; + return OK; + } } - } - // time-stretch the data - size_t dstAvailable = min(mLocalBufferFrameCount - mRemaining, outputDesired); - size_t srcAvailable = mBuffer.frameCount; - processFrames((uint8_t*)mLocalBufferData + mRemaining * mFrameSize, &dstAvailable, - mBuffer.raw, &srcAvailable); + // time-stretch the data + dstAvailable = min(mLocalBufferFrameCount - mRemaining, outputDesired); + size_t srcAvailable = mBuffer.frameCount; + processFrames((uint8_t*)mLocalBufferData + mRemaining * mFrameSize, &dstAvailable, + mBuffer.raw, &srcAvailable); - // release all data consumed - mBuffer.frameCount = srcAvailable; - mTrackBufferProvider->releaseBuffer(&mBuffer); + // release all data consumed + mBuffer.frameCount = srcAvailable; + mTrackBufferProvider->releaseBuffer(&mBuffer); + } while (dstAvailable == 0); // try until we get output data or upstream provider fails. // update buffer vars with the actual data processed and return with buffer mRemaining += dstAvailable; |