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

Commit 34645da2 authored by Andy Hung's avatar Andy Hung
Browse files

AudioFlinger: Extract TeePatch

Test: atest audiorecord_tests audiotrack_tests audiorouting_tests trackplayerbase_tests audiosystem_tests
Test: atest AAudioTests AudioTrackOffloadTest
Test: atest AudioTrackTest AudioRecordTest
Test: YouTube Camera
Bug: 288339104
Merged-In: I88576005a266fd6beeabec873a2d531a65dcf9fd
Change-Id: I88576005a266fd6beeabec873a2d531a65dcf9fd
parent 7ab063d3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3999,7 +3999,7 @@ void AudioFlinger::updateSecondaryOutputsForTrack_l(
        patchTrack->setPeerProxy(patchRecord, true /* holdReference */);
        patchRecord->setPeerProxy(patchTrack, false /* holdReference */);
    }
    track->setTeePatchesToUpdate(&teePatches);  // TODO(b/288339104) void* to std::move()
    track->setTeePatchesToUpdate(std::move(teePatches));
}

sp<audioflinger::SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
+0 −12
Original line number Diff line number Diff line
@@ -582,13 +582,6 @@ private:
    // Requests media.log to start merging log buffers
    void requestLogMerge();

    // TODO(b/288339104) replace these forward declaration classes with interfaces.
private:
    struct TeePatch;
public:
    using TeePatches = std::vector<TeePatch>;
private:

    // Find io handle by session id.
    // Preference is given to an io handle with a matching effect chain to session id.
    // If none found, AUDIO_IO_HANDLE_NONE is returned.
@@ -722,11 +715,6 @@ private:
                        audio_io_handle_t upStream, const String8& keyValuePairs,
            const std::function<bool(const sp<IAfPlaybackThread>&)>& useThread = nullptr);

    struct TeePatch {
        sp<IAfPatchRecord> patchRecord;
        sp<IAfPatchTrack> patchTrack;
    };

    // for mAudioSessionRefs only
    struct AudioSessionRef {
        AudioSessionRef(audio_session_t sessionid, pid_t pid, uid_t uid) :
+11 −3
Original line number Diff line number Diff line
@@ -19,10 +19,19 @@
namespace android {

class IAfDuplicatingThread;
class IAfPatchRecord;
class IAfPatchTrack;
class IAfPlaybackThread;
class IAfRecordThread;
class IAfThreadBase;

struct TeePatch {
    sp<IAfPatchRecord> patchRecord;
    sp<IAfPatchTrack> patchTrack;
};

using TeePatches = std::vector<TeePatch>;

// Common interface to all Playback and Record tracks.
class IAfTrackBase : public virtual RefBase {
public:
@@ -313,9 +322,8 @@ public:
    // This function should be called with holding thread lock.
    virtual void updateTeePatches() = 0;

    // TODO(b/288339104) type
    virtual void setTeePatchesToUpdate(
            const void* teePatchesToUpdate /* TeePatches& teePatchesToUpdate */) = 0;
    // Argument teePatchesToUpdate is by value, use std::move to optimize.
    virtual void setTeePatchesToUpdate(TeePatches teePatchesToUpdate) = 0;

    static bool checkServerLatencySupported(audio_format_t format, audio_output_flags_t flags) {
        return audio_is_linear_pcm(format) && (flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC) == 0;
+3 −7
Original line number Diff line number Diff line
@@ -189,11 +189,7 @@ public:

            // This function should be called with holding thread lock.
    void updateTeePatches() final;
    void setTeePatchesToUpdate(const void* teePatchesToUpdate) final {
        setTeePatchesToUpdate(  // TODO(b/288339104) void*
                *reinterpret_cast<const AudioFlinger::TeePatches*>(teePatchesToUpdate));
    }
    void setTeePatchesToUpdate(AudioFlinger::TeePatches teePatchesToUpdate);
    void setTeePatchesToUpdate(TeePatches teePatchesToUpdate) final;

    void tallyUnderrunFrames(size_t frames) final {
       if (isOut()) { // we expect this from output tracks only
@@ -388,8 +384,8 @@ private:
    bool                mFlushHwPending; // track requests for thread flush
    bool                mPauseHwPending = false; // direct/offload track request for thread pause
    audio_output_flags_t mFlags;
    AudioFlinger::TeePatches  mTeePatches;
    std::optional<AudioFlinger::TeePatches> mTeePatchesToUpdate;
    TeePatches mTeePatches;
    std::optional<TeePatches> mTeePatchesToUpdate;
    const float         mSpeed;
    const bool          mIsSpatialized;
    const bool          mIsBitPerfect;
+1 −1
Original line number Diff line number Diff line
@@ -1617,7 +1617,7 @@ void Track::updateTeePatches() {
    }
}

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