Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 065f6572 authored by Robert Shih's avatar Robert Shih Committed by Android (Google) Code Review
Browse files

Merge "NuPlayer: disable pre-start preview for audio only sources" into mnc-dev

parents 878b8f1a 0c61a0d7
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -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);
                if (mStarted) {
                    onPause();
                    mPausedByClient = true;
                }
                if (needNotify) {
                    notifyDriverSeekComplete();
                }
@@ -1263,16 +1266,22 @@ status_t NuPlayer::onInstantiateSecureDecoders() {
}

void NuPlayer::onStart(int64_t startPositionUs) {
    mOffloadAudio = false;
    mAudioEOS = false;
    mVideoEOS = false;
    mStarted = true;

    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;

    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() {
+1 −0
Original line number Diff line number Diff line
@@ -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;