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

Commit 925a349b authored by The Android Open Source Project's avatar The Android Open Source Project
Browse files

auto import from //branches/cupcake/...@132569

parent 25658fd4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
    uint32_t u = cblk->user;
    uint32_t bufferEnd = cblk->userBase + cblk->frameCount;

    if (u + framesReady > bufferEnd) {
    if (u + framesReq > bufferEnd) {
        framesReq = bufferEnd - u;
    }

+12 −7
Original line number Diff line number Diff line
@@ -175,27 +175,28 @@ bool ToneGenerator::startTone(int toneType) {
    if (mState == TONE_INIT) {
        if (prepareWave()) {
            LOGV("Immediate start, time %d\n", (unsigned int)(systemTime()/1000000));

            lResult = true;
            mState = TONE_STARTING;
            mLock.unlock();
            mpAudioTrack->start();
            mLock.lock();
            if (mState == TONE_STARTING) {
                LOGV("Wait for start callback");
                if (mWaitCbkCond.waitRelative(mLock, seconds(1)) != NO_ERROR) {
                    LOGE("--- Immediate start timed out");
                    mState = TONE_IDLE;
                    lResult = false;
                }
            }

            if (mState == TONE_PLAYING)
                lResult = true;
        } else {
            mState == TONE_IDLE;
        }
    } else {
        LOGV("Delayed start\n");

        mState = TONE_RESTARTING;
        if (mWaitCbkCond.waitRelative(mLock, seconds(1)) == NO_ERROR) {
            if (mState != TONE_INIT) {
            if (mState != TONE_IDLE) {
                lResult = true;
            }
            LOGV("cond received");
@@ -206,7 +207,8 @@ bool ToneGenerator::startTone(int toneType) {
    }
    mLock.unlock();

    LOGV("Tone started, time %d\n", (unsigned int)(systemTime()/1000000));
    LOGV_IF(lResult, "Tone started, time %d\n", (unsigned int)(systemTime()/1000000));
    LOGW_IF(!lResult, "Tone start failed!!!, time %d\n", (unsigned int)(systemTime()/1000000));

    return lResult;
}
@@ -457,8 +459,11 @@ audioCallback_EndLoop:
            if (lpToneGen->prepareWave()) {
                lpToneGen->mState = TONE_STARTING;
            } else {
                lpToneGen->mState = TONE_INIT;
                LOGW("Cbk restarting prepareWave() failed\n");
                lpToneGen->mState = TONE_IDLE;
                lpToneGen->mpAudioTrack->stop();
                // Force loop exit
                lNumSmp = 0;
            }
            lSignal = true;
            break;