diff options
author | Andreas Huber <andih@google.com> | 2010-10-19 11:19:55 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-10-19 11:19:55 -0700 |
commit | 74e1e56dfa15be0ffea82c60d81846c4f6615421 (patch) | |
tree | 5026e6f89f12c1ba8f67d9249c51c2a427827270 /media/libstagefright/AwesomePlayer.cpp | |
parent | a3764dee0d52e65d16005a411e2d4efd0af20953 (diff) | |
parent | 60d6ac48ea94f9613e21200f3bcf04b7e818ba11 (diff) | |
download | frameworks_av-74e1e56dfa15be0ffea82c60d81846c4f6615421.zip frameworks_av-74e1e56dfa15be0ffea82c60d81846c4f6615421.tar.gz frameworks_av-74e1e56dfa15be0ffea82c60d81846c4f6615421.tar.bz2 |
am 2d00c605: am 52bea277: Merge "If we encounter video stream EOS while seeking we may still need to seek audio." into gingerbread
Merge commit '2d00c6050977f3e03665fbfef93f4f6aed041a63'
* commit '2d00c6050977f3e03665fbfef93f4f6aed041a63':
If we encounter video stream EOS while seeking we may still need to seek audio.
Diffstat (limited to 'media/libstagefright/AwesomePlayer.cpp')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index a0b7f70..ad6cb5b 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -1079,6 +1079,32 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) { return mVideoSource != NULL ? OK : UNKNOWN_ERROR; } +void AwesomePlayer::finishSeekIfNecessary(int64_t videoTimeUs) { + if (!mSeeking) { + return; + } + + if (mAudioPlayer != NULL) { + LOGV("seeking audio to %lld us (%.2f secs).", timeUs, timeUs / 1E6); + + // If we don't have a video time, seek audio to the originally + // requested seek time instead. + + mAudioPlayer->seekTo(videoTimeUs < 0 ? mSeekTimeUs : videoTimeUs); + mAudioPlayer->resume(); + mWatchForAudioSeekComplete = true; + mWatchForAudioEOS = true; + } else if (!mSeekNotificationSent) { + // If we're playing video only, report seek complete now, + // otherwise audio player will notify us later. + notifyListener_l(MEDIA_SEEK_COMPLETE); + } + + mFlags |= FIRST_FRAME; + mSeeking = false; + mSeekNotificationSent = false; +} + void AwesomePlayer::onVideoEvent() { Mutex::Autolock autoLock(mLock); if (!mVideoEventPending) { @@ -1142,6 +1168,14 @@ void AwesomePlayer::onVideoEvent() { continue; } + // So video playback is complete, but we may still have + // a seek request pending that needs to be applied + // to the audio track. + if (mSeeking) { + LOGV("video stream ended while seeking!"); + } + finishSeekIfNecessary(-1); + mFlags |= VIDEO_AT_EOS; postStreamDoneEvent_l(err); return; @@ -1168,24 +1202,7 @@ void AwesomePlayer::onVideoEvent() { mVideoTimeUs = timeUs; } - if (mSeeking) { - if (mAudioPlayer != NULL) { - LOGV("seeking audio to %lld us (%.2f secs).", timeUs, timeUs / 1E6); - - mAudioPlayer->seekTo(timeUs); - mAudioPlayer->resume(); - mWatchForAudioSeekComplete = true; - mWatchForAudioEOS = true; - } else if (!mSeekNotificationSent) { - // If we're playing video only, report seek complete now, - // otherwise audio player will notify us later. - notifyListener_l(MEDIA_SEEK_COMPLETE); - } - - mFlags |= FIRST_FRAME; - mSeeking = false; - mSeekNotificationSent = false; - } + finishSeekIfNecessary(timeUs); TimeSource *ts = (mFlags & AUDIO_AT_EOS) ? &mSystemTimeSource : mTimeSource; |