Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ffe7689 authored by Eric Laurent's avatar Eric Laurent Committed by Android Git Automerger
Browse files

am 2d595c0e: Merge "ToneGenerator: fix stop/destroy concurrency" into jb-mr2-dev

* commit '2d595c0e':
  ToneGenerator: fix stop/destroy concurrency
parents 2ec46421 2d595c0e
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -976,20 +976,25 @@ void ToneGenerator::stopTone() {
    ALOGV("stopTone");

    mLock.lock();
    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();
    }

    mLock.unlock();
}
@@ -1299,7 +1304,7 @@ audioCallback_EndLoop:
        }

        if (lSignal)
            lpToneGen->mWaitCbkCond.signal();
            lpToneGen->mWaitCbkCond.broadcast();
        lpToneGen->mLock.unlock();
    }
}