summaryrefslogtreecommitdiffstats
path: root/media/libmedia/mediaplayer.cpp
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2014-07-23 11:43:46 -0700
committerChong Zhang <chz@google.com>2014-07-23 12:00:22 -0700
commitd88adb96ec867ed1b629c434f87514d2fabaf5e9 (patch)
tree96229ead860a21012650d71df5e4cf120f092da2 /media/libmedia/mediaplayer.cpp
parent225d5b20409fd400bfa4ed5e9bc1d5babb498471 (diff)
downloadframeworks_av-d88adb96ec867ed1b629c434f87514d2fabaf5e9.zip
frameworks_av-d88adb96ec867ed1b629c434f87514d2fabaf5e9.tar.gz
frameworks_av-d88adb96ec867ed1b629c434f87514d2fabaf5e9.tar.bz2
NuPlayer: save thread id in MediaPlayer::start
so that when MediaPlayer::notify is called from within start, it doesn't try to lock itself again. Bug: 15323063 Change-Id: Idd77e892cd22538bbfe3e65c64c9dd2a216a0aee
Diffstat (limited to 'media/libmedia/mediaplayer.cpp')
-rw-r--r--media/libmedia/mediaplayer.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index 889bd7f..2b7ea97 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -283,16 +283,21 @@ status_t MediaPlayer::prepareAsync()
status_t MediaPlayer::start()
{
ALOGV("start");
+
+ status_t ret = NO_ERROR;
Mutex::Autolock _l(mLock);
- if (mCurrentState & MEDIA_PLAYER_STARTED)
- return NO_ERROR;
- if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_PREPARED |
+
+ mLockThreadId = getThreadId();
+
+ if (mCurrentState & MEDIA_PLAYER_STARTED) {
+ ret = NO_ERROR;
+ } else if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_PREPARED |
MEDIA_PLAYER_PLAYBACK_COMPLETE | MEDIA_PLAYER_PAUSED ) ) ) {
mPlayer->setLooping(mLoop);
mPlayer->setVolume(mLeftVolume, mRightVolume);
mPlayer->setAuxEffectSendLevel(mSendLevel);
mCurrentState = MEDIA_PLAYER_STARTED;
- status_t ret = mPlayer->start();
+ ret = mPlayer->start();
if (ret != NO_ERROR) {
mCurrentState = MEDIA_PLAYER_STATE_ERROR;
} else {
@@ -300,10 +305,14 @@ status_t MediaPlayer::start()
ALOGV("playback completed immediately following start()");
}
}
- return ret;
+ } else {
+ ALOGE("start called in state %d", mCurrentState);
+ ret = INVALID_OPERATION;
}
- ALOGE("start called in state %d", mCurrentState);
- return INVALID_OPERATION;
+
+ mLockThreadId = 0;
+
+ return ret;
}
status_t MediaPlayer::stop()
@@ -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,
// this will deadlock.
//
- // The threadId hack below works around this for the care of prepare
- // and seekTo within the same process.
+ // The threadId hack below works around this for the care of prepare,
+ // seekTo and start within the same process.
// 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.
if (mLockThreadId != getThreadId()) {