am dd28d563: Fix 2209967 Tonegenerator: mutex not release in startTone() upon timeout waiting for the stop sequence to complete.

Merge commit 'dd28d56368441537ec5eb42150516416fdbf10ad' into eclair-plus-aosp

* commit 'dd28d56368441537ec5eb42150516416fdbf10ad':
  Fix 2209967 Tonegenerator: mutex not release in startTone() upon timeout waiting for the stop sequence to complete.
This commit is contained in:
Eric Laurent
2009-10-23 08:26:35 -07:00
committed by Android Git Automerger

View File

@@ -903,10 +903,11 @@ bool ToneGenerator::startTone(int toneType, int durationMs) {
if (mState == TONE_STOPPED) {
LOGV("Start waiting for previous tone to stop");
lStatus = mWaitCbkCond.waitRelative(mLock, seconds(1));
lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
if (lStatus != NO_ERROR) {
LOGE("--- start wait for stop timed out, status %d", lStatus);
mState = TONE_IDLE;
mLock.unlock();
return lResult;
}
}
@@ -921,7 +922,7 @@ bool ToneGenerator::startTone(int toneType, int durationMs) {
mLock.lock();
if (mState == TONE_STARTING) {
LOGV("Wait for start callback");
lStatus = mWaitCbkCond.waitRelative(mLock, seconds(1));
lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
if (lStatus != NO_ERROR) {
LOGE("--- Immediate start timed out, status %d", lStatus);
mState = TONE_IDLE;
@@ -934,7 +935,7 @@ bool ToneGenerator::startTone(int toneType, int durationMs) {
} else {
LOGV("Delayed start\n");
mState = TONE_RESTARTING;
lStatus = mWaitCbkCond.waitRelative(mLock, seconds(1));
lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
if (lStatus == NO_ERROR) {
if (mState != TONE_IDLE) {
lResult = true;
@@ -973,7 +974,7 @@ void ToneGenerator::stopTone() {
if (mState == TONE_PLAYING || mState == TONE_STARTING || mState == TONE_RESTARTING) {
mState = TONE_STOPPING;
LOGV("waiting cond");
status_t lStatus = mWaitCbkCond.waitRelative(mLock, seconds(1));
status_t lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3));
if (lStatus == NO_ERROR) {
LOGV("track stop complete, time %d", (unsigned int)(systemTime()/1000000));
} else {
@@ -1087,6 +1088,7 @@ void ToneGenerator::audioCallback(int event, void* user, void *info) {
lpToneGen->mLock.lock();
// Update pcm frame count and end time (current time at the end of this process)
lpToneGen->mTotalSmp += lReqSmp;