diff options
author | Eric Laurent <elaurent@google.com> | 2014-03-08 02:00:05 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-08 02:00:05 +0000 |
commit | 38efe8eb08e08610d535a164768851ac7c13d654 (patch) | |
tree | 7853a753cbfac471087604d702ad6b2c546a2269 /media/libmedia | |
parent | 4ee774f322ad3292fcfbb3c120cf250643419425 (diff) | |
parent | 6db20dcb54dad932a3ea2e3a5dca41fce5802eb4 (diff) | |
download | frameworks_av-38efe8eb08e08610d535a164768851ac7c13d654.zip frameworks_av-38efe8eb08e08610d535a164768851ac7c13d654.tar.gz frameworks_av-38efe8eb08e08610d535a164768851ac7c13d654.tar.bz2 |
am 6db20dcb: Merge "AudioTrack: When paused, return cached playback position" into klp-dev
* commit '6db20dcb54dad932a3ea2e3a5dca41fce5802eb4':
AudioTrack: When paused, return cached playback position
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index cce73d4..e290627 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -85,7 +85,8 @@ AudioTrack::AudioTrack() : mStatus(NO_INIT), mIsTimed(false), mPreviousPriority(ANDROID_PRIORITY_NORMAL), - mPreviousSchedulingGroup(SP_DEFAULT) + mPreviousSchedulingGroup(SP_DEFAULT), + mPausedPosition(0) { } @@ -106,7 +107,8 @@ AudioTrack::AudioTrack( : mStatus(NO_INIT), mIsTimed(false), mPreviousPriority(ANDROID_PRIORITY_NORMAL), - mPreviousSchedulingGroup(SP_DEFAULT) + mPreviousSchedulingGroup(SP_DEFAULT), + mPausedPosition(0) { mStatus = set(streamType, sampleRate, format, channelMask, frameCount, flags, cbf, user, notificationFrames, @@ -131,7 +133,8 @@ AudioTrack::AudioTrack( : mStatus(NO_INIT), mIsTimed(false), mPreviousPriority(ANDROID_PRIORITY_NORMAL), - mPreviousSchedulingGroup(SP_DEFAULT) + mPreviousSchedulingGroup(SP_DEFAULT), + mPausedPosition(0) { mStatus = set(streamType, sampleRate, format, channelMask, 0 /*frameCount*/, flags, cbf, user, notificationFrames, @@ -529,6 +532,16 @@ void AudioTrack::pause() } mProxy->interrupt(); mAudioTrack->pause(); + + if (isOffloaded()) { + if (mOutput != 0) { + uint32_t halFrames; + // OffloadThread sends HAL pause in its threadLoop.. time saved + // here can be slightly off + AudioSystem::getRenderPosition(mOutput, &halFrames, &mPausedPosition); + ALOGV("AudioTrack::pause for offload, cache current position %u", mPausedPosition); + } + } } status_t AudioTrack::setVolume(float left, float right) @@ -747,6 +760,12 @@ status_t AudioTrack::getPosition(uint32_t *position) const if (isOffloaded()) { uint32_t dspFrames = 0; + if ((mState == STATE_PAUSED) || (mState == STATE_PAUSED_STOPPING)) { + ALOGV("getPosition called in paused state, return cached position %u", mPausedPosition); + *position = mPausedPosition; + return NO_ERROR; + } + if (mOutput != 0) { uint32_t halFrames; AudioSystem::getRenderPosition(mOutput, &halFrames, &dspFrames); |