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

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

Merge changes I5b2973c1,Iaa535450

* changes:
  AudioFlinger: Extract inner Client class
  AudioFlinger: Use std::any for the event cookie
parents 0ea64ea6 59867e43
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1029,7 +1029,7 @@ NO_THREAD_SAFETY_ANALYSIS // conditional try lock
    return NO_ERROR;
}

sp<AudioFlinger::Client> AudioFlinger::registerPid(pid_t pid)
sp<Client> AudioFlinger::registerPid(pid_t pid)
{
    Mutex::Autolock _cl(mClientLock);
    // If pid is already in the mClients wp<> map, then use that entry
@@ -2314,19 +2314,19 @@ sp<AudioFlinger::ThreadBase> AudioFlinger::getEffectThread_l(audio_session_t ses

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

AudioFlinger::Client::Client(const sp<AudioFlinger>& audioFlinger, pid_t pid)
Client::Client(const sp<AudioFlinger>& audioFlinger, pid_t pid)
    :   RefBase(),
        mAudioFlinger(audioFlinger),
        mPid(pid),
        mClientAllocator(AllocatorFactory::getClientAllocator()) {}

// Client destructor must be called with AudioFlinger::mClientLock held
AudioFlinger::Client::~Client()
Client::~Client()
{
    mAudioFlinger->removeClient_l(mPid);
}

AllocatorFactory::ClientAllocator& AudioFlinger::Client::allocator()
AllocatorFactory::ClientAllocator& Client::allocator()
{
    return mClientAllocator;
}
+3 −20
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@
#include "android/media/BnAudioRecord.h"
#include "android/media/BnEffect.h"

#include "Client.h"

// include AudioFlinger component interfaces
#include "IAfEffect.h"

@@ -146,6 +148,7 @@ using android::content::AttributionSourceState;
class AudioFlinger : public AudioFlingerServerAdapter::Delegate
{
    friend class sp<AudioFlinger>;
    friend class Client; // removeClient_l();
public:
    static void instantiate() ANDROID_API;

@@ -497,26 +500,6 @@ public:
private:
    void dumpToThreadLog_l(const sp<ThreadBase> &thread);

public:
    // TODO(b/288339104) Move to separate file
    // --- Client ---
    class Client : public RefBase {
      public:
        Client(const sp<AudioFlinger>& audioFlinger, pid_t pid);
        virtual             ~Client();
        AllocatorFactory::ClientAllocator& allocator();
        pid_t               pid() const { return mPid; }
        sp<AudioFlinger>    audioFlinger() const { return mAudioFlinger; }

    private:
        DISALLOW_COPY_AND_ASSIGN(Client);

        const sp<AudioFlinger>    mAudioFlinger;
        const pid_t         mPid;
        AllocatorFactory::ClientAllocator mClientAllocator;
    };
private:

    // --- Notification Client ---
    class NotificationClient : public IBinder::DeathRecipient {
    public:
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

// TODO(b/288339104) Move to nested namespace
namespace android {

class AudioFlinger;

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

    // 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; }
    sp<AudioFlinger> audioFlinger() const { return mAudioFlinger; }

private:
    DISALLOW_COPY_AND_ASSIGN(Client);

    const sp<AudioFlinger> mAudioFlinger;
    const pid_t mPid;
    AllocatorFactory::ClientAllocator mClientAllocator;
};

} // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ void AudioFlinger::DeviceEffectManager::onUpdateAudioPatch(audio_patch_handle_t
sp<IAfEffectHandle> AudioFlinger::DeviceEffectManager::createEffect_l(
        effect_descriptor_t *descriptor,
        const AudioDeviceTypeAddr& device,
        const sp<AudioFlinger::Client>& client,
        const sp<Client>& client,
        const sp<IEffectClient>& effectClient,
        const std::map<audio_patch_handle_t, PatchPanel::Patch>& patches,
        int *enabled,
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ public:

    sp<IAfEffectHandle> createEffect_l(effect_descriptor_t *descriptor,
                const AudioDeviceTypeAddr& device,
                const sp<AudioFlinger::Client>& client,
                const sp<Client>& client,
                const sp<media::IEffectClient>& effectClient,
                const std::map<audio_patch_handle_t, PatchPanel::Patch>& patches,
                int *enabled,
Loading