diff options
author | Eric Laurent <elaurent@google.com> | 2013-03-28 00:24:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-03-28 00:24:50 +0000 |
commit | 2d595c0efc0eee9e0c94f4842c6fed07c19163c1 (patch) | |
tree | 1b67238f7567dd19a5c4bdd70825c2ebd2f884cc /media | |
parent | ad065d38daace14281801127bd447114b7b4daa5 (diff) | |
parent | 09108adeca8cbbf3fbb21f8aea2a2ff250db9531 (diff) | |
download | frameworks_av-2d595c0efc0eee9e0c94f4842c6fed07c19163c1.zip frameworks_av-2d595c0efc0eee9e0c94f4842c6fed07c19163c1.tar.gz frameworks_av-2d595c0efc0eee9e0c94f4842c6fed07c19163c1.tar.bz2 |
Merge "ToneGenerator: fix stop/destroy concurrency" into jb-mr2-dev
Diffstat (limited to 'media')
-rw-r--r-- | media/libmedia/ToneGenerator.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp index 58d495e..3554608 100644 --- a/media/libmedia/ToneGenerator.cpp +++ b/media/libmedia/ToneGenerator.cpp @@ -976,21 +976,26 @@ void ToneGenerator::stopTone() { ALOGV("stopTone"); mLock.lock(); - if (mState == TONE_PLAYING || mState == TONE_STARTING || mState == TONE_RESTARTING) { - mState = TONE_STOPPING; + if (mState != TONE_IDLE && mState != TONE_INIT) { + if (mState == TONE_PLAYING || mState == TONE_STARTING || mState == TONE_RESTARTING) { + mState = TONE_STOPPING; + } ALOGV("waiting cond"); status_t lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3)); if (lStatus == NO_ERROR) { + // If the tone was restarted exit now before calling clearWaveGens(); + if (mState != TONE_INIT) { + return; + } ALOGV("track stop complete, time %d", (unsigned int)(systemTime()/1000000)); } else { ALOGE("--- Stop timed out"); mState = TONE_IDLE; mpAudioTrack->stop(); } + clearWaveGens(); } - clearWaveGens(); - mLock.unlock(); } @@ -1299,7 +1304,7 @@ audioCallback_EndLoop: } if (lSignal) - lpToneGen->mWaitCbkCond.signal(); + lpToneGen->mWaitCbkCond.broadcast(); lpToneGen->mLock.unlock(); } } |