diff options
author | Eric Laurent <elaurent@google.com> | 2013-09-20 11:22:17 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-20 11:22:17 -0700 |
commit | 0230a2a8a413076a138db4c4e1dea018104fd5e2 (patch) | |
tree | 1d78509ed7b005fe0bc3a998c8eda13a93f65876 | |
parent | d2b80a1fb90cb4dc3f569e716af0279c1e1ea72d (diff) | |
parent | c6bed216e3a759a855ac4b9b743fbaed2d5929c1 (diff) | |
download | frameworks_av-0230a2a8a413076a138db4c4e1dea018104fd5e2.zip frameworks_av-0230a2a8a413076a138db4c4e1dea018104fd5e2.tar.gz frameworks_av-0230a2a8a413076a138db4c4e1dea018104fd5e2.tar.bz2 |
am c6bed216: am a3b97ad2: Merge "audioflinger: implement getTimestamp() for offloaded tracks" into klp-dev
* commit 'c6bed216e3a759a855ac4b9b743fbaed2d5929c1':
audioflinger: implement getTimestamp() for offloaded tracks
-rw-r--r-- | services/audioflinger/Threads.cpp | 16 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 2 | ||||
-rw-r--r-- | services/audioflinger/Tracks.cpp | 28 |
3 files changed, 34 insertions, 12 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 533ef6a..b0a1ee2 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -2347,6 +2347,22 @@ void AudioFlinger::PlaybackThread::removeTracks_l(const Vector< sp<Track> >& tra } +status_t AudioFlinger::PlaybackThread::getTimestamp_l(AudioTimestamp& timestamp) +{ + if (mNormalSink != 0) { + return mNormalSink->getTimestamp(timestamp); + } + if (mType == OFFLOAD && mOutput->stream->get_presentation_position) { + uint64_t position64; + int ret = mOutput->stream->get_presentation_position( + mOutput->stream, &position64, ×tamp.mTime); + if (ret == 0) { + timestamp.mPosition = (uint32_t)position64; + return NO_ERROR; + } + } + return INVALID_OPERATION; +} // ---------------------------------------------------------------------------- AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index 51b134b..b96e1c8 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -469,6 +469,8 @@ public: // Return's the HAL's frame count i.e. fast mixer buffer size. size_t frameCountHAL() const { return mFrameCount; } + status_t getTimestamp_l(AudioTimestamp& timestamp); + protected: // updated by readOutputParameters() size_t mNormalFrameCount; // normal mixer and effects diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index c9ff7e1..9002f9b 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -766,19 +766,23 @@ status_t AudioFlinger::PlaybackThread::Track::getTimestamp(AudioTimestamp& times } Mutex::Autolock _l(thread->mLock); PlaybackThread *playbackThread = (PlaybackThread *)thread.get(); - if (!playbackThread->mLatchQValid) { - return INVALID_OPERATION; - } - uint32_t unpresentedFrames = - ((int64_t) playbackThread->mLatchQ.mUnpresentedFrames * mSampleRate) / - playbackThread->mSampleRate; - uint32_t framesWritten = mAudioTrackServerProxy->framesReleased(); - if (framesWritten < unpresentedFrames) { - return INVALID_OPERATION; + if (!isOffloaded()) { + if (!playbackThread->mLatchQValid) { + return INVALID_OPERATION; + } + uint32_t unpresentedFrames = + ((int64_t) playbackThread->mLatchQ.mUnpresentedFrames * mSampleRate) / + playbackThread->mSampleRate; + uint32_t framesWritten = mAudioTrackServerProxy->framesReleased(); + if (framesWritten < unpresentedFrames) { + return INVALID_OPERATION; + } + timestamp.mPosition = framesWritten - unpresentedFrames; + timestamp.mTime = playbackThread->mLatchQ.mTimestamp.mTime; + return NO_ERROR; } - timestamp.mPosition = framesWritten - unpresentedFrames; - timestamp.mTime = playbackThread->mLatchQ.mTimestamp.mTime; - return NO_ERROR; + + return playbackThread->getTimestamp_l(timestamp); } status_t AudioFlinger::PlaybackThread::Track::attachAuxEffect(int EffectId) |