Loading media/libmedia/mediaplayer.cpp +18 −9 Original line number Original line Diff line number Diff line Loading @@ -283,16 +283,21 @@ status_t MediaPlayer::prepareAsync() status_t MediaPlayer::start() status_t MediaPlayer::start() { { ALOGV("start"); ALOGV("start"); status_t ret = NO_ERROR; Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); if (mCurrentState & MEDIA_PLAYER_STARTED) return NO_ERROR; mLockThreadId = getThreadId(); if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_PREPARED | if (mCurrentState & MEDIA_PLAYER_STARTED) { ret = NO_ERROR; } else if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_PLAYBACK_COMPLETE | MEDIA_PLAYER_PAUSED ) ) ) { MEDIA_PLAYER_PLAYBACK_COMPLETE | MEDIA_PLAYER_PAUSED ) ) ) { mPlayer->setLooping(mLoop); mPlayer->setLooping(mLoop); mPlayer->setVolume(mLeftVolume, mRightVolume); mPlayer->setVolume(mLeftVolume, mRightVolume); mPlayer->setAuxEffectSendLevel(mSendLevel); mPlayer->setAuxEffectSendLevel(mSendLevel); mCurrentState = MEDIA_PLAYER_STARTED; mCurrentState = MEDIA_PLAYER_STARTED; status_t ret = mPlayer->start(); ret = mPlayer->start(); if (ret != NO_ERROR) { if (ret != NO_ERROR) { mCurrentState = MEDIA_PLAYER_STATE_ERROR; mCurrentState = MEDIA_PLAYER_STATE_ERROR; } else { } else { Loading @@ -300,10 +305,14 @@ status_t MediaPlayer::start() ALOGV("playback completed immediately following start()"); ALOGV("playback completed immediately following start()"); } } } } return ret; } else { } ALOGE("start called in state %d", mCurrentState); ALOGE("start called in state %d", mCurrentState); return INVALID_OPERATION; ret = INVALID_OPERATION; } mLockThreadId = 0; return ret; } } status_t MediaPlayer::stop() status_t MediaPlayer::stop() Loading Loading @@ -706,8 +715,8 @@ void MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj) // running in the same process as the media server. In that case, // running in the same process as the media server. In that case, // this will deadlock. // this will deadlock. // // // The threadId hack below works around this for the care of prepare // The threadId hack below works around this for the care of prepare, // and seekTo within the same process. // seekTo and start within the same process. // FIXME: Remember, this is a hack, it's not even a hack that is applied // FIXME: Remember, this is a hack, it's not even a hack that is applied // consistently for all use-cases, this needs to be revisited. // consistently for all use-cases, this needs to be revisited. if (mLockThreadId != getThreadId()) { if (mLockThreadId != getThreadId()) { Loading Loading
media/libmedia/mediaplayer.cpp +18 −9 Original line number Original line Diff line number Diff line Loading @@ -283,16 +283,21 @@ status_t MediaPlayer::prepareAsync() status_t MediaPlayer::start() status_t MediaPlayer::start() { { ALOGV("start"); ALOGV("start"); status_t ret = NO_ERROR; Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); if (mCurrentState & MEDIA_PLAYER_STARTED) return NO_ERROR; mLockThreadId = getThreadId(); if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_PREPARED | if (mCurrentState & MEDIA_PLAYER_STARTED) { ret = NO_ERROR; } else if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_PLAYBACK_COMPLETE | MEDIA_PLAYER_PAUSED ) ) ) { MEDIA_PLAYER_PLAYBACK_COMPLETE | MEDIA_PLAYER_PAUSED ) ) ) { mPlayer->setLooping(mLoop); mPlayer->setLooping(mLoop); mPlayer->setVolume(mLeftVolume, mRightVolume); mPlayer->setVolume(mLeftVolume, mRightVolume); mPlayer->setAuxEffectSendLevel(mSendLevel); mPlayer->setAuxEffectSendLevel(mSendLevel); mCurrentState = MEDIA_PLAYER_STARTED; mCurrentState = MEDIA_PLAYER_STARTED; status_t ret = mPlayer->start(); ret = mPlayer->start(); if (ret != NO_ERROR) { if (ret != NO_ERROR) { mCurrentState = MEDIA_PLAYER_STATE_ERROR; mCurrentState = MEDIA_PLAYER_STATE_ERROR; } else { } else { Loading @@ -300,10 +305,14 @@ status_t MediaPlayer::start() ALOGV("playback completed immediately following start()"); ALOGV("playback completed immediately following start()"); } } } } return ret; } else { } ALOGE("start called in state %d", mCurrentState); ALOGE("start called in state %d", mCurrentState); return INVALID_OPERATION; ret = INVALID_OPERATION; } mLockThreadId = 0; return ret; } } status_t MediaPlayer::stop() status_t MediaPlayer::stop() Loading Loading @@ -706,8 +715,8 @@ void MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj) // running in the same process as the media server. In that case, // running in the same process as the media server. In that case, // this will deadlock. // this will deadlock. // // // The threadId hack below works around this for the care of prepare // The threadId hack below works around this for the care of prepare, // and seekTo within the same process. // seekTo and start within the same process. // FIXME: Remember, this is a hack, it's not even a hack that is applied // FIXME: Remember, this is a hack, it's not even a hack that is applied // consistently for all use-cases, this needs to be revisited. // consistently for all use-cases, this needs to be revisited. if (mLockThreadId != getThreadId()) { if (mLockThreadId != getThreadId()) { Loading