diff options
author | Eric Laurent <elaurent@google.com> | 2013-07-26 17:16:50 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2013-12-17 13:41:37 -0800 |
commit | 5e49afd05566820517747b9a8071c99ec0918328 (patch) | |
tree | 0dd9697822c0bd70f03bb776bc78e2da60f28991 /media/libstagefright | |
parent | a67c76538fff102cd44b2f38dd073df5f2a33605 (diff) | |
download | frameworks_av-5e49afd05566820517747b9a8071c99ec0918328.zip frameworks_av-5e49afd05566820517747b9a8071c99ec0918328.tar.gz frameworks_av-5e49afd05566820517747b9a8071c99ec0918328.tar.bz2 |
update offloaded audio track sampling rate
AudioPlayer must read the sampling rate from offloaded audio sinks
whenever a new time position is computed as the decoder can update
the sampling rate on the fly.
Change-Id: I997e5248cfd4017aeceb4e11689324ded2a5bc88
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/AudioPlayer.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp index a8a8786..05ee34e 100644 --- a/media/libstagefright/AudioPlayer.cpp +++ b/media/libstagefright/AudioPlayer.cpp @@ -721,16 +721,27 @@ int64_t AudioPlayer::getRealTimeUsLocked() const { return result + diffUs; } -int64_t AudioPlayer::getOutputPlayPositionUs_l() const +int64_t AudioPlayer::getOutputPlayPositionUs_l() { uint32_t playedSamples = 0; + uint32_t sampleRate; if (mAudioSink != NULL) { mAudioSink->getPosition(&playedSamples); + sampleRate = mAudioSink->getSampleRate(); } else { mAudioTrack->getPosition(&playedSamples); + sampleRate = mAudioTrack->getSampleRate(); + } + if (sampleRate != 0) { + mSampleRate = sampleRate; } - const int64_t playedUs = (static_cast<int64_t>(playedSamples) * 1000000 ) / mSampleRate; + int64_t playedUs; + if (mSampleRate != 0) { + playedUs = (static_cast<int64_t>(playedSamples) * 1000000 ) / mSampleRate; + } else { + playedUs = 0; + } // HAL position is relative to the first buffer we sent at mStartPosUs const int64_t renderedDuration = mStartPosUs + playedUs; |