summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-10-19 10:08:32 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-19 10:08:32 -0700
commit60d6ac48ea94f9613e21200f3bcf04b7e818ba11 (patch)
treeac03296024f34290f31ad0a91185729ebef3864d /media/libstagefright
parent475c5fabc59a86eb667f3afb4b1523f9b98797e3 (diff)
parent4769cc92740e3ab58e9263d42553c12bbf79e3be (diff)
downloadframeworks_av-60d6ac48ea94f9613e21200f3bcf04b7e818ba11.zip
frameworks_av-60d6ac48ea94f9613e21200f3bcf04b7e818ba11.tar.gz
frameworks_av-60d6ac48ea94f9613e21200f3bcf04b7e818ba11.tar.bz2
am 52bea277: Merge "If we encounter video stream EOS while seeking we may still need to seek audio." into gingerbread
Merge commit '52bea277ff92a2a1780e035c82c72082434e7b16' into gingerbread-plus-aosp * commit '52bea277ff92a2a1780e035c82c72082434e7b16': If we encounter video stream EOS while seeking we may still need to seek audio.
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/AwesomePlayer.cpp53
-rw-r--r--media/libstagefright/include/AwesomePlayer.h2
2 files changed, 37 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;
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 46a0c65..3020a09 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -258,6 +258,8 @@ private:
bool getBitrate(int64_t *bitrate);
+ void finishSeekIfNecessary(int64_t videoTimeUs);
+
AwesomePlayer(const AwesomePlayer &);
AwesomePlayer &operator=(const AwesomePlayer &);
};