diff options
author | Robert Shih <robertshih@google.com> | 2015-07-06 15:09:10 -0700 |
---|---|---|
committer | Robert Shih <robertshih@google.com> | 2015-07-07 11:43:04 -0700 |
commit | 0c61a0d78f5f093f47826d770111cd455a19beb4 (patch) | |
tree | 11a2d98615eba4558295754012b0f94e8f0462d9 /media/libmediaplayerservice/nuplayer | |
parent | 29b7cec9a248828d2371bc8758d819308d0e84a4 (diff) | |
download | frameworks_av-0c61a0d78f5f093f47826d770111cd455a19beb4.zip frameworks_av-0c61a0d78f5f093f47826d770111cd455a19beb4.tar.gz frameworks_av-0c61a0d78f5f093f47826d770111cd455a19beb4.tar.bz2 |
NuPlayer: disable pre-start preview for audio only sources
Bug: 22117876
Change-Id: I0e00ff8f081d80946cbd19028f1f786c1b8268f3
Diffstat (limited to 'media/libmediaplayerservice/nuplayer')
-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; |