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

Commit a4f7e0e9 authored by Eric Laurent's avatar Eric Laurent
Browse files

audioflinger: fix duplicating thread standby

The code that waits for a track presentation to be complete
before disabling it caused a regression for duplicating threads.
Because of the way output tracks activity is managed, the number
of frames output by the duplicating thread would never
reach the target set for a track to be considered presented.
The track would not be removed from active list and the thread would
not go to standby and keep its wakelock held.

Bug 6606922.

Change-Id: I4b46b420ac4cbf79a86b6791ae6589d407b01c92
parent e35a55fb
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -3891,6 +3891,7 @@ void AudioFlinger::DuplicatingThread::threadLoop_mix()
    }
    sleepTime = 0;
    writeFrames = mNormalFrameCount;
    standbyTime = systemTime() + standbyDelay;
}

void AudioFlinger::DuplicatingThread::threadLoop_sleepTime()
@@ -3902,21 +3903,19 @@ void AudioFlinger::DuplicatingThread::threadLoop_sleepTime()
            sleepTime = idleSleepTime;
        }
    } else if (mBytesWritten != 0) {
        if (mMixerStatus == MIXER_TRACKS_ENABLED) {
            writeFrames = mNormalFrameCount;
            memset(mMixBuffer, 0, mixBufferSize);
        } else {
            // flush remaining overflow buffers in output tracks
        for (size_t i = 0; i < outputTracks.size(); i++) {
            if (outputTracks[i]->isActive()) {
                sleepTime = 0;
            writeFrames = 0;
                memset(mMixBuffer, 0, mixBufferSize);
                break;
            }
        }
        sleepTime = 0;
    }
}

void AudioFlinger::DuplicatingThread::threadLoop_write()
{
    standbyTime = systemTime() + standbyDelay;
    for (size_t i = 0; i < outputTracks.size(); i++) {
        outputTracks[i]->write(mMixBuffer, writeFrames);
    }