diff options
author | Andreas Huber <andih@google.com> | 2011-05-10 13:56:39 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-05-10 14:05:02 -0700 |
commit | c0dfc5b02d4179769bbdd25c10d430576ec09568 (patch) | |
tree | db15fa069e3b9b0f2f0e26961aa6716a270a4529 /media/libstagefright | |
parent | 70ccfd44c4bfe95ddecc2df6c3695efc48229d72 (diff) | |
download | frameworks_av-c0dfc5b02d4179769bbdd25c10d430576ec09568.zip frameworks_av-c0dfc5b02d4179769bbdd25c10d430576ec09568.tar.gz frameworks_av-c0dfc5b02d4179769bbdd25c10d430576ec09568.tar.bz2 |
Properly honour any pending seek request when reading the first buffer after
starting the audio player.
Change-Id: Ibedc1804a8c444e4d0f5be4eb87b22ed5d2c367d
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/AudioPlayer.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 13 | ||||
-rw-r--r-- | media/libstagefright/include/AwesomePlayer.h | 1 |
3 files changed, 21 insertions, 1 deletions
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp index 69f9c23..dd69e6b 100644 --- a/media/libstagefright/AudioPlayer.cpp +++ b/media/libstagefright/AudioPlayer.cpp @@ -84,7 +84,13 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) { CHECK(mFirstBuffer == NULL); - mFirstBufferResult = mSource->read(&mFirstBuffer); + MediaSource::ReadOptions options; + if (mSeeking) { + options.setSeekTo(mSeekTimeUs); + mSeeking = false; + } + + mFirstBufferResult = mSource->read(&mFirstBuffer, &options); if (mFirstBufferResult == INFO_FORMAT_CHANGED) { LOGV("INFO_FORMAT_CHANGED!!!"); diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index cccd0b7..dcc268f 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -831,6 +831,8 @@ status_t AwesomePlayer::startAudioPlayer_l() { if (!(mFlags & AUDIOPLAYER_STARTED)) { mFlags |= AUDIOPLAYER_STARTED; + bool wasSeeking = mAudioPlayer->isSeeking(); + // We've already started the MediaSource in order to enable // the prefetcher to read its data. status_t err = mAudioPlayer->start( @@ -840,6 +842,13 @@ status_t AwesomePlayer::startAudioPlayer_l() { notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err); return err; } + + if (wasSeeking) { + CHECK(!mAudioPlayer->isSeeking()); + + // We will have finished the seek while starting the audio player. + postAudioSeekComplete_l(); + } } else { mAudioPlayer->resume(); } @@ -1957,6 +1966,10 @@ void AwesomePlayer::postAudioEOS(int64_t delayUs) { void AwesomePlayer::postAudioSeekComplete() { Mutex::Autolock autoLock(mLock); + postAudioSeekComplete_l(); +} + +void AwesomePlayer::postAudioSeekComplete_l() { postCheckAudioStatusEvent_l(0 /* delayUs */); } diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index fd3ddf7..835d2bb 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -281,6 +281,7 @@ private: void ensureCacheIsFetching_l(); status_t startAudioPlayer_l(); + void postAudioSeekComplete_l(); void shutdownVideoDecoder_l(); void setNativeWindow_l(const sp<ANativeWindow> &native); |