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

Commit 44a957f0 authored by Eric Laurent's avatar Eric Laurent
Browse files

Fix static track activity ref counting

When a static AudioTrack underruns, it means that playback is over.
As apps do not necessarily stop playback explicitly, AudioFlinger
should call stopOutput() to decrease activity ref count in
audio policy manager.

Bug 6486311.

Change-Id: I1ea722c443780329ded6310c958b24726e918d16
parent 29864609
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -2136,6 +2136,21 @@ bool AudioFlinger::PlaybackThread::isValidSyncEvent(const sp<SyncEvent>& event)
    return false;
}

void AudioFlinger::PlaybackThread::threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove)
{
    size_t count = tracksToRemove.size();
    if (CC_UNLIKELY(count)) {
        for (size_t i = 0 ; i < count ; i++) {
            const sp<Track>& track = tracksToRemove.itemAt(i);
            if ((track->sharedBuffer() != 0) &&
                    (track->mState == TrackBase::ACTIVE || track->mState == TrackBase::RESUMING)) {
                AudioSystem::stopOutput(mId, track->streamType(), track->sessionId());
            }
        }
    }

}

// ----------------------------------------------------------------------------

AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
@@ -2588,7 +2603,6 @@ if (mType == DUPLICATING) {
    return false;
}

// returns (via tracksToRemove) a set of tracks to remove.
void AudioFlinger::MixerThread::threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove)
{
    PlaybackThread::threadLoop_removeTracks(tracksToRemove);
+1 −1
Original line number Diff line number Diff line
@@ -950,7 +950,7 @@ protected:
        virtual     void        threadLoop_sleepTime() = 0;
        virtual     void        threadLoop_write();
        virtual     void        threadLoop_standby();
        virtual     void        threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove) { }
        virtual     void        threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove);

                    // prepareTracks_l reads and writes mActiveTracks, and returns
                    // the pending set of tracks to remove via Vector 'tracksToRemove'.  The caller