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

Commit 40079052 authored by Jiabin Huang's avatar Jiabin Huang Committed by Android (Google) Code Review
Browse files

Merge "Update tee patches in the thread loop." into udc-dev

parents 6e5663fe fb47684b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3951,7 +3951,7 @@ void AudioFlinger::updateSecondaryOutputsForTrack_l(
        patchTrack->setPeerProxy(patchRecord, true /* holdReference */);
        patchRecord->setPeerProxy(patchTrack, false /* holdReference */);
    }
    track->setTeePatches(std::move(teePatches));
    track->setTeePatchesToUpdate(std::move(teePatches));
}

sp<AudioFlinger::SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
+4 −1
Original line number Diff line number Diff line
@@ -186,7 +186,9 @@ public:
            }
            sp<os::ExternalVibration> getExternalVibration() const { return mExternalVibration; }

            void    setTeePatches(TeePatches teePatches);
            // This function should be called with holding thread lock.
            void    updateTeePatches();
            void    setTeePatchesToUpdate(TeePatches teePatchesToUpdate);

    void tallyUnderrunFrames(size_t frames) override {
       if (isOut()) { // we expect this from output tracks only
@@ -369,6 +371,7 @@ private:
    bool                mPauseHwPending = false; // direct/offload track request for thread pause
    audio_output_flags_t mFlags;
    TeePatches  mTeePatches;
    std::optional<TeePatches> mTeePatchesToUpdate;
    const float         mSpeed;
    const bool          mIsSpatialized;
    const bool          mIsBitPerfect;
+4 −0
Original line number Diff line number Diff line
@@ -4104,6 +4104,10 @@ NO_THREAD_SAFETY_ANALYSIS // manual locking of AudioFlinger

            setHalLatencyMode_l();

            for (const auto &track : mActiveTracks ) {
                track->updateTeePatches();
            }

            // signal actual start of output stream when the render position reported by the kernel
            // starts moving.
            if (!mStandby && !mHalStarted && mKernelPositionOnStandby !=
+15 −6
Original line number Diff line number Diff line
@@ -1491,13 +1491,22 @@ void AudioFlinger::PlaybackThread::Track::copyMetadataTo(MetadataInserter& backI
    *backInserter++ = metadata;
}

void AudioFlinger::PlaybackThread::Track::setTeePatches(TeePatches teePatches) {
void AudioFlinger::PlaybackThread::Track::updateTeePatches() {
    if (mTeePatchesToUpdate.has_value()) {
        forEachTeePatchTrack([](auto patchTrack) { patchTrack->destroy(); });
    mTeePatches = std::move(teePatches);
        mTeePatches = mTeePatchesToUpdate.value();
        if (mState == TrackBase::ACTIVE || mState == TrackBase::RESUMING ||
                mState == TrackBase::STOPPING_1) {
            forEachTeePatchTrack([](auto patchTrack) { patchTrack->start(); });
        }
        mTeePatchesToUpdate.reset();
    }
}

void AudioFlinger::PlaybackThread::Track::setTeePatchesToUpdate(TeePatches teePatchesToUpdate) {
    ALOGW_IF(mTeePatchesToUpdate.has_value(),
             "%s, existing tee patches to update will be ignored", __func__);
    mTeePatchesToUpdate = std::move(teePatchesToUpdate);
}

// must be called with player thread lock held