blob: 36d6ff7bdce07d65ab31d36294bcd44e8e2ba31a [file] [log] [blame]
Andy Hungd65869f2023-06-27 17:05:02 -07001/*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
Andy Hung56126702023-07-14 11:00:08 -070019// TODO(b/291318727) Move to nested namespace
Andy Hungd65869f2023-06-27 17:05:02 -070020namespace android {
21
Andy Hungfa2f4f32023-07-17 12:40:43 -070022class IAfPlaybackThread;
23
24class IAfClientCallback : public virtual RefBase {
25public:
26 virtual Mutex& clientMutex() const = 0;
27 virtual void removeClient_l(pid_t pid) = 0;
28 virtual void removeNotificationClient(pid_t pid) = 0;
29 virtual status_t moveAuxEffectToIo(
30 int effectId,
31 const sp<IAfPlaybackThread>& dstThread,
32 sp<IAfPlaybackThread>* srcThread) = 0;
33};
Andy Hungd65869f2023-06-27 17:05:02 -070034
35class Client : public RefBase {
36public:
Andy Hungfa2f4f32023-07-17 12:40:43 -070037 Client(const sp<IAfClientCallback>& audioFlinger, pid_t pid);
Andy Hungd65869f2023-06-27 17:05:02 -070038
39 // TODO(b/289139675) make Client container.
40 // Client destructor must be called with AudioFlinger::mClientLock held
41 ~Client() override;
42 AllocatorFactory::ClientAllocator& allocator();
43 pid_t pid() const { return mPid; }
Andy Hungfa2f4f32023-07-17 12:40:43 -070044 const auto& afClientCallback() const { return mAfClientCallback; }
Andy Hungd65869f2023-06-27 17:05:02 -070045
46private:
47 DISALLOW_COPY_AND_ASSIGN(Client);
48
Andy Hungfa2f4f32023-07-17 12:40:43 -070049 const sp<IAfClientCallback> mAfClientCallback;
Andy Hungd65869f2023-06-27 17:05:02 -070050 const pid_t mPid;
51 AllocatorFactory::ClientAllocator mClientAllocator;
52};
53
54} // namespace android