diff options
author | Andreas Huber <andih@google.com> | 2010-10-19 09:34:44 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-10-19 09:34:44 -0700 |
commit | 4769cc92740e3ab58e9263d42553c12bbf79e3be (patch) | |
tree | 9d745401de93897dea77649e00a59ee582a5fe35 /media/libstagefright/AwesomePlayer.cpp | |
parent | f200777290d2e3e8b580c512cc0808eae9790705 (diff) | |
download | frameworks_av-4769cc92740e3ab58e9263d42553c12bbf79e3be.zip frameworks_av-4769cc92740e3ab58e9263d42553c12bbf79e3be.tar.gz frameworks_av-4769cc92740e3ab58e9263d42553c12bbf79e3be.tar.bz2 |
If we encounter video stream EOS while seeking we may still need to seek audio.
Change-Id: Ie260942247b6810ca94e86328a3725d75b12181d
related-to-bug: 3108724
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 57bea8c..064a00c 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -1059,6 +1059,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) { @@ -1120,6 +1146,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; @@ -1146,24 +1180,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; |