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

Commit a9e84bc8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "MediaPlayer2: allow prepared->pause"

parents 31496f67 6376cd57
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -154,8 +154,8 @@ enum media2_info_type {
enum mediaplayer2_states {
    MEDIAPLAYER2_STATE_IDLE         = 1001,
    MEDIAPLAYER2_STATE_PREPARED     = 1002,
    MEDIAPLAYER2_STATE_PLAYING      = 1003,
    MEDIAPLAYER2_STATE_PAUSED       = 1004,
    MEDIAPLAYER2_STATE_PAUSED       = 1003,
    MEDIAPLAYER2_STATE_PLAYING      = 1004,
    MEDIAPLAYER2_STATE_ERROR        = 1005,
};

+1 −1
Original line number Diff line number Diff line
@@ -660,7 +660,7 @@ status_t MediaPlayer2::pause() {
    Mutex::Autolock _l(mLock);
    if (mCurrentState & (MEDIA_PLAYER2_PAUSED|MEDIA_PLAYER2_PLAYBACK_COMPLETE))
        return NO_ERROR;
    if ((mPlayer != 0) && (mCurrentState & MEDIA_PLAYER2_STARTED)) {
    if ((mPlayer != 0) && (mCurrentState & (MEDIA_PLAYER2_STARTED | MEDIA_PLAYER2_PREPARED))) {
        status_t ret = mPlayer->pause();
        if (ret != NO_ERROR) {
            mCurrentState = MEDIA_PLAYER2_STATE_ERROR;
+11 −3
Original line number Diff line number Diff line
@@ -969,7 +969,7 @@ void NuPlayer2::onMessageReceived(const sp<AMessage> &msg) {
                    onResume();
                }
            } else {
                onStart();
                onStart(true /* play */);
            }
            mPausedByClient = false;
            notifyListener(mSrcId, MEDIA2_STARTED, 0, 0);
@@ -1502,6 +1502,9 @@ void NuPlayer2::onMessageReceived(const sp<AMessage> &msg) {

        case kWhatPause:
        {
            if (!mStarted) {
                onStart(false /* play */);
            }
            onPause();
            notifyListener(mSrcId, MEDIA2_PAUSED, 0, 0);
            mPausedByClient = true;
@@ -1575,7 +1578,7 @@ void NuPlayer2::onResume() {
    startPlaybackTimer("onresume");
}

void NuPlayer2::onStart() {
void NuPlayer2::onStart(bool play) {
    ALOGV("onStart: mCrypto: %p", mCrypto.get());

    if (!mSourceStarted) {
@@ -1649,6 +1652,11 @@ void NuPlayer2::onStart() {
        mRenderer->setVideoFrameRate(rate);
    }

    // Renderer is created in paused state.
    if (play) {
        mRenderer->resume();
    }

    if (mVideoDecoder != NULL) {
        mVideoDecoder->setRenderer(mRenderer);
    }
@@ -2472,7 +2480,7 @@ void NuPlayer2::performPlayNextDataSource() {
        mRenderer->resume();
    }

    onStart();
    onStart(true /* play */);
    mPausedByClient = false;
    notifyListener(mSrcId, MEDIA2_STARTED, 0, 0);
}
+1 −1
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ private:
    void handleFlushComplete(bool audio, bool isDecoder);
    void finishFlushIfPossible();

    void onStart();
    void onStart(bool play);
    void onResume();
    void onPause();

+1 −1
Original line number Diff line number Diff line
@@ -327,9 +327,9 @@ status_t NuPlayer2Driver::pause() {

    switch (mState) {
        case STATE_PAUSED:
        case STATE_PREPARED:
            return OK;

        case STATE_PREPARED:
        case STATE_RUNNING:
            mState = STATE_PAUSED;
            mPlayer->pause();
Loading