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

Commit 05317d29 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Eric Laurent
Browse files

audioflinger: set flush pending on invalidating offload track

On invalidating an offload track, the IAudioTrack instance is
destroyed and the offload output is released. If it so happens
that APM::getOutputForAttr for the new IAudioTrack is called before
OffloadThread::prepareTracks_l checks and removes an invalid track,
the same output can get reused.

The side effect of this is data present in HAL and below from before the
invalidate will be rendered before data from the new seek position
is rendered. This is unexpected.

To fix this, set hint to issue flush when an offload track is invalidated.

Bug: 28566885
Change-Id: Ib6c38a3abb600598b87591bac90d03b7150d5216
parent 5bdfad1a
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -2670,11 +2670,10 @@ void AudioFlinger::PlaybackThread::cacheParameters_l()
    }
}

void AudioFlinger::PlaybackThread::invalidateTracks(audio_stream_type_t streamType)
void AudioFlinger::PlaybackThread::invalidateTracks_l(audio_stream_type_t streamType)
{
    ALOGV("MixerThread::invalidateTracks() mixer %p, streamType %d, mTracks.size %zu",
            this,  streamType, mTracks.size());
    Mutex::Autolock _l(mLock);

    size_t size = mTracks.size();
    for (size_t i = 0; i < size; i++) {
@@ -2685,6 +2684,12 @@ void AudioFlinger::PlaybackThread::invalidateTracks(audio_stream_type_t streamTy
    }
}

void AudioFlinger::PlaybackThread::invalidateTracks(audio_stream_type_t streamType)
{
    Mutex::Autolock _l(mLock);
    invalidateTracks_l(streamType);
}

status_t AudioFlinger::PlaybackThread::addEffectChain_l(const sp<EffectChain>& chain)
{
    audio_session_t session = chain->sessionId();
@@ -5445,6 +5450,13 @@ uint32_t AudioFlinger::OffloadThread::activeSleepTimeUs() const
    return time;
}

void AudioFlinger::OffloadThread::invalidateTracks(audio_stream_type_t streamType)
{
    Mutex::Autolock _l(mLock);
    mFlushPending = true;
    PlaybackThread::invalidateTracks_l(streamType);
}

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

AudioFlinger::DuplicatingThread::DuplicatingThread(const sp<AudioFlinger>& audioFlinger,
+3 −1
Original line number Diff line number Diff line
@@ -606,7 +606,8 @@ public:
                virtual bool     isValidSyncEvent(const sp<SyncEvent>& event) const;

                // called with AudioFlinger lock held
                        void     invalidateTracks(audio_stream_type_t streamType);
                        void     invalidateTracks_l(audio_stream_type_t streamType);
                virtual void     invalidateTracks(audio_stream_type_t streamType);

    virtual     size_t      frameCount() const { return mNormalFrameCount; }

@@ -998,6 +999,7 @@ protected:

    virtual     bool        waitingAsyncCallback();
    virtual     bool        waitingAsyncCallback_l();
    virtual     void        invalidateTracks(audio_stream_type_t streamType);

    virtual     bool        keepWakeLock() const { return mKeepWakeLock; }