Loading media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Interface.h +0 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Types.h +1 −2 Original line number Diff line number Diff line Loading @@ -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. Loading media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h +0 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading media/libmediaplayer2/mediaplayer2.cpp +4 −23 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); Loading Loading @@ -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 Loading @@ -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; } Loading Loading @@ -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); Loading media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp +1 −59 Original line number Diff line number Diff line Loading @@ -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; }; Loading @@ -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(); Loading @@ -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 Loading Loading @@ -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(); } Loading Loading @@ -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: { Loading Loading @@ -601,10 +563,6 @@ status_t NuPlayer2Driver::reset() { break; } if (mState != STATE_STOPPED) { // notifyListener_l(MEDIA2_STOPPED); } mState = STATE_RESET_IN_PROGRESS; mPlayer->resetAsync(); Loading Loading @@ -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( Loading Loading @@ -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 Loading
media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Interface.h +0 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading
media/libmediaplayer2/include/mediaplayer2/MediaPlayer2Types.h +1 −2 Original line number Diff line number Diff line Loading @@ -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. Loading
media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h +0 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading
media/libmediaplayer2/mediaplayer2.cpp +4 −23 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); Loading Loading @@ -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 Loading @@ -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; } Loading Loading @@ -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); Loading
media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp +1 −59 Original line number Diff line number Diff line Loading @@ -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; }; Loading @@ -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(); Loading @@ -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 Loading Loading @@ -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(); } Loading Loading @@ -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: { Loading Loading @@ -601,10 +563,6 @@ status_t NuPlayer2Driver::reset() { break; } if (mState != STATE_STOPPED) { // notifyListener_l(MEDIA2_STOPPED); } mState = STATE_RESET_IN_PROGRESS; mPlayer->resetAsync(); Loading Loading @@ -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( Loading Loading @@ -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