diff options
author | Robert Shih <robertshih@google.com> | 2015-07-07 20:22:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-07 20:22:57 +0000 |
commit | 065f6572752dca646b7d60df8e80b6d4ac159281 (patch) | |
tree | 1209ff7475b3d1fa82fe4ebb19056cf37f9a5e45 | |
parent | 878b8f1a0128cf63617782e3073dffb212d0c8f1 (diff) | |
parent | 0c61a0d78f5f093f47826d770111cd455a19beb4 (diff) | |
download | frameworks_av-065f6572752dca646b7d60df8e80b6d4ac159281.zip frameworks_av-065f6572752dca646b7d60df8e80b6d4ac159281.tar.gz frameworks_av-065f6572752dca646b7d60df8e80b6d4ac159281.tar.bz2 |
Merge "NuPlayer: disable pre-start preview for audio only sources" into mnc-dev
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 30 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.h | 1 |
2 files changed, 22 insertions, 9 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index ef96a28..a9d8904 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -186,6 +186,7 @@ NuPlayer::NuPlayer() mPlaybackSettings(AUDIO_PLAYBACK_RATE_DEFAULT), mVideoFpsHint(-1.f), mStarted(false), + mSourceStarted(false), mPaused(false), mPausedByClient(false), mPausedForBuffering(false) { @@ -1010,6 +1011,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { // Widevine source reads must stop before releasing the video decoder. if (!audio && mSource != NULL && mSourceFlags & Source::FLAG_SECURE) { mSource->stop(); + mSourceStarted = false; } getDecoder(audio)->initiateShutdown(); // In the middle of a seek. *flushing = SHUTTING_DOWN_DECODER; // Shut down. @@ -1158,11 +1160,12 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { // need to start the player and pause it. This branch is called // only once if needed. After the player is started, any seek // operation will go through normal path. - // All cases, including audio-only, are handled in the same way - // for the sake of simplicity. + // Audio-only cases are handled separately. onStart(seekTimeUs); - onPause(); - mPausedByClient = true; + if (mStarted) { + onPause(); + mPausedByClient = true; + } if (needNotify) { notifyDriverSeekComplete(); } @@ -1263,16 +1266,22 @@ status_t NuPlayer::onInstantiateSecureDecoders() { } void NuPlayer::onStart(int64_t startPositionUs) { + if (!mSourceStarted) { + mSourceStarted = true; + mSource->start(); + } + if (startPositionUs > 0) { + performSeek(startPositionUs); + if (mSource->getFormat(false /* audio */) == NULL) { + return; + } + } + mOffloadAudio = false; mAudioEOS = false; mVideoEOS = false; mStarted = true; - mSource->start(); - if (startPositionUs > 0) { - performSeek(startPositionUs); - } - uint32_t flags = 0; if (mSource->isRealTime()) { @@ -1305,6 +1314,7 @@ void NuPlayer::onStart(int64_t startPositionUs) { status_t err = mRenderer->setPlaybackSettings(mPlaybackSettings); if (err != OK) { mSource->stop(); + mSourceStarted = false; notifyListener(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err); return; } @@ -1372,6 +1382,7 @@ void NuPlayer::handleFlushComplete(bool audio, bool isDecoder) { // Widevine source reads must stop before releasing the video decoder. if (mSource != NULL && mSourceFlags & Source::FLAG_SECURE) { mSource->stop(); + mSourceStarted = false; } } getDecoder(audio)->initiateShutdown(); @@ -1871,6 +1882,7 @@ void NuPlayer::performReset() { } mStarted = false; + mSourceStarted = false; } void NuPlayer::performScanSources() { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 298ea6d..38904bc 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -194,6 +194,7 @@ private: AVSyncSettings mSyncSettings; float mVideoFpsHint; bool mStarted; + bool mSourceStarted; // Actual pause state, either as requested by client or due to buffering. bool mPaused; |