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

Commit 19d61365 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add uid to audioflinger track dumps" into main

parents 84fdab92 b01390fa
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1009,14 +1009,14 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args)
    return NO_ERROR;
}

sp<Client> AudioFlinger::registerPid(pid_t pid)
sp<Client> AudioFlinger::registerClient(pid_t pid, uid_t uid)
{
    audio_utils::lock_guard _cl(clientMutex());
    // If pid is already in the mClients wp<> map, then use that entry
    // (for which promote() is always != 0), otherwise create a new entry and Client.
    sp<Client> client = mClients.valueFor(pid).promote();
    if (client == 0) {
        client = sp<Client>::make(sp<IAfClientCallback>::fromExisting(this), pid);
        client = sp<Client>::make(sp<IAfClientCallback>::fromExisting(this), pid, uid);
        mClients.add(pid, client);
    }

@@ -1194,7 +1194,7 @@ status_t AudioFlinger::createTrack(const media::CreateTrackRequest& _input,
            goto Exit;
        }

        client = registerPid(adjAttributionSource.pid);
        client = registerClient(adjAttributionSource.pid, adjAttributionSource.uid);

        IAfPlaybackThread* effectThread = nullptr;
        sp<IAfEffectChain> effectChain = nullptr;
@@ -2489,7 +2489,7 @@ status_t AudioFlinger::createRecord(const media::CreateRecordRequest& _input,
    output.selectedDeviceId = input.selectedDeviceId;
    output.flags = input.flags;

    client = registerPid(VALUE_OR_FATAL(aidl2legacy_int32_t_pid_t(adjAttributionSource.pid)));
    client = registerClient(adjAttributionSource.pid, adjAttributionSource.uid);

    // Not a conventional loop, but a retry loop for at most two iterations total.
    // Try first maybe with FAST flag then try again without FAST flag if that fails.
@@ -4412,7 +4412,7 @@ status_t AudioFlinger::createEffect(const media::CreateEffectRequest& request,
        audio_utils::lock_guard _l(mutex());

        if (sessionId == AUDIO_SESSION_DEVICE) {
            sp<Client> client = registerPid(currentPid);
            sp<Client> client = registerClient(currentPid, adjAttributionSource.uid);
            ALOGV("%s device type %#x address %s", __func__, device.mType, device.getAddress());
            handle = mDeviceEffectManager->createEffect_l(
                    &descOut, device, client, effectClient, mPatchPanel->patches_l(),
@@ -4474,7 +4474,7 @@ status_t AudioFlinger::createEffect(const media::CreateEffectRequest& request,
                    goto Exit;
                }
                ALOGV("%s() got io %d for effect %s", __func__, io, descOut.name);
                sp<Client> client = registerPid(currentPid);
                sp<Client> client = registerClient(currentPid, adjAttributionSource.uid);
                bool pinned = !audio_is_global_session(sessionId) && isSessionAcquired_l(sessionId);
                handle = createOrphanEffect_l(client, effectClient, priority, sessionId,
                                              &descOut, &enabledOut, &lStatus, pinned,
@@ -4536,7 +4536,7 @@ status_t AudioFlinger::createEffect(const media::CreateEffectRequest& request,
            }
        }

        sp<Client> client = registerPid(currentPid);
        sp<Client> client = registerClient(currentPid, adjAttributionSource.uid);

        // create effect on selected output thread
        bool pinned = !audio_is_global_session(sessionId) && isSessionAcquired_l(sessionId);
+2 −1
Original line number Diff line number Diff line
@@ -728,7 +728,8 @@ private:
                // Audio data transfer is directly handled by the client creating the MMAP stream
    DefaultKeyedVector<audio_io_handle_t, sp<IAfMmapThread>> mMmapThreads GUARDED_BY(mutex());

    sp<Client> registerPid(pid_t pid) EXCLUDES_AudioFlinger_ClientMutex; // always returns non-0
    // always returns non-null
    sp<Client> registerClient(pid_t pid, uid_t uid) EXCLUDES_AudioFlinger_ClientMutex;

    sp<IAfEffectHandle> createOrphanEffect_l(const sp<Client>& client,
                                          const sp<media::IEffectClient>& effectClient,
+3 −2
Original line number Diff line number Diff line
@@ -18,9 +18,10 @@

namespace android {

Client::Client(const sp<IAfClientCallback>& afClientCallback, pid_t pid)
Client::Client(const sp<IAfClientCallback>& afClientCallback, pid_t pid, uid_t uid)
    : mAfClientCallback(afClientCallback)
    , mPid(pid)
    , mUid(uid)
    , mClientAllocator(AllocatorFactory::getClientAllocator()) {}

// Client destructor must be called with AudioFlinger::mClientLock held
+3 −1
Original line number Diff line number Diff line
@@ -42,13 +42,14 @@ public:

class Client : public RefBase {
public:
    Client(const sp<IAfClientCallback>& audioFlinger, pid_t pid);
    Client(const sp<IAfClientCallback>& audioFlinger, pid_t pid, uid_t uid);

    // TODO(b/289139675) make Client container.
    // Client destructor must be called with AudioFlinger::mClientLock held
    ~Client() override;
    AllocatorFactory::ClientAllocator& allocator();
    pid_t pid() const { return mPid; }
    uid_t uid() const { return mUid; }
    const auto& afClientCallback() const { return mAfClientCallback; }

private:
@@ -56,6 +57,7 @@ private:

    const sp<IAfClientCallback> mAfClientCallback;
    const pid_t mPid;
    const uid_t mUid;
    AllocatorFactory::ClientAllocator mClientAllocator;
};

+4 −3
Original line number Diff line number Diff line
@@ -295,7 +295,7 @@ public:

    static constexpr std::string_view getLogHeader() {
        using namespace std::literals;
        return "Type     Id Active Client Session Port Id S  Flags "
        return "Type     Id Active Client(pid/uid) Session Port Id S  Flags "
                        "  Format Chn mask  SRate "
                        "ST Usg CT "
                        " G db  L dB  R dB  VS dB  PortVol dB "
@@ -480,7 +480,8 @@ public:

    static constexpr std::string_view getLogHeader() {
        using namespace std::literals;
        return "Client Session Port Id   Format Chn mask  SRate Flags Usg/Src PortVol dB\n"sv;
        return "Client(pid/uid) Session Port Id"
                "   Format Chn mask  SRate Flags Usg/Src PortVol dB\n"sv;
    };

    // protected by MMapThread::mLock
@@ -528,7 +529,7 @@ public:

    static constexpr std::string_view getLogHeader() {
        using namespace std::literals;
        return "Active     Id Client Session Port Id  S  Flags  "
        return "Active     Id Client(pid/uid) Session Port Id  S  Flags  "
                        " Format Chn mask  SRate Source  "
                        " Server FrmCnt FrmRdy Sil   Latency\n"sv;
    }
Loading