summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-09-20 09:36:34 -0700
committerEric Laurent <elaurent@google.com>2013-09-20 09:36:34 -0700
commitaccc147666bfd37fc8b4ef745f18a8c751555ec2 (patch)
treea091aa566ed09e8efe881a16e3806ee4169de3f0 /services
parent5baf2af52cd186633b7173196c1e4a4cd3435f22 (diff)
downloadframeworks_av-accc147666bfd37fc8b4ef745f18a8c751555ec2.zip
frameworks_av-accc147666bfd37fc8b4ef745f18a8c751555ec2.tar.gz
frameworks_av-accc147666bfd37fc8b4ef745f18a8c751555ec2.tar.bz2
audioflinger: implement getTimestamp() for offloaded tracks
Bug: 9587132. Change-Id: Ie9d5f4cca96306d08bc9a2dbd6edd8953096702d
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/Threads.cpp16
-rw-r--r--services/audioflinger/Threads.h2
-rw-r--r--services/audioflinger/Tracks.cpp28
3 files changed, 34 insertions, 12 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 7d0ecac..242e020 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2340,6 +2340,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, &timestamp.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 3fe470c..f13cb54 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -466,6 +466,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 57aad1e..ccba014 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -757,19 +757,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)