Properly honour any pending seek request when reading the first buffer after
starting the audio player. Change-Id: Ibedc1804a8c444e4d0f5be4eb87b22ed5d2c367d
This commit is contained in:
@@ -84,7 +84,13 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
|
||||
|
||||
CHECK(mFirstBuffer == NULL);
|
||||
|
||||
mFirstBufferResult = mSource->read(&mFirstBuffer);
|
||||
MediaSource::ReadOptions options;
|
||||
if (mSeeking) {
|
||||
options.setSeekTo(mSeekTimeUs);
|
||||
mSeeking = false;
|
||||
}
|
||||
|
||||
mFirstBufferResult = mSource->read(&mFirstBuffer, &options);
|
||||
if (mFirstBufferResult == INFO_FORMAT_CHANGED) {
|
||||
LOGV("INFO_FORMAT_CHANGED!!!");
|
||||
|
||||
|
||||
@@ -831,6 +831,8 @@ status_t AwesomePlayer::startAudioPlayer_l() {
|
||||
if (!(mFlags & AUDIOPLAYER_STARTED)) {
|
||||
mFlags |= AUDIOPLAYER_STARTED;
|
||||
|
||||
bool wasSeeking = mAudioPlayer->isSeeking();
|
||||
|
||||
// We've already started the MediaSource in order to enable
|
||||
// the prefetcher to read its data.
|
||||
status_t err = mAudioPlayer->start(
|
||||
@@ -840,6 +842,13 @@ status_t AwesomePlayer::startAudioPlayer_l() {
|
||||
notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (wasSeeking) {
|
||||
CHECK(!mAudioPlayer->isSeeking());
|
||||
|
||||
// We will have finished the seek while starting the audio player.
|
||||
postAudioSeekComplete_l();
|
||||
}
|
||||
} else {
|
||||
mAudioPlayer->resume();
|
||||
}
|
||||
@@ -1957,6 +1966,10 @@ void AwesomePlayer::postAudioEOS(int64_t delayUs) {
|
||||
|
||||
void AwesomePlayer::postAudioSeekComplete() {
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
postAudioSeekComplete_l();
|
||||
}
|
||||
|
||||
void AwesomePlayer::postAudioSeekComplete_l() {
|
||||
postCheckAudioStatusEvent_l(0 /* delayUs */);
|
||||
}
|
||||
|
||||
|
||||
@@ -281,6 +281,7 @@ private:
|
||||
void ensureCacheIsFetching_l();
|
||||
|
||||
status_t startAudioPlayer_l();
|
||||
void postAudioSeekComplete_l();
|
||||
|
||||
void shutdownVideoDecoder_l();
|
||||
void setNativeWindow_l(const sp<ANativeWindow> &native);
|
||||
|
||||
Reference in New Issue
Block a user