diff options
author | Wang Liyong <liyong.x.wang@sonymobile.com> | 2012-04-13 19:34:00 +0900 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-30 20:28:23 -0800 |
commit | aeda337c2fad2db2d25128c4bd68fd7c2c32c09f (patch) | |
tree | 9eab27fe9b766ef6c471e7cdc60415b5110f3d3d | |
parent | 8a55244e9847fba8252933ced56b56ecc77204eb (diff) | |
download | frameworks_av-aeda337c2fad2db2d25128c4bd68fd7c2c32c09f.zip frameworks_av-aeda337c2fad2db2d25128c4bd68fd7c2c32c09f.tar.gz frameworks_av-aeda337c2fad2db2d25128c4bd68fd7c2c32c09f.tar.bz2 |
Fix for getPosition after seek
When starting playback with a seek pending
(calling seek before start) there is a brief period
when the audioplayer returns an incorrect position (zero)
This is caused by that mSeeking is set to false
before the position in the audioplayer actually is updated.
Change-Id: Iaec355c8fdfe589d9b826d20c2531034f2b4e6fb
-rw-r--r-- | media/libstagefright/AudioPlayer.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp index 95441bc..1f9383b 100644 --- a/media/libstagefright/AudioPlayer.cpp +++ b/media/libstagefright/AudioPlayer.cpp @@ -102,7 +102,6 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) { MediaSource::ReadOptions options; if (mSeeking) { options.setSeekTo(mSeekTimeUs); - mSeeking = false; } mFirstBufferResult = mSource->read(&mFirstBuffer, &options); @@ -112,8 +111,25 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) { CHECK(mFirstBuffer == NULL); mFirstBufferResult = OK; mIsFirstBuffer = false; + + if (mSeeking) { + mPositionTimeRealUs = 0; + mPositionTimeMediaUs = mSeekTimeUs; + mSeeking = false; + } + } else { mIsFirstBuffer = true; + + if (mSeeking) { + mPositionTimeRealUs = 0; + if (mFirstBuffer == NULL || !mFirstBuffer->meta_data()->findInt64( + kKeyTime, &mPositionTimeMediaUs)) { + return UNKNOWN_ERROR; + } + mSeeking = false; + } + } sp<MetaData> format = mSource->getFormat(); |