Fix 2209967 Tonegenerator: mutex not release in startTone() upon timeout waiting for the stop sequence to complete.
Unlock mLock mutex when exiting upon wait stop timeout condition. Increase timeout delays to avoid timing out when A2DP exits standby.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user