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

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

Merge "MediaPlayer2: remove stop and related enums"

parents 7f3fbbec 0151ef43
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -171,7 +171,6 @@ public:

    virtual status_t prepareAsync() = 0;
    virtual status_t start() = 0;
    virtual status_t stop() = 0;
    virtual status_t pause() = 0;
    virtual bool isPlaying() = 0;
    virtual status_t setPlaybackSettings(const AudioPlaybackRate& rate) {
+1 −2
Original line number Diff line number Diff line
@@ -168,8 +168,7 @@ enum media_player2_internal_states {
    MEDIA_PLAYER2_PREPARED           = 1 << 3,
    MEDIA_PLAYER2_STARTED            = 1 << 4,
    MEDIA_PLAYER2_PAUSED             = 1 << 5,
    MEDIA_PLAYER2_STOPPED            = 1 << 6,
    MEDIA_PLAYER2_PLAYBACK_COMPLETE  = 1 << 7
    MEDIA_PLAYER2_PLAYBACK_COMPLETE  = 1 << 6
};

// Keep KEY_PARAMETER_* in sync with MediaPlayer2.java.
+0 −1
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ public:
            status_t        setBufferingSettings(const BufferingSettings& buffering);
            status_t        prepareAsync();
            status_t        start();
            status_t        stop();
            status_t        pause();
            bool            isPlaying();
            mediaplayer2_states getState();
+4 −23
Original line number Diff line number Diff line
@@ -750,7 +750,7 @@ status_t MediaPlayer2::setAudioAttributes_l(const Parcel &parcel) {
status_t MediaPlayer2::prepareAsync() {
    ALOGV("prepareAsync");
    Mutex::Autolock _l(mLock);
    if ((mPlayer != 0) && (mCurrentState & (MEDIA_PLAYER2_INITIALIZED | MEDIA_PLAYER2_STOPPED))) {
    if ((mPlayer != 0) && (mCurrentState & MEDIA_PLAYER2_INITIALIZED)) {
        if (mAudioAttributesParcel != NULL) {
            status_t err = setAudioAttributes_l(*mAudioAttributesParcel);
            if (err != OK) {
@@ -806,24 +806,6 @@ status_t MediaPlayer2::start() {
    return ret;
}

status_t MediaPlayer2::stop() {
    ALOGV("stop");
    Mutex::Autolock _l(mLock);
    if (mCurrentState & MEDIA_PLAYER2_STOPPED) return NO_ERROR;
    if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER2_STARTED | MEDIA_PLAYER2_PREPARED |
                    MEDIA_PLAYER2_PAUSED | MEDIA_PLAYER2_PLAYBACK_COMPLETE ) ) ) {
        status_t ret = mPlayer->stop();
        if (ret != NO_ERROR) {
            mCurrentState = MEDIA_PLAYER2_STATE_ERROR;
        } else {
            mCurrentState = MEDIA_PLAYER2_STOPPED;
        }
        return ret;
    }
    ALOGE("stop called in state %d, mPlayer(%p)", mCurrentState, mPlayer.get());
    return INVALID_OPERATION;
}

status_t MediaPlayer2::pause() {
    ALOGV("pause");
    Mutex::Autolock _l(mLock);
@@ -873,8 +855,7 @@ mediaplayer2_states MediaPlayer2::getState() {
    if (mCurrentState & MEDIA_PLAYER2_STARTED) {
        return MEDIAPLAYER2_STATE_PLAYING;
    }
    if (mCurrentState
        & (MEDIA_PLAYER2_PAUSED | MEDIA_PLAYER2_STOPPED | MEDIA_PLAYER2_PLAYBACK_COMPLETE)) {
    if (mCurrentState & (MEDIA_PLAYER2_PAUSED | MEDIA_PLAYER2_PLAYBACK_COMPLETE)) {
        return MEDIAPLAYER2_STATE_PAUSED;
    }
    // now only mCurrentState & MEDIA_PLAYER2_PREPARED is true
@@ -890,7 +871,7 @@ status_t MediaPlayer2::setPlaybackSettings(const AudioPlaybackRate& rate) {
        return BAD_VALUE;
    }
    Mutex::Autolock _l(mLock);
    if (mPlayer == 0 || (mCurrentState & MEDIA_PLAYER2_STOPPED)) {
    if (mPlayer == 0) {
        return INVALID_OPERATION;
    }

@@ -982,7 +963,7 @@ status_t MediaPlayer2::getDuration(int64_t *msec) {
    Mutex::Autolock _l(mLock);
    ALOGV("getDuration_l");
    bool isValidState = (mCurrentState & (MEDIA_PLAYER2_PREPARED | MEDIA_PLAYER2_STARTED |
            MEDIA_PLAYER2_PAUSED | MEDIA_PLAYER2_STOPPED | MEDIA_PLAYER2_PLAYBACK_COMPLETE));
            MEDIA_PLAYER2_PAUSED | MEDIA_PLAYER2_PLAYBACK_COMPLETE));
    if (mPlayer == 0 || !isValidState) {
        ALOGE("Attempt to call getDuration in wrong state: mPlayer=%p, mCurrentState=%u",
                mPlayer.get(), mCurrentState);
+1 −59
Original line number Diff line number Diff line
@@ -272,13 +272,6 @@ status_t NuPlayer2Driver::prepareAsync() {
            mState = STATE_PREPARING;
            mPlayer->prepareAsync();
            return OK;
        case STATE_STOPPED:
            // this is really just paused. handle as seek to start
            mAtEOS = false;
            mState = STATE_STOPPED_AND_PREPARING;
            mPlayer->seekToAsync(0, MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC /* mode */,
                    true /* needNotify */);
            return OK;
        default:
            return INVALID_OPERATION;
    };
@@ -293,7 +286,6 @@ status_t NuPlayer2Driver::start() {
status_t NuPlayer2Driver::start_l() {
    switch (mState) {
        case STATE_PAUSED:
        case STATE_STOPPED_AND_PREPARED:
        case STATE_PREPARED:
        {
            mPlayer->start();
@@ -320,34 +312,6 @@ status_t NuPlayer2Driver::start_l() {
    return OK;
}

status_t NuPlayer2Driver::stop() {
    ALOGD("stop(%p)", this);
    Mutex::Autolock autoLock(mLock);

    switch (mState) {
        case STATE_RUNNING:
            mPlayer->pause();
            // fall through

        case STATE_PAUSED:
            mState = STATE_STOPPED;
            //notifyListener_l(MEDIA2_STOPPED);
            break;

        case STATE_PREPARED:
        case STATE_STOPPED:
        case STATE_STOPPED_AND_PREPARING:
        case STATE_STOPPED_AND_PREPARED:
            mState = STATE_STOPPED;
            break;

        default:
            return INVALID_OPERATION;
    }

    return OK;
}

status_t NuPlayer2Driver::pause() {
    ALOGD("pause(%p)", this);
    // The NuPlayerRenderer may get flushed if pause for long enough, e.g. the pause timeout tear
@@ -391,7 +355,6 @@ status_t NuPlayer2Driver::setPlaybackSettings(const AudioPlaybackRate &rate) {
            mState = STATE_PAUSED;
        } else if (rate.mSpeed != 0.f
                && (mState == STATE_PAUSED
                    || mState == STATE_STOPPED_AND_PREPARED
                    || mState == STATE_PREPARED)) {
            err = start_l();
        }
@@ -419,7 +382,6 @@ status_t NuPlayer2Driver::seekTo(int64_t msec, MediaPlayer2SeekMode mode) {

    switch (mState) {
        case STATE_PREPARED:
        case STATE_STOPPED_AND_PREPARED:
        case STATE_PAUSED:
        case STATE_RUNNING:
        {
@@ -601,10 +563,6 @@ status_t NuPlayer2Driver::reset() {
            break;
    }

    if (mState != STATE_STOPPED) {
        // notifyListener_l(MEDIA2_STOPPED);
    }

    mState = STATE_RESET_IN_PROGRESS;
    mPlayer->resetAsync();

@@ -780,20 +738,7 @@ void NuPlayer2Driver::notifySeekComplete(int64_t srcId) {
    ALOGV("notifySeekComplete(%p)", this);
    Mutex::Autolock autoLock(mLock);
    mSeekInProgress = false;
    notifySeekComplete_l(srcId);
}

void NuPlayer2Driver::notifySeekComplete_l(int64_t srcId) {
    bool wasSeeking = true;
    if (mState == STATE_STOPPED_AND_PREPARING) {
        wasSeeking = false;
        mState = STATE_STOPPED_AND_PREPARED;
        mCondition.broadcast();
    } else if (mState == STATE_STOPPED) {
        // no need to notify listener
        return;
    }
    notifyListener_l(srcId, wasSeeking ? MEDIA2_SEEK_COMPLETE : MEDIA2_PREPARED);
    notifyListener_l(srcId, MEDIA2_SEEK_COMPLETE);
}

status_t NuPlayer2Driver::dump(
@@ -1078,9 +1023,6 @@ std::string NuPlayer2Driver::stateString(State state) {
        case STATE_RUNNING: rval = "RUNNING"; break;
        case STATE_PAUSED: rval = "PAUSED"; break;
        case STATE_RESET_IN_PROGRESS: rval = "RESET_IN_PROGRESS"; break;
        case STATE_STOPPED: rval = "STOPPED"; break;
        case STATE_STOPPED_AND_PREPARING: rval = "STOPPED_AND_PREPARING"; break;
        case STATE_STOPPED_AND_PREPARED: rval = "STOPPED_AND_PREPARED"; break;
        default:
            // yes, this buffer is shared and vulnerable to races
            snprintf(rawbuffer, sizeof(rawbuffer), "%d", state);
Loading