NuPlayer: disable pre-start preview for audio only sources
Bug: 22117876
Change-Id: I0e00ff8f081d80946cbd19028f1f786c1b8268f3
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 @@
mPlaybackSettings(AUDIO_PLAYBACK_RATE_DEFAULT),
mVideoFpsHint(-1.f),
mStarted(false),
+ mSourceStarted(false),
mPaused(false),
mPausedByClient(false),
mPausedForBuffering(false) {
@@ -1010,6 +1011,7 @@
// 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 @@
// 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 @@
}
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 @@
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 @@
// 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 @@
}
mStarted = false;
+ mSourceStarted = false;
}
void NuPlayer::performScanSources() {