Merge "If we encounter video stream EOS while seeking we may still need to seek audio." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
52bea277ff
@@ -1059,6 +1059,32 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
|
|||||||
return mVideoSource != NULL ? OK : UNKNOWN_ERROR;
|
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() {
|
void AwesomePlayer::onVideoEvent() {
|
||||||
Mutex::Autolock autoLock(mLock);
|
Mutex::Autolock autoLock(mLock);
|
||||||
if (!mVideoEventPending) {
|
if (!mVideoEventPending) {
|
||||||
@@ -1120,6 +1146,14 @@ void AwesomePlayer::onVideoEvent() {
|
|||||||
continue;
|
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;
|
mFlags |= VIDEO_AT_EOS;
|
||||||
postStreamDoneEvent_l(err);
|
postStreamDoneEvent_l(err);
|
||||||
return;
|
return;
|
||||||
@@ -1146,24 +1180,7 @@ void AwesomePlayer::onVideoEvent() {
|
|||||||
mVideoTimeUs = timeUs;
|
mVideoTimeUs = timeUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSeeking) {
|
finishSeekIfNecessary(timeUs);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeSource *ts = (mFlags & AUDIO_AT_EOS) ? &mSystemTimeSource : mTimeSource;
|
TimeSource *ts = (mFlags & AUDIO_AT_EOS) ? &mSystemTimeSource : mTimeSource;
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,8 @@ private:
|
|||||||
|
|
||||||
bool getBitrate(int64_t *bitrate);
|
bool getBitrate(int64_t *bitrate);
|
||||||
|
|
||||||
|
void finishSeekIfNecessary(int64_t videoTimeUs);
|
||||||
|
|
||||||
AwesomePlayer(const AwesomePlayer &);
|
AwesomePlayer(const AwesomePlayer &);
|
||||||
AwesomePlayer &operator=(const AwesomePlayer &);
|
AwesomePlayer &operator=(const AwesomePlayer &);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user