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

Commit 83faee05 authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioFlinger: fix stop detection for static tracks

The end of playback and end of presentation detection was broken for
static AudioTracks (tracks using shared memory buffers passed by client).

The mixer should not wait for a minimal amount of frames to be available to mix
a static track otherwise the last frames might never be consumed.

A static track should be removed from active list in case of underrun even if not
stopped().

Issue 6411521.

Change-Id: I66a2c1a77e98149e5049a223a6f04c3b8c5ad11a
parent 209ec37b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2831,7 +2831,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac
        // hence the test on (mMixerStatus == MIXER_TRACKS_READY) meaning the track was mixed
        // during last round
        uint32_t minFrames = 1;
        if (!track->isStopped() && !track->isPausing() &&
        if ((track->sharedBuffer() == 0) && !track->isStopped() && !track->isPausing() &&
                (mMixerStatus == MIXER_TRACKS_READY)) {
            if (t->sampleRate() == (int)mSampleRate) {
                minFrames = mNormalFrameCount;
@@ -2990,7 +2990,8 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac
            if (track->isStopped()) {
                track->reset();
            }
            if (track->isTerminated() || track->isStopped() || track->isPaused()) {
            if ((track->sharedBuffer() != 0) || track->isTerminated() ||
                    track->isStopped() || track->isPaused()) {
                // We have consumed all the buffers of this track.
                // Remove it from the list of active tracks.
                // TODO: use actual buffer filling status instead of latency when available from
+2 −0
Original line number Diff line number Diff line
@@ -737,6 +737,8 @@ private:
                return (mStreamType == AUDIO_STREAM_CNT);
            }

            sp<IMemory> sharedBuffer() const { return mSharedBuffer; }

            bool presentationComplete(size_t framesWritten, size_t audioHalFrames);
            void triggerEvents(AudioSystem::sync_event_t type);