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

Commit da3349cc authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "AudioFlinger: Extract TeePatch" into main

parents c981ed86 16ed0da3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4038,7 +4038,7 @@ void AudioFlinger::updateSecondaryOutputsForTrack_l(
        patchTrack->setPeerProxy(patchRecord, true /* holdReference */);
        patchRecord->setPeerProxy(patchTrack, false /* holdReference */);
    }
    track->setTeePatchesToUpdate_l(&teePatches);  // TODO(b/288339104) void* to std::move()
    track->setTeePatchesToUpdate_l(std::move(teePatches));
}

sp<audioflinger::SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
+0 −12
Original line number Diff line number Diff line
@@ -583,13 +583,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.
@@ -728,11 +721,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:
@@ -325,9 +334,8 @@ public:
    // This function should be called with holding thread lock.
    virtual void updateTeePatches_l() = 0;

    // TODO(b/288339104) type
    virtual void setTeePatchesToUpdate_l(
            const void* teePatchesToUpdate /* TeePatches& teePatchesToUpdate */) = 0;
    // Argument teePatchesToUpdate is by value, use std::move to optimize.
    virtual void setTeePatchesToUpdate_l(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_l() final;
    void setTeePatchesToUpdate_l(const void* teePatchesToUpdate) final {
        setTeePatchesToUpdate_l(  // TODO(b/288339104) void*
                *reinterpret_cast<const AudioFlinger::TeePatches*>(teePatchesToUpdate));
    }
    void setTeePatchesToUpdate_l(AudioFlinger::TeePatches teePatchesToUpdate);
    void setTeePatchesToUpdate_l(TeePatches teePatchesToUpdate) final;

    void tallyUnderrunFrames(size_t frames) final {
       if (isOut()) { // we expect this from output tracks only
@@ -389,8 +385,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
@@ -1615,7 +1615,7 @@ void Track::updateTeePatches_l() {
    }
}

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