From 0c61a0d78f5f093f47826d770111cd455a19beb4 Mon Sep 17 00:00:00 2001 From: Robert Shih Date: Mon, 6 Jul 2015 15:09:10 -0700 Subject: NuPlayer: disable pre-start preview for audio only sources Bug: 22117876 Change-Id: I0e00ff8f081d80946cbd19028f1f786c1b8268f3 --- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 30 ++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'media/libmediaplayerservice/nuplayer/NuPlayer.cpp') 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 &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 &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() { -- cgit v1.1