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

Commit d7fdb3b5 authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

Merge \"AudioFlinger: fix capture stop sequence\" into nyc-mr1-dev

am: a5bcf566

Change-Id: I17cde8f3113d5371e24ce1d4adafa2413752b0e3
parents 9912625f a5bcf566
Loading
Loading
Loading
Loading
+19 −8
Original line number Original line Diff line number Diff line
@@ -6014,14 +6014,6 @@ reacquire_wakelock:
    for (;;) {
    for (;;) {
        Vector< sp<EffectChain> > effectChains;
        Vector< sp<EffectChain> > effectChains;


        // sleep with mutex unlocked
        if (sleepUs > 0) {
            ATRACE_BEGIN("sleep");
            usleep(sleepUs);
            ATRACE_END();
            sleepUs = 0;
        }

        // activeTracks accumulates a copy of a subset of mActiveTracks
        // activeTracks accumulates a copy of a subset of mActiveTracks
        Vector< sp<RecordTrack> > activeTracks;
        Vector< sp<RecordTrack> > activeTracks;


@@ -6042,6 +6034,15 @@ reacquire_wakelock:
                break;
                break;
            }
            }


            // sleep with mutex unlocked
            if (sleepUs > 0) {
                ATRACE_BEGIN("sleep");
                mWaitWorkCV.waitRelative(mLock, microseconds((nsecs_t)sleepUs));
                ATRACE_END();
                sleepUs = 0;
                continue;
            }

            // if no active track(s), then standby and release wakelock
            // if no active track(s), then standby and release wakelock
            size_t size = mActiveTracks.size();
            size_t size = mActiveTracks.size();
            if (size == 0) {
            if (size == 0) {
@@ -6065,6 +6066,7 @@ reacquire_wakelock:
            }
            }


            bool doBroadcast = false;
            bool doBroadcast = false;
            bool allStopped = true;
            for (size_t i = 0; i < size; ) {
            for (size_t i = 0; i < size; ) {


                activeTrack = mActiveTracks[i];
                activeTrack = mActiveTracks[i];
@@ -6093,15 +6095,18 @@ reacquire_wakelock:
                case TrackBase::STARTING_1:
                case TrackBase::STARTING_1:
                    sleepUs = 10000;
                    sleepUs = 10000;
                    i++;
                    i++;
                    allStopped = false;
                    continue;
                    continue;


                case TrackBase::STARTING_2:
                case TrackBase::STARTING_2:
                    doBroadcast = true;
                    doBroadcast = true;
                    mStandby = false;
                    mStandby = false;
                    activeTrack->mState = TrackBase::ACTIVE;
                    activeTrack->mState = TrackBase::ACTIVE;
                    allStopped = false;
                    break;
                    break;


                case TrackBase::ACTIVE:
                case TrackBase::ACTIVE:
                    allStopped = false;
                    break;
                    break;


                case TrackBase::IDLE:
                case TrackBase::IDLE:
@@ -6121,6 +6126,10 @@ reacquire_wakelock:
                    fastTrack = activeTrack;
                    fastTrack = activeTrack;
                }
                }
            }
            }

            if (allStopped) {
                standbyIfNotAlreadyInStandby();
            }
            if (doBroadcast) {
            if (doBroadcast) {
                mStartStopCond.broadcast();
                mStartStopCond.broadcast();
            }
            }
@@ -6703,6 +6712,8 @@ bool AudioFlinger::RecordThread::stop(RecordThread::RecordTrack* recordTrack) {
    }
    }
    // note that threadLoop may still be processing the track at this point [without lock]
    // note that threadLoop may still be processing the track at this point [without lock]
    recordTrack->mState = TrackBase::PAUSING;
    recordTrack->mState = TrackBase::PAUSING;
    // signal thread to stop
    mWaitWorkCV.broadcast();
    // do not wait for mStartStopCond if exiting
    // do not wait for mStartStopCond if exiting
    if (exitPending()) {
    if (exitPending()) {
        return true;
        return true;