summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Tracks.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-03-26 19:13:55 -0700
committerAndy Hung <hunga@google.com>2015-04-09 18:49:15 -0700
commit8edb8dc44b8a2f81bdb5db645b6b708548771a31 (patch)
tree663bda0f8a3d43894fa6d3d3f4283ed0df427f03 /services/audioflinger/Tracks.cpp
parentc5656cc900aeb4a705e27508dd82c70030a97709 (diff)
downloadframeworks_av-8edb8dc44b8a2f81bdb5db645b6b708548771a31.zip
frameworks_av-8edb8dc44b8a2f81bdb5db645b6b708548771a31.tar.gz
frameworks_av-8edb8dc44b8a2f81bdb5db645b6b708548771a31.tar.bz2
Add playback rate to AudioTrack
Bug: 19196501 Change-Id: I6411e1d3ce652b711a71a6d9df020cb5f60d4714
Diffstat (limited to 'services/audioflinger/Tracks.cpp')
-rw-r--r--services/audioflinger/Tracks.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 1566b1f..da2d634 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -903,9 +903,14 @@ status_t AudioFlinger::PlaybackThread::Track::getTimestamp(AudioTimestamp& times
mPreviousTimestampValid = false;
return INVALID_OPERATION;
}
+ // FIXME Not accurate under dynamic changes of sample rate and speed.
+ // Do not use track's mSampleRate as it is not current for mixer tracks.
+ uint32_t sampleRate = mAudioTrackServerProxy->getSampleRate();
+ float speed, pitch;
+ mAudioTrackServerProxy->getPlaybackRate(&speed, &pitch);
uint32_t unpresentedFrames =
- ((int64_t) playbackThread->mLatchQ.mUnpresentedFrames * mSampleRate) /
- playbackThread->mSampleRate;
+ ((double) playbackThread->mLatchQ.mUnpresentedFrames * sampleRate * speed)
+ / playbackThread->mSampleRate;
// FIXME Since we're using a raw pointer as the key, it is theoretically possible
// for a brand new track to share the same address as a recently destroyed
// track, and thus for us to get the frames released of the wrong track.