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

Commit c241a242 authored by Deva Ramasubramanian's avatar Deva Ramasubramanian Committed by Steve Kondik
Browse files

mediaplayer: Switch to PAUSE state on suspend and STARTED on resume

- After repeated suspend/resume, the pause button will no longer work
  due to state mismatch in mediaplayer.
- Issue is caused due to a race condition between isPlaying() and
  AwesomePlayer resume.  If isPlaying() is called before Awesomeplayer
  is ready, mediaplayer goes into a dead end Pause state.  It is not
  possible to come out of this state unless we pause.  But we
  can't pause because mediaplayer thinks that it is already paused.
- This fix attempts to prevent the mismatch by changing the state to
  PAUSE on suspend and STARTED on resume.

Change-Id: I24ac964efc0cd70d79cafc870ceb2422473b5555
CRs-fixed: 260443, 260600
parent bc56f933
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -177,12 +177,16 @@ status_t MediaPlayer::invoke(const Parcel& request, Parcel *reply)

status_t MediaPlayer::suspend() {
    Mutex::Autolock _l(mLock);
    return mPlayer->suspend();
    status_t rv = mPlayer->suspend();
    mCurrentState = (rv == OK ? MEDIA_PLAYER_PAUSED : MEDIA_PLAYER_STATE_ERROR);
    return rv;
}

status_t MediaPlayer::resume() {
    Mutex::Autolock _l(mLock);
    return mPlayer->resume();
    status_t rv = mPlayer->resume();
    mCurrentState = (rv == OK ? MEDIA_PLAYER_STARTED : MEDIA_PLAYER_STATE_ERROR);
    return rv;
}

status_t MediaPlayer::setMetadataFilter(const Parcel& filter)