diff options
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 36 | ||||
-rw-r--r-- | media/libstagefright/include/AwesomePlayer.h | 2 |
2 files changed, 21 insertions, 17 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 5fbee7e..bcf9cd3 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -259,6 +259,7 @@ void AwesomePlayer::cancelPlayerEvents(bool keepNotifications) { mQueue.cancelEvent(mBufferingEvent->eventID()); mBufferingEventPending = false; + mAudioTearDown = false; } } @@ -2301,6 +2302,7 @@ void AwesomePlayer::abortPrepare(status_t err) { modifyFlags((PREPARING|PREPARE_CANCELLED|PREPARING_CONNECTED), CLEAR); mAsyncPrepareEvent = NULL; mPreparedCondition.broadcast(); + mAudioTearDown = false; } // static @@ -2374,6 +2376,20 @@ void AwesomePlayer::finishAsyncPrepare_l() { modifyFlags(PREPARED, SET); mAsyncPrepareEvent = NULL; mPreparedCondition.broadcast(); + + if (mAudioTearDown) { + if (mPrepareResult == OK) { + if (mExtractorFlags & MediaExtractor::CAN_SEEK) { + seekTo_l(mAudioTearDownPosition); + } + + if (mAudioTearDownWasPlaying) { + modifyFlags(CACHE_UNDERRUN, CLEAR); + play_l(); + } + } + mAudioTearDown = false; + } } uint32_t AwesomePlayer::flags() const { @@ -2791,7 +2807,7 @@ void AwesomePlayer::onAudioTearDownEvent() { ALOGV("onAudioTearDownEvent"); // stream info is cleared by reset_l() so copy what we need - const bool wasPlaying = (mFlags & PLAYING); + mAudioTearDownWasPlaying = (mFlags & PLAYING); KeyedVector<String8, String8> uriHeaders(mUriHeaders); sp<DataSource> fileSource(mFileSource); @@ -2800,8 +2816,7 @@ void AwesomePlayer::onAudioTearDownEvent() { mStatsLock.unlock(); // get current position so we can start recreated stream from here - int64_t position = 0; - getPosition(&position); + getPosition(&mAudioTearDownPosition); // Reset and recreate reset_l(); @@ -2825,21 +2840,8 @@ void AwesomePlayer::onAudioTearDownEvent() { mAudioTearDown = true; mIsAsyncPrepare = true; - // Call parepare for the host decoding + // Call prepare for the host decoding beginPrepareAsync_l(); - - if (mPrepareResult == OK) { - if (mExtractorFlags & MediaExtractor::CAN_SEEK) { - seekTo_l(position); - } - - if (wasPlaying) { - modifyFlags(CACHE_UNDERRUN, CLEAR); - play_l(); - } - } - - mAudioTearDown = false; } } // namespace android diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index b001cf4..271df8e 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -342,6 +342,8 @@ private: bool mOffloadAudio; bool mAudioTearDown; + bool mAudioTearDownWasPlaying; + int64_t mAudioTearDownPosition; status_t setVideoScalingMode(int32_t mode); status_t setVideoScalingMode_l(int32_t mode); |