Merge "Properly send a MEDIA_SEEK_COMPLETE notification for a seek request while paused (legacy behaviour)." into froyo

This commit is contained in:
Andreas Huber
2010-03-31 09:48:22 -07:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 2 deletions

View File

@@ -395,6 +395,7 @@ void AwesomePlayer::reset_l() {
mVideoTimeUs = 0; mVideoTimeUs = 0;
mSeeking = false; mSeeking = false;
mSeekNotificationSent = false;
mSeekTimeUs = 0; mSeekTimeUs = 0;
mUri.setTo(""); mUri.setTo("");
@@ -686,11 +687,20 @@ status_t AwesomePlayer::seekTo(int64_t timeUs) {
status_t AwesomePlayer::seekTo_l(int64_t timeUs) { status_t AwesomePlayer::seekTo_l(int64_t timeUs) {
mSeeking = true; mSeeking = true;
mSeekNotificationSent = false;
mSeekTimeUs = timeUs; mSeekTimeUs = timeUs;
mFlags &= ~AT_EOS; mFlags &= ~AT_EOS;
seekAudioIfNecessary_l(); seekAudioIfNecessary_l();
if (!(mFlags & PLAYING)) {
LOGV("seeking while paused, sending SEEK_COMPLETE notification"
" immediately.");
notifyListener_l(MEDIA_SEEK_COMPLETE);
mSeekNotificationSent = true;
}
return OK; return OK;
} }
@@ -701,6 +711,7 @@ void AwesomePlayer::seekAudioIfNecessary_l() {
mWatchForAudioSeekComplete = true; mWatchForAudioSeekComplete = true;
mWatchForAudioEOS = true; mWatchForAudioEOS = true;
mSeeking = false; mSeeking = false;
mSeekNotificationSent = false;
} }
} }
@@ -869,7 +880,7 @@ void AwesomePlayer::onVideoEvent() {
mAudioPlayer->seekTo(timeUs); mAudioPlayer->seekTo(timeUs);
mWatchForAudioSeekComplete = true; mWatchForAudioSeekComplete = true;
mWatchForAudioEOS = true; mWatchForAudioEOS = true;
} else { } else if (!mSeekNotificationSent) {
// If we're playing video only, report seek complete now, // If we're playing video only, report seek complete now,
// otherwise audio player will notify us later. // otherwise audio player will notify us later.
notifyListener_l(MEDIA_SEEK_COMPLETE); notifyListener_l(MEDIA_SEEK_COMPLETE);
@@ -877,6 +888,7 @@ void AwesomePlayer::onVideoEvent() {
mFlags |= FIRST_FRAME; mFlags |= FIRST_FRAME;
mSeeking = false; mSeeking = false;
mSeekNotificationSent = false;
} }
if (mFlags & FIRST_FRAME) { if (mFlags & FIRST_FRAME) {
@@ -984,7 +996,11 @@ void AwesomePlayer::onCheckAudioStatus() {
if (mWatchForAudioSeekComplete && !mAudioPlayer->isSeeking()) { if (mWatchForAudioSeekComplete && !mAudioPlayer->isSeeking()) {
mWatchForAudioSeekComplete = false; mWatchForAudioSeekComplete = false;
notifyListener_l(MEDIA_SEEK_COMPLETE);
if (!mSeekNotificationSent) {
notifyListener_l(MEDIA_SEEK_COMPLETE);
mSeekNotificationSent = true;
}
} }
status_t finalStatus; status_t finalStatus;

View File

@@ -132,6 +132,7 @@ private:
int64_t mVideoTimeUs; int64_t mVideoTimeUs;
bool mSeeking; bool mSeeking;
bool mSeekNotificationSent;
int64_t mSeekTimeUs; int64_t mSeekTimeUs;
bool mWatchForAudioSeekComplete; bool mWatchForAudioSeekComplete;