blob: 2f6ab2fe7a5c838c795ccb1e08efdbc11a74d15d [file] [log] [blame]
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +00001/*
2 * Copyright (C) 2022 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#include <algorithm>
18#include <set>
19
20#define LOG_TAG "AHAL_Module"
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000021#include <android-base/logging.h>
Shunkai Yao39bf2c32022-12-06 03:25:59 +000022#include <android/binder_ibinder_platform.h>
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000023
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +000024#include <Utils.h>
25#include <aidl/android/media/audio/common/AudioInputFlags.h>
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000026#include <aidl/android/media/audio/common/AudioOutputFlags.h>
27
Mikhail Naganov10c6fe22022-09-30 23:49:17 +000028#include "core-impl/Bluetooth.h"
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000029#include "core-impl/Module.h"
jiabin253bd322023-01-25 23:57:31 +000030#include "core-impl/ModuleUsb.h"
Vlad Popa943b7e22022-12-08 14:24:12 +010031#include "core-impl/SoundDose.h"
Mikhail Naganovf429c032023-01-07 00:24:50 +000032#include "core-impl/StreamStub.h"
jiabin253bd322023-01-25 23:57:31 +000033#include "core-impl/StreamUsb.h"
Mikhail Naganov3b125b72022-10-05 02:12:39 +000034#include "core-impl/Telephony.h"
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000035#include "core-impl/utils.h"
36
37using aidl::android::hardware::audio::common::SinkMetadata;
38using aidl::android::hardware::audio::common::SourceMetadata;
Vlad Popa2afbd1e2022-12-28 17:04:58 +010039using aidl::android::hardware::audio::core::sounddose::ISoundDose;
Mikhail Naganov6a4872d2022-06-15 21:39:04 +000040using aidl::android::media::audio::common::AudioChannelLayout;
Mikhail Naganovef6bc742022-10-06 00:14:19 +000041using aidl::android::media::audio::common::AudioDevice;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000042using aidl::android::media::audio::common::AudioFormatDescription;
Mikhail Naganov6a4872d2022-06-15 21:39:04 +000043using aidl::android::media::audio::common::AudioFormatType;
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +000044using aidl::android::media::audio::common::AudioInputFlags;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000045using aidl::android::media::audio::common::AudioIoFlags;
jiabin9a8e6862023-01-12 23:06:37 +000046using aidl::android::media::audio::common::AudioMMapPolicy;
47using aidl::android::media::audio::common::AudioMMapPolicyInfo;
48using aidl::android::media::audio::common::AudioMMapPolicyType;
Mikhail Naganov04ae8222023-01-11 15:48:10 -080049using aidl::android::media::audio::common::AudioMode;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000050using aidl::android::media::audio::common::AudioOffloadInfo;
51using aidl::android::media::audio::common::AudioOutputFlags;
52using aidl::android::media::audio::common::AudioPort;
53using aidl::android::media::audio::common::AudioPortConfig;
54using aidl::android::media::audio::common::AudioPortExt;
55using aidl::android::media::audio::common::AudioProfile;
Mikhail Naganov20047bc2023-01-05 20:16:07 +000056using aidl::android::media::audio::common::Boolean;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000057using aidl::android::media::audio::common::Int;
Mikhail Naganov6a4872d2022-06-15 21:39:04 +000058using aidl::android::media::audio::common::PcmType;
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +000059using android::hardware::audio::common::getFrameSizeInBytes;
Mikhail Naganova2c5ddf2022-09-12 22:57:14 +000060using android::hardware::audio::common::isBitPositionFlagSet;
Mikhail Naganov04ae8222023-01-11 15:48:10 -080061using android::hardware::audio::common::isValidAudioMode;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +000062
63namespace aidl::android::hardware::audio::core {
64
65namespace {
66
67bool generateDefaultPortConfig(const AudioPort& port, AudioPortConfig* config) {
68 *config = {};
69 config->portId = port.id;
70 if (port.profiles.empty()) {
71 LOG(ERROR) << __func__ << ": port " << port.id << " has no profiles";
72 return false;
73 }
74 const auto& profile = port.profiles.begin();
75 config->format = profile->format;
76 if (profile->channelMasks.empty()) {
77 LOG(ERROR) << __func__ << ": the first profile in port " << port.id
78 << " has no channel masks";
79 return false;
80 }
81 config->channelMask = *profile->channelMasks.begin();
82 if (profile->sampleRates.empty()) {
83 LOG(ERROR) << __func__ << ": the first profile in port " << port.id
84 << " has no sample rates";
85 return false;
86 }
87 Int sampleRate;
88 sampleRate.value = *profile->sampleRates.begin();
89 config->sampleRate = sampleRate;
90 config->flags = port.flags;
91 config->ext = port.ext;
92 return true;
93}
94
95bool findAudioProfile(const AudioPort& port, const AudioFormatDescription& format,
96 AudioProfile* profile) {
97 if (auto profilesIt =
98 find_if(port.profiles.begin(), port.profiles.end(),
99 [&format](const auto& profile) { return profile.format == format; });
100 profilesIt != port.profiles.end()) {
101 *profile = *profilesIt;
102 return true;
103 }
104 return false;
105}
Mikhail Naganov00603d12022-05-02 22:52:13 +0000106
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000107} // namespace
108
jiabin253bd322023-01-25 23:57:31 +0000109// static
110std::shared_ptr<Module> Module::createInstance(Type type) {
111 switch (type) {
112 case Module::Type::USB:
113 return ndk::SharedRefBase::make<ModuleUsb>(type);
114 case Type::DEFAULT:
115 case Type::R_SUBMIX:
116 default:
117 return ndk::SharedRefBase::make<Module>(type);
118 }
119}
120
121// static
122StreamIn::CreateInstance Module::getStreamInCreator(Type type) {
123 switch (type) {
124 case Type::USB:
125 return StreamInUsb::createInstance;
126 case Type::DEFAULT:
127 case Type::R_SUBMIX:
128 default:
129 return StreamInStub::createInstance;
130 }
131}
132
133// static
134StreamOut::CreateInstance Module::getStreamOutCreator(Type type) {
135 switch (type) {
136 case Type::USB:
137 return StreamOutUsb::createInstance;
138 case Type::DEFAULT:
139 case Type::R_SUBMIX:
140 default:
141 return StreamOutStub::createInstance;
142 }
143}
144
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000145void Module::cleanUpPatch(int32_t patchId) {
146 erase_all_values(mPatches, std::set<int32_t>{patchId});
147}
148
Mikhail Naganov8651b362023-01-06 23:15:27 +0000149ndk::ScopedAStatus Module::createStreamContext(
150 int32_t in_portConfigId, int64_t in_bufferSizeFrames,
151 std::shared_ptr<IStreamCallback> asyncCallback,
152 std::shared_ptr<IStreamOutEventCallback> outEventCallback, StreamContext* out_context) {
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000153 if (in_bufferSizeFrames <= 0) {
154 LOG(ERROR) << __func__ << ": non-positive buffer size " << in_bufferSizeFrames;
155 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
156 }
157 if (in_bufferSizeFrames < kMinimumStreamBufferSizeFrames) {
158 LOG(ERROR) << __func__ << ": insufficient buffer size " << in_bufferSizeFrames
159 << ", must be at least " << kMinimumStreamBufferSizeFrames;
160 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
161 }
162 auto& configs = getConfig().portConfigs;
163 auto portConfigIt = findById<AudioPortConfig>(configs, in_portConfigId);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000164 // Since this is a private method, it is assumed that
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000165 // validity of the portConfigId has already been checked.
166 const size_t frameSize =
167 getFrameSizeInBytes(portConfigIt->format.value(), portConfigIt->channelMask.value());
168 if (frameSize == 0) {
169 LOG(ERROR) << __func__ << ": could not calculate frame size for port config "
170 << portConfigIt->toString();
171 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
172 }
173 LOG(DEBUG) << __func__ << ": frame size " << frameSize << " bytes";
174 if (frameSize > kMaximumStreamBufferSizeBytes / in_bufferSizeFrames) {
175 LOG(ERROR) << __func__ << ": buffer size " << in_bufferSizeFrames
176 << " frames is too large, maximum size is "
177 << kMaximumStreamBufferSizeBytes / frameSize;
178 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
179 }
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000180 const auto& flags = portConfigIt->flags.value();
181 if ((flags.getTag() == AudioIoFlags::Tag::input &&
Mikhail Naganova2c5ddf2022-09-12 22:57:14 +0000182 !isBitPositionFlagSet(flags.get<AudioIoFlags::Tag::input>(),
183 AudioInputFlags::MMAP_NOIRQ)) ||
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000184 (flags.getTag() == AudioIoFlags::Tag::output &&
Mikhail Naganova2c5ddf2022-09-12 22:57:14 +0000185 !isBitPositionFlagSet(flags.get<AudioIoFlags::Tag::output>(),
186 AudioOutputFlags::MMAP_NOIRQ))) {
Mikhail Naganov20047bc2023-01-05 20:16:07 +0000187 StreamContext::DebugParameters params{mDebug.streamTransientStateDelayMs,
Mikhail Naganov194daaa2023-01-05 22:34:20 +0000188 mVendorDebug.forceTransientBurst,
189 mVendorDebug.forceSynchronousDrain};
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000190 StreamContext temp(
191 std::make_unique<StreamContext::CommandMQ>(1, true /*configureEventFlagWord*/),
192 std::make_unique<StreamContext::ReplyMQ>(1, true /*configureEventFlagWord*/),
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000193 portConfigIt->format.value(), portConfigIt->channelMask.value(),
jiabin253bd322023-01-25 23:57:31 +0000194 portConfigIt->sampleRate.value().value,
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000195 std::make_unique<StreamContext::DataMQ>(frameSize * in_bufferSizeFrames),
Mikhail Naganov8651b362023-01-06 23:15:27 +0000196 asyncCallback, outEventCallback, params);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000197 if (temp.isValid()) {
198 *out_context = std::move(temp);
199 } else {
200 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
201 }
202 } else {
203 // TODO: Implement simulation of MMAP buffer allocation
204 }
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000205 return ndk::ScopedAStatus::ok();
206}
207
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000208std::vector<AudioDevice> Module::findConnectedDevices(int32_t portConfigId) {
209 std::vector<AudioDevice> result;
210 auto& ports = getConfig().ports;
211 auto portIds = portIdsFromPortConfigIds(findConnectedPortConfigIds(portConfigId));
212 for (auto it = portIds.begin(); it != portIds.end(); ++it) {
213 auto portIt = findById<AudioPort>(ports, *it);
214 if (portIt != ports.end() && portIt->ext.getTag() == AudioPortExt::Tag::device) {
215 result.push_back(portIt->ext.template get<AudioPortExt::Tag::device>().device);
216 }
217 }
218 return result;
219}
220
221std::set<int32_t> Module::findConnectedPortConfigIds(int32_t portConfigId) {
222 std::set<int32_t> result;
223 auto patchIdsRange = mPatches.equal_range(portConfigId);
224 auto& patches = getConfig().patches;
225 for (auto it = patchIdsRange.first; it != patchIdsRange.second; ++it) {
226 auto patchIt = findById<AudioPatch>(patches, it->second);
227 if (patchIt == patches.end()) {
228 LOG(FATAL) << __func__ << ": patch with id " << it->second << " taken from mPatches "
229 << "not found in the configuration";
230 }
231 if (std::find(patchIt->sourcePortConfigIds.begin(), patchIt->sourcePortConfigIds.end(),
232 portConfigId) != patchIt->sourcePortConfigIds.end()) {
233 result.insert(patchIt->sinkPortConfigIds.begin(), patchIt->sinkPortConfigIds.end());
234 } else {
235 result.insert(patchIt->sourcePortConfigIds.begin(), patchIt->sourcePortConfigIds.end());
236 }
237 }
238 return result;
239}
240
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000241ndk::ScopedAStatus Module::findPortIdForNewStream(int32_t in_portConfigId, AudioPort** port) {
242 auto& configs = getConfig().portConfigs;
243 auto portConfigIt = findById<AudioPortConfig>(configs, in_portConfigId);
244 if (portConfigIt == configs.end()) {
245 LOG(ERROR) << __func__ << ": existing port config id " << in_portConfigId << " not found";
246 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
247 }
248 const int32_t portId = portConfigIt->portId;
249 // In our implementation, configs of mix ports always have unique IDs.
250 CHECK(portId != in_portConfigId);
251 auto& ports = getConfig().ports;
252 auto portIt = findById<AudioPort>(ports, portId);
253 if (portIt == ports.end()) {
254 LOG(ERROR) << __func__ << ": port id " << portId << " used by port config id "
255 << in_portConfigId << " not found";
256 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
257 }
258 if (mStreams.count(in_portConfigId) != 0) {
259 LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
260 << " already has a stream opened on it";
261 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
262 }
263 if (portIt->ext.getTag() != AudioPortExt::Tag::mix) {
264 LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
265 << " does not correspond to a mix port";
266 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
267 }
268 const int32_t maxOpenStreamCount = portIt->ext.get<AudioPortExt::Tag::mix>().maxOpenStreamCount;
269 if (maxOpenStreamCount != 0 && mStreams.count(portId) >= maxOpenStreamCount) {
270 LOG(ERROR) << __func__ << ": port id " << portId
271 << " has already reached maximum allowed opened stream count: "
272 << maxOpenStreamCount;
273 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
274 }
275 *port = &(*portIt);
276 return ndk::ScopedAStatus::ok();
277}
278
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000279template <typename C>
280std::set<int32_t> Module::portIdsFromPortConfigIds(C portConfigIds) {
281 std::set<int32_t> result;
282 auto& portConfigs = getConfig().portConfigs;
283 for (auto it = portConfigIds.begin(); it != portConfigIds.end(); ++it) {
284 auto portConfigIt = findById<AudioPortConfig>(portConfigs, *it);
285 if (portConfigIt != portConfigs.end()) {
286 result.insert(portConfigIt->portId);
287 }
288 }
289 return result;
290}
291
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000292internal::Configuration& Module::getConfig() {
293 if (!mConfig) {
Mikhail Naganovc8e43122022-12-09 00:33:47 +0000294 switch (mType) {
295 case Type::DEFAULT:
296 mConfig = std::move(internal::getPrimaryConfiguration());
297 break;
298 case Type::R_SUBMIX:
299 mConfig = std::move(internal::getRSubmixConfiguration());
300 break;
jiabinb309d8d2023-01-20 19:07:15 +0000301 case Type::USB:
302 mConfig = std::move(internal::getUsbConfiguration());
jiabin253bd322023-01-25 23:57:31 +0000303 break;
Mikhail Naganovc8e43122022-12-09 00:33:47 +0000304 }
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000305 }
306 return *mConfig;
307}
308
309void Module::registerPatch(const AudioPatch& patch) {
310 auto& configs = getConfig().portConfigs;
311 auto do_insert = [&](const std::vector<int32_t>& portConfigIds) {
312 for (auto portConfigId : portConfigIds) {
313 auto configIt = findById<AudioPortConfig>(configs, portConfigId);
314 if (configIt != configs.end()) {
315 mPatches.insert(std::pair{portConfigId, patch.id});
316 if (configIt->portId != portConfigId) {
317 mPatches.insert(std::pair{configIt->portId, patch.id});
318 }
319 }
320 };
321 };
322 do_insert(patch.sourcePortConfigIds);
323 do_insert(patch.sinkPortConfigIds);
324}
325
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000326void Module::updateStreamsConnectedState(const AudioPatch& oldPatch, const AudioPatch& newPatch) {
327 // Streams from the old patch need to be disconnected, streams from the new
328 // patch need to be connected. If the stream belongs to both patches, no need
329 // to update it.
330 std::set<int32_t> idsToDisconnect, idsToConnect;
331 idsToDisconnect.insert(oldPatch.sourcePortConfigIds.begin(),
332 oldPatch.sourcePortConfigIds.end());
333 idsToDisconnect.insert(oldPatch.sinkPortConfigIds.begin(), oldPatch.sinkPortConfigIds.end());
334 idsToConnect.insert(newPatch.sourcePortConfigIds.begin(), newPatch.sourcePortConfigIds.end());
335 idsToConnect.insert(newPatch.sinkPortConfigIds.begin(), newPatch.sinkPortConfigIds.end());
336 std::for_each(idsToDisconnect.begin(), idsToDisconnect.end(), [&](const auto& portConfigId) {
337 if (idsToConnect.count(portConfigId) == 0) {
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000338 LOG(DEBUG) << "The stream on port config id " << portConfigId << " is not connected";
339 mStreams.setStreamIsConnected(portConfigId, {});
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000340 }
341 });
342 std::for_each(idsToConnect.begin(), idsToConnect.end(), [&](const auto& portConfigId) {
343 if (idsToDisconnect.count(portConfigId) == 0) {
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000344 const auto connectedDevices = findConnectedDevices(portConfigId);
345 LOG(DEBUG) << "The stream on port config id " << portConfigId
346 << " is connected to: " << ::android::internal::ToString(connectedDevices);
347 mStreams.setStreamIsConnected(portConfigId, connectedDevices);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000348 }
349 });
350}
351
Mikhail Naganov00603d12022-05-02 22:52:13 +0000352ndk::ScopedAStatus Module::setModuleDebug(
353 const ::aidl::android::hardware::audio::core::ModuleDebug& in_debug) {
354 LOG(DEBUG) << __func__ << ": old flags:" << mDebug.toString()
355 << ", new flags: " << in_debug.toString();
356 if (mDebug.simulateDeviceConnections != in_debug.simulateDeviceConnections &&
357 !mConnectedDevicePorts.empty()) {
358 LOG(ERROR) << __func__ << ": attempting to change device connections simulation "
359 << "while having external devices connected";
360 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
361 }
Mikhail Naganovbd483c02022-11-17 20:33:39 +0000362 if (in_debug.streamTransientStateDelayMs < 0) {
363 LOG(ERROR) << __func__ << ": streamTransientStateDelayMs is negative: "
364 << in_debug.streamTransientStateDelayMs;
365 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
366 }
Mikhail Naganov00603d12022-05-02 22:52:13 +0000367 mDebug = in_debug;
368 return ndk::ScopedAStatus::ok();
369}
370
Mikhail Naganov3b125b72022-10-05 02:12:39 +0000371ndk::ScopedAStatus Module::getTelephony(std::shared_ptr<ITelephony>* _aidl_return) {
372 if (mTelephony == nullptr) {
373 mTelephony = ndk::SharedRefBase::make<Telephony>();
Mikhail Naganovdf5feba2022-12-15 00:11:14 +0000374 mTelephonyBinder = mTelephony->asBinder();
375 AIBinder_setMinSchedulerPolicy(mTelephonyBinder.get(), SCHED_NORMAL,
Shunkai Yao39bf2c32022-12-06 03:25:59 +0000376 ANDROID_PRIORITY_AUDIO);
Mikhail Naganov3b125b72022-10-05 02:12:39 +0000377 }
378 *_aidl_return = mTelephony;
379 LOG(DEBUG) << __func__ << ": returning instance of ITelephony: " << _aidl_return->get();
380 return ndk::ScopedAStatus::ok();
381}
382
Mikhail Naganov10c6fe22022-09-30 23:49:17 +0000383ndk::ScopedAStatus Module::getBluetooth(std::shared_ptr<IBluetooth>* _aidl_return) {
384 if (mBluetooth == nullptr) {
385 mBluetooth = ndk::SharedRefBase::make<Bluetooth>();
386 mBluetoothBinder = mBluetooth->asBinder();
387 AIBinder_setMinSchedulerPolicy(mBluetoothBinder.get(), SCHED_NORMAL,
388 ANDROID_PRIORITY_AUDIO);
389 }
390 *_aidl_return = mBluetooth;
391 LOG(DEBUG) << __func__ << ": returning instance of IBluetooth: " << _aidl_return->get();
392 return ndk::ScopedAStatus::ok();
393}
394
Mikhail Naganov00603d12022-05-02 22:52:13 +0000395ndk::ScopedAStatus Module::connectExternalDevice(const AudioPort& in_templateIdAndAdditionalData,
396 AudioPort* _aidl_return) {
397 const int32_t templateId = in_templateIdAndAdditionalData.id;
398 auto& ports = getConfig().ports;
399 AudioPort connectedPort;
400 { // Scope the template port so that we don't accidentally modify it.
401 auto templateIt = findById<AudioPort>(ports, templateId);
402 if (templateIt == ports.end()) {
403 LOG(ERROR) << __func__ << ": port id " << templateId << " not found";
404 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
405 }
406 if (templateIt->ext.getTag() != AudioPortExt::Tag::device) {
407 LOG(ERROR) << __func__ << ": port id " << templateId << " is not a device port";
408 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
409 }
410 if (!templateIt->profiles.empty()) {
411 LOG(ERROR) << __func__ << ": port id " << templateId
412 << " does not have dynamic profiles";
413 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
414 }
415 auto& templateDevicePort = templateIt->ext.get<AudioPortExt::Tag::device>();
416 if (templateDevicePort.device.type.connection.empty()) {
417 LOG(ERROR) << __func__ << ": port id " << templateId << " is permanently attached";
418 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
419 }
420 // Postpone id allocation until we ensure that there are no client errors.
421 connectedPort = *templateIt;
422 connectedPort.extraAudioDescriptors = in_templateIdAndAdditionalData.extraAudioDescriptors;
423 const auto& inputDevicePort =
424 in_templateIdAndAdditionalData.ext.get<AudioPortExt::Tag::device>();
425 auto& connectedDevicePort = connectedPort.ext.get<AudioPortExt::Tag::device>();
426 connectedDevicePort.device.address = inputDevicePort.device.address;
427 LOG(DEBUG) << __func__ << ": device port " << connectedPort.id << " device set to "
428 << connectedDevicePort.device.toString();
429 // Check if there is already a connected port with for the same external device.
430 for (auto connectedPortId : mConnectedDevicePorts) {
431 auto connectedPortIt = findById<AudioPort>(ports, connectedPortId);
432 if (connectedPortIt->ext.get<AudioPortExt::Tag::device>().device ==
433 connectedDevicePort.device) {
434 LOG(ERROR) << __func__ << ": device " << connectedDevicePort.device.toString()
435 << " is already connected at the device port id " << connectedPortId;
436 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
437 }
438 }
439 }
440
441 if (!mDebug.simulateDeviceConnections) {
442 // In a real HAL here we would attempt querying the profiles from the device.
443 LOG(ERROR) << __func__ << ": failed to query supported device profiles";
jiabin253bd322023-01-25 23:57:31 +0000444 // TODO: Check the return value when it is ready for actual devices.
445 populateConnectedDevicePort(&connectedPort);
Mikhail Naganov00603d12022-05-02 22:52:13 +0000446 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
447 }
448
449 connectedPort.id = ++getConfig().nextPortId;
450 mConnectedDevicePorts.insert(connectedPort.id);
451 LOG(DEBUG) << __func__ << ": template port " << templateId << " external device connected, "
452 << "connected port ID " << connectedPort.id;
453 auto& connectedProfiles = getConfig().connectedProfiles;
454 if (auto connectedProfilesIt = connectedProfiles.find(templateId);
455 connectedProfilesIt != connectedProfiles.end()) {
456 connectedPort.profiles = connectedProfilesIt->second;
457 }
458 ports.push_back(connectedPort);
459 *_aidl_return = std::move(connectedPort);
460
461 std::vector<AudioRoute> newRoutes;
462 auto& routes = getConfig().routes;
463 for (auto& r : routes) {
464 if (r.sinkPortId == templateId) {
465 AudioRoute newRoute;
466 newRoute.sourcePortIds = r.sourcePortIds;
467 newRoute.sinkPortId = connectedPort.id;
468 newRoute.isExclusive = r.isExclusive;
469 newRoutes.push_back(std::move(newRoute));
470 } else {
471 auto& srcs = r.sourcePortIds;
472 if (std::find(srcs.begin(), srcs.end(), templateId) != srcs.end()) {
473 srcs.push_back(connectedPort.id);
474 }
475 }
476 }
477 routes.insert(routes.end(), newRoutes.begin(), newRoutes.end());
478
479 return ndk::ScopedAStatus::ok();
480}
481
482ndk::ScopedAStatus Module::disconnectExternalDevice(int32_t in_portId) {
483 auto& ports = getConfig().ports;
484 auto portIt = findById<AudioPort>(ports, in_portId);
485 if (portIt == ports.end()) {
486 LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
487 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
488 }
489 if (portIt->ext.getTag() != AudioPortExt::Tag::device) {
490 LOG(ERROR) << __func__ << ": port id " << in_portId << " is not a device port";
491 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
492 }
493 if (mConnectedDevicePorts.count(in_portId) == 0) {
494 LOG(ERROR) << __func__ << ": port id " << in_portId << " is not a connected device port";
495 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
496 }
497 auto& configs = getConfig().portConfigs;
498 auto& initials = getConfig().initialConfigs;
499 auto configIt = std::find_if(configs.begin(), configs.end(), [&](const auto& config) {
500 if (config.portId == in_portId) {
501 // Check if the configuration was provided by the client.
502 const auto& initialIt = findById<AudioPortConfig>(initials, config.id);
503 return initialIt == initials.end() || config != *initialIt;
504 }
505 return false;
506 });
507 if (configIt != configs.end()) {
508 LOG(ERROR) << __func__ << ": port id " << in_portId << " has a non-default config with id "
509 << configIt->id;
510 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
511 }
512 ports.erase(portIt);
513 mConnectedDevicePorts.erase(in_portId);
514 LOG(DEBUG) << __func__ << ": connected device port " << in_portId << " released";
515
516 auto& routes = getConfig().routes;
517 for (auto routesIt = routes.begin(); routesIt != routes.end();) {
518 if (routesIt->sinkPortId == in_portId) {
519 routesIt = routes.erase(routesIt);
520 } else {
521 // Note: the list of sourcePortIds can't become empty because there must
522 // be the id of the template port in the route.
523 erase_if(routesIt->sourcePortIds, [in_portId](auto src) { return src == in_portId; });
524 ++routesIt;
525 }
526 }
527
528 return ndk::ScopedAStatus::ok();
529}
530
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000531ndk::ScopedAStatus Module::getAudioPatches(std::vector<AudioPatch>* _aidl_return) {
532 *_aidl_return = getConfig().patches;
533 LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " patches";
534 return ndk::ScopedAStatus::ok();
535}
536
537ndk::ScopedAStatus Module::getAudioPort(int32_t in_portId, AudioPort* _aidl_return) {
538 auto& ports = getConfig().ports;
539 auto portIt = findById<AudioPort>(ports, in_portId);
540 if (portIt != ports.end()) {
541 *_aidl_return = *portIt;
542 LOG(DEBUG) << __func__ << ": returning port by id " << in_portId;
543 return ndk::ScopedAStatus::ok();
544 }
545 LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
546 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
547}
548
549ndk::ScopedAStatus Module::getAudioPortConfigs(std::vector<AudioPortConfig>* _aidl_return) {
550 *_aidl_return = getConfig().portConfigs;
551 LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " port configs";
552 return ndk::ScopedAStatus::ok();
553}
554
555ndk::ScopedAStatus Module::getAudioPorts(std::vector<AudioPort>* _aidl_return) {
556 *_aidl_return = getConfig().ports;
557 LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " ports";
558 return ndk::ScopedAStatus::ok();
559}
560
561ndk::ScopedAStatus Module::getAudioRoutes(std::vector<AudioRoute>* _aidl_return) {
562 *_aidl_return = getConfig().routes;
563 LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " routes";
564 return ndk::ScopedAStatus::ok();
565}
566
Mikhail Naganov00603d12022-05-02 22:52:13 +0000567ndk::ScopedAStatus Module::getAudioRoutesForAudioPort(int32_t in_portId,
568 std::vector<AudioRoute>* _aidl_return) {
569 auto& ports = getConfig().ports;
570 if (auto portIt = findById<AudioPort>(ports, in_portId); portIt == ports.end()) {
571 LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
572 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
573 }
574 auto& routes = getConfig().routes;
575 std::copy_if(routes.begin(), routes.end(), std::back_inserter(*_aidl_return),
576 [&](const auto& r) {
577 const auto& srcs = r.sourcePortIds;
578 return r.sinkPortId == in_portId ||
579 std::find(srcs.begin(), srcs.end(), in_portId) != srcs.end();
580 });
581 return ndk::ScopedAStatus::ok();
582}
583
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000584ndk::ScopedAStatus Module::openInputStream(const OpenInputStreamArguments& in_args,
585 OpenInputStreamReturn* _aidl_return) {
586 LOG(DEBUG) << __func__ << ": port config id " << in_args.portConfigId << ", buffer size "
587 << in_args.bufferSizeFrames << " frames";
588 AudioPort* port = nullptr;
589 if (auto status = findPortIdForNewStream(in_args.portConfigId, &port); !status.isOk()) {
590 return status;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000591 }
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000592 if (port->flags.getTag() != AudioIoFlags::Tag::input) {
593 LOG(ERROR) << __func__ << ": port config id " << in_args.portConfigId
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000594 << " does not correspond to an input mix port";
595 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
596 }
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000597 StreamContext context;
Mikhail Naganov30301a42022-09-13 01:20:45 +0000598 if (auto status = createStreamContext(in_args.portConfigId, in_args.bufferSizeFrames, nullptr,
Mikhail Naganov8651b362023-01-06 23:15:27 +0000599 nullptr, &context);
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000600 !status.isOk()) {
601 return status;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000602 }
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000603 context.fillDescriptor(&_aidl_return->desc);
Mikhail Naganove9f10fc2022-10-14 23:31:52 +0000604 std::shared_ptr<StreamIn> stream;
jiabin253bd322023-01-25 23:57:31 +0000605 ndk::ScopedAStatus status = getStreamInCreator(mType)(in_args.sinkMetadata, std::move(context),
606 mConfig->microphones, &stream);
607 if (!status.isOk()) {
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000608 return status;
609 }
610 StreamWrapper streamWrapper(stream);
Mikhail Naganovdf5feba2022-12-15 00:11:14 +0000611 AIBinder_setMinSchedulerPolicy(streamWrapper.getBinder().get(), SCHED_NORMAL,
612 ANDROID_PRIORITY_AUDIO);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000613 auto patchIt = mPatches.find(in_args.portConfigId);
614 if (patchIt != mPatches.end()) {
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000615 streamWrapper.setStreamIsConnected(findConnectedDevices(in_args.portConfigId));
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000616 }
617 mStreams.insert(port->id, in_args.portConfigId, std::move(streamWrapper));
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000618 _aidl_return->stream = std::move(stream);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000619 return ndk::ScopedAStatus::ok();
620}
621
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000622ndk::ScopedAStatus Module::openOutputStream(const OpenOutputStreamArguments& in_args,
623 OpenOutputStreamReturn* _aidl_return) {
624 LOG(DEBUG) << __func__ << ": port config id " << in_args.portConfigId << ", has offload info? "
625 << (in_args.offloadInfo.has_value()) << ", buffer size " << in_args.bufferSizeFrames
626 << " frames";
627 AudioPort* port = nullptr;
628 if (auto status = findPortIdForNewStream(in_args.portConfigId, &port); !status.isOk()) {
629 return status;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000630 }
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000631 if (port->flags.getTag() != AudioIoFlags::Tag::output) {
632 LOG(ERROR) << __func__ << ": port config id " << in_args.portConfigId
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000633 << " does not correspond to an output mix port";
634 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
635 }
Mikhail Naganova2c5ddf2022-09-12 22:57:14 +0000636 const bool isOffload = isBitPositionFlagSet(port->flags.get<AudioIoFlags::Tag::output>(),
637 AudioOutputFlags::COMPRESS_OFFLOAD);
638 if (isOffload && !in_args.offloadInfo.has_value()) {
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000639 LOG(ERROR) << __func__ << ": port id " << port->id
Mikhail Naganov111e0ce2022-06-17 21:41:19 +0000640 << " has COMPRESS_OFFLOAD flag set, requires offload info";
641 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
642 }
Mikhail Naganov30301a42022-09-13 01:20:45 +0000643 const bool isNonBlocking = isBitPositionFlagSet(port->flags.get<AudioIoFlags::Tag::output>(),
644 AudioOutputFlags::NON_BLOCKING);
645 if (isNonBlocking && in_args.callback == nullptr) {
646 LOG(ERROR) << __func__ << ": port id " << port->id
647 << " has NON_BLOCKING flag set, requires async callback";
648 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
649 }
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000650 StreamContext context;
Mikhail Naganov30301a42022-09-13 01:20:45 +0000651 if (auto status = createStreamContext(in_args.portConfigId, in_args.bufferSizeFrames,
Mikhail Naganov8651b362023-01-06 23:15:27 +0000652 isNonBlocking ? in_args.callback : nullptr,
653 in_args.eventCallback, &context);
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000654 !status.isOk()) {
655 return status;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000656 }
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000657 context.fillDescriptor(&_aidl_return->desc);
Mikhail Naganove9f10fc2022-10-14 23:31:52 +0000658 std::shared_ptr<StreamOut> stream;
jiabin253bd322023-01-25 23:57:31 +0000659 ndk::ScopedAStatus status = getStreamOutCreator(mType)(
660 in_args.sourceMetadata, std::move(context), in_args.offloadInfo, &stream);
661 if (!status.isOk()) {
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000662 return status;
663 }
664 StreamWrapper streamWrapper(stream);
Mikhail Naganovdf5feba2022-12-15 00:11:14 +0000665 AIBinder_setMinSchedulerPolicy(streamWrapper.getBinder().get(), SCHED_NORMAL,
666 ANDROID_PRIORITY_AUDIO);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000667 auto patchIt = mPatches.find(in_args.portConfigId);
668 if (patchIt != mPatches.end()) {
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000669 streamWrapper.setStreamIsConnected(findConnectedDevices(in_args.portConfigId));
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000670 }
671 mStreams.insert(port->id, in_args.portConfigId, std::move(streamWrapper));
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000672 _aidl_return->stream = std::move(stream);
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000673 return ndk::ScopedAStatus::ok();
674}
675
Mikhail Naganov74927202022-12-19 16:37:14 +0000676ndk::ScopedAStatus Module::getSupportedPlaybackRateFactors(
677 SupportedPlaybackRateFactors* _aidl_return) {
678 LOG(DEBUG) << __func__;
679 (void)_aidl_return;
680 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
681}
682
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000683ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPatch* _aidl_return) {
Mikhail Naganov16db9b72022-06-17 21:36:18 +0000684 LOG(DEBUG) << __func__ << ": requested patch " << in_requested.toString();
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000685 if (in_requested.sourcePortConfigIds.empty()) {
686 LOG(ERROR) << __func__ << ": requested patch has empty sources list";
687 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
688 }
689 if (!all_unique<int32_t>(in_requested.sourcePortConfigIds)) {
690 LOG(ERROR) << __func__ << ": requested patch has duplicate ids in the sources list";
691 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
692 }
693 if (in_requested.sinkPortConfigIds.empty()) {
694 LOG(ERROR) << __func__ << ": requested patch has empty sinks list";
695 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
696 }
697 if (!all_unique<int32_t>(in_requested.sinkPortConfigIds)) {
698 LOG(ERROR) << __func__ << ": requested patch has duplicate ids in the sinks list";
699 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
700 }
701
702 auto& configs = getConfig().portConfigs;
703 std::vector<int32_t> missingIds;
704 auto sources =
705 selectByIds<AudioPortConfig>(configs, in_requested.sourcePortConfigIds, &missingIds);
706 if (!missingIds.empty()) {
707 LOG(ERROR) << __func__ << ": following source port config ids not found: "
708 << ::android::internal::ToString(missingIds);
709 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
710 }
711 auto sinks = selectByIds<AudioPortConfig>(configs, in_requested.sinkPortConfigIds, &missingIds);
712 if (!missingIds.empty()) {
713 LOG(ERROR) << __func__ << ": following sink port config ids not found: "
714 << ::android::internal::ToString(missingIds);
715 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
716 }
717 // bool indicates whether a non-exclusive route is available.
718 // If only an exclusive route is available, that means the patch can not be
719 // established if there is any other patch which currently uses the sink port.
720 std::map<int32_t, bool> allowedSinkPorts;
721 auto& routes = getConfig().routes;
722 for (auto src : sources) {
723 for (const auto& r : routes) {
724 const auto& srcs = r.sourcePortIds;
725 if (std::find(srcs.begin(), srcs.end(), src->portId) != srcs.end()) {
726 if (!allowedSinkPorts[r.sinkPortId]) { // prefer non-exclusive
727 allowedSinkPorts[r.sinkPortId] = !r.isExclusive;
728 }
729 }
730 }
731 }
732 for (auto sink : sinks) {
733 if (allowedSinkPorts.count(sink->portId) == 0) {
734 LOG(ERROR) << __func__ << ": there is no route to the sink port id " << sink->portId;
735 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
736 }
737 }
738
jiabin253bd322023-01-25 23:57:31 +0000739 if (auto status = checkAudioPatchEndpointsMatch(sources, sinks); !status.isOk()) {
740 return status;
741 }
742
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000743 auto& patches = getConfig().patches;
744 auto existing = patches.end();
745 std::optional<decltype(mPatches)> patchesBackup;
746 if (in_requested.id != 0) {
747 existing = findById<AudioPatch>(patches, in_requested.id);
748 if (existing != patches.end()) {
749 patchesBackup = mPatches;
750 cleanUpPatch(existing->id);
751 } else {
752 LOG(ERROR) << __func__ << ": not found existing patch id " << in_requested.id;
753 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
754 }
755 }
756 // Validate the requested patch.
757 for (const auto& [sinkPortId, nonExclusive] : allowedSinkPorts) {
758 if (!nonExclusive && mPatches.count(sinkPortId) != 0) {
759 LOG(ERROR) << __func__ << ": sink port id " << sinkPortId
760 << "is exclusive and is already used by some other patch";
761 if (patchesBackup.has_value()) {
762 mPatches = std::move(*patchesBackup);
763 }
764 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
765 }
766 }
767 *_aidl_return = in_requested;
Mikhail Naganov6a4872d2022-06-15 21:39:04 +0000768 _aidl_return->minimumStreamBufferSizeFrames = kMinimumStreamBufferSizeFrames;
769 _aidl_return->latenciesMs.clear();
770 _aidl_return->latenciesMs.insert(_aidl_return->latenciesMs.end(),
771 _aidl_return->sinkPortConfigIds.size(), kLatencyMs);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000772 AudioPatch oldPatch{};
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000773 if (existing == patches.end()) {
774 _aidl_return->id = getConfig().nextPatchId++;
775 patches.push_back(*_aidl_return);
776 existing = patches.begin() + (patches.size() - 1);
777 } else {
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000778 oldPatch = *existing;
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000779 *existing = *_aidl_return;
780 }
781 registerPatch(*existing);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000782 updateStreamsConnectedState(oldPatch, *_aidl_return);
783
784 LOG(DEBUG) << __func__ << ": " << (oldPatch.id == 0 ? "created" : "updated") << " patch "
785 << _aidl_return->toString();
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000786 return ndk::ScopedAStatus::ok();
787}
788
789ndk::ScopedAStatus Module::setAudioPortConfig(const AudioPortConfig& in_requested,
790 AudioPortConfig* out_suggested, bool* _aidl_return) {
791 LOG(DEBUG) << __func__ << ": requested " << in_requested.toString();
792 auto& configs = getConfig().portConfigs;
793 auto existing = configs.end();
794 if (in_requested.id != 0) {
795 if (existing = findById<AudioPortConfig>(configs, in_requested.id);
796 existing == configs.end()) {
797 LOG(ERROR) << __func__ << ": existing port config id " << in_requested.id
798 << " not found";
799 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
800 }
801 }
802
803 const int portId = existing != configs.end() ? existing->portId : in_requested.portId;
804 if (portId == 0) {
805 LOG(ERROR) << __func__ << ": input port config does not specify portId";
806 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
807 }
808 auto& ports = getConfig().ports;
809 auto portIt = findById<AudioPort>(ports, portId);
810 if (portIt == ports.end()) {
811 LOG(ERROR) << __func__ << ": input port config points to non-existent portId " << portId;
812 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
813 }
814 if (existing != configs.end()) {
815 *out_suggested = *existing;
816 } else {
817 AudioPortConfig newConfig;
818 if (generateDefaultPortConfig(*portIt, &newConfig)) {
819 *out_suggested = newConfig;
820 } else {
821 LOG(ERROR) << __func__ << ": unable generate a default config for port " << portId;
822 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
823 }
824 }
825 // From this moment, 'out_suggested' is either an existing port config,
826 // or a new generated config. Now attempt to update it according to the specified
827 // fields of 'in_requested'.
828
829 bool requestedIsValid = true, requestedIsFullySpecified = true;
830
831 AudioIoFlags portFlags = portIt->flags;
832 if (in_requested.flags.has_value()) {
833 if (in_requested.flags.value() != portFlags) {
834 LOG(WARNING) << __func__ << ": requested flags "
835 << in_requested.flags.value().toString() << " do not match port's "
836 << portId << " flags " << portFlags.toString();
837 requestedIsValid = false;
838 }
839 } else {
840 requestedIsFullySpecified = false;
841 }
842
843 AudioProfile portProfile;
844 if (in_requested.format.has_value()) {
845 const auto& format = in_requested.format.value();
846 if (findAudioProfile(*portIt, format, &portProfile)) {
847 out_suggested->format = format;
848 } else {
849 LOG(WARNING) << __func__ << ": requested format " << format.toString()
850 << " is not found in port's " << portId << " profiles";
851 requestedIsValid = false;
852 }
853 } else {
854 requestedIsFullySpecified = false;
855 }
856 if (!findAudioProfile(*portIt, out_suggested->format.value(), &portProfile)) {
857 LOG(ERROR) << __func__ << ": port " << portId << " does not support format "
858 << out_suggested->format.value().toString() << " anymore";
859 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
860 }
861
862 if (in_requested.channelMask.has_value()) {
863 const auto& channelMask = in_requested.channelMask.value();
864 if (find(portProfile.channelMasks.begin(), portProfile.channelMasks.end(), channelMask) !=
865 portProfile.channelMasks.end()) {
866 out_suggested->channelMask = channelMask;
867 } else {
868 LOG(WARNING) << __func__ << ": requested channel mask " << channelMask.toString()
869 << " is not supported for the format " << portProfile.format.toString()
870 << " by the port " << portId;
871 requestedIsValid = false;
872 }
873 } else {
874 requestedIsFullySpecified = false;
875 }
876
877 if (in_requested.sampleRate.has_value()) {
878 const auto& sampleRate = in_requested.sampleRate.value();
879 if (find(portProfile.sampleRates.begin(), portProfile.sampleRates.end(),
880 sampleRate.value) != portProfile.sampleRates.end()) {
881 out_suggested->sampleRate = sampleRate;
882 } else {
883 LOG(WARNING) << __func__ << ": requested sample rate " << sampleRate.value
884 << " is not supported for the format " << portProfile.format.toString()
885 << " by the port " << portId;
886 requestedIsValid = false;
887 }
888 } else {
889 requestedIsFullySpecified = false;
890 }
891
892 if (in_requested.gain.has_value()) {
893 // Let's pretend that gain can always be applied.
894 out_suggested->gain = in_requested.gain.value();
895 }
896
897 if (existing == configs.end() && requestedIsValid && requestedIsFullySpecified) {
898 out_suggested->id = getConfig().nextPortId++;
899 configs.push_back(*out_suggested);
900 *_aidl_return = true;
901 LOG(DEBUG) << __func__ << ": created new port config " << out_suggested->toString();
902 } else if (existing != configs.end() && requestedIsValid) {
903 *existing = *out_suggested;
904 *_aidl_return = true;
905 LOG(DEBUG) << __func__ << ": updated port config " << out_suggested->toString();
906 } else {
907 LOG(DEBUG) << __func__ << ": not applied; existing config ? " << (existing != configs.end())
908 << "; requested is valid? " << requestedIsValid << ", fully specified? "
909 << requestedIsFullySpecified;
910 *_aidl_return = false;
911 }
912 return ndk::ScopedAStatus::ok();
913}
914
915ndk::ScopedAStatus Module::resetAudioPatch(int32_t in_patchId) {
916 auto& patches = getConfig().patches;
917 auto patchIt = findById<AudioPatch>(patches, in_patchId);
918 if (patchIt != patches.end()) {
919 cleanUpPatch(patchIt->id);
Mikhail Naganov4f5d3f12022-07-22 23:23:25 +0000920 updateStreamsConnectedState(*patchIt, AudioPatch{});
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +0000921 patches.erase(patchIt);
922 LOG(DEBUG) << __func__ << ": erased patch " << in_patchId;
923 return ndk::ScopedAStatus::ok();
924 }
925 LOG(ERROR) << __func__ << ": patch id " << in_patchId << " not found";
926 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
927}
928
929ndk::ScopedAStatus Module::resetAudioPortConfig(int32_t in_portConfigId) {
930 auto& configs = getConfig().portConfigs;
931 auto configIt = findById<AudioPortConfig>(configs, in_portConfigId);
932 if (configIt != configs.end()) {
933 if (mStreams.count(in_portConfigId) != 0) {
934 LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
935 << " has a stream opened on it";
936 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
937 }
938 auto patchIt = mPatches.find(in_portConfigId);
939 if (patchIt != mPatches.end()) {
940 LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
941 << " is used by the patch with id " << patchIt->second;
942 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
943 }
944 auto& initials = getConfig().initialConfigs;
945 auto initialIt = findById<AudioPortConfig>(initials, in_portConfigId);
946 if (initialIt == initials.end()) {
947 configs.erase(configIt);
948 LOG(DEBUG) << __func__ << ": erased port config " << in_portConfigId;
949 } else if (*configIt != *initialIt) {
950 *configIt = *initialIt;
951 LOG(DEBUG) << __func__ << ": reset port config " << in_portConfigId;
952 }
953 return ndk::ScopedAStatus::ok();
954 }
955 LOG(ERROR) << __func__ << ": port config id " << in_portConfigId << " not found";
956 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
957}
958
Mikhail Naganov3b125b72022-10-05 02:12:39 +0000959ndk::ScopedAStatus Module::getMasterMute(bool* _aidl_return) {
960 *_aidl_return = mMasterMute;
961 LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
962 return ndk::ScopedAStatus::ok();
963}
964
965ndk::ScopedAStatus Module::setMasterMute(bool in_mute) {
966 LOG(DEBUG) << __func__ << ": " << in_mute;
967 mMasterMute = in_mute;
968 return ndk::ScopedAStatus::ok();
969}
970
971ndk::ScopedAStatus Module::getMasterVolume(float* _aidl_return) {
972 *_aidl_return = mMasterVolume;
973 LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
974 return ndk::ScopedAStatus::ok();
975}
976
977ndk::ScopedAStatus Module::setMasterVolume(float in_volume) {
978 LOG(DEBUG) << __func__ << ": " << in_volume;
979 if (in_volume >= 0.0f && in_volume <= 1.0f) {
980 mMasterVolume = in_volume;
981 return ndk::ScopedAStatus::ok();
982 }
983 LOG(ERROR) << __func__ << ": invalid master volume value: " << in_volume;
984 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
985}
986
987ndk::ScopedAStatus Module::getMicMute(bool* _aidl_return) {
988 *_aidl_return = mMicMute;
989 LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
990 return ndk::ScopedAStatus::ok();
991}
992
993ndk::ScopedAStatus Module::setMicMute(bool in_mute) {
994 LOG(DEBUG) << __func__ << ": " << in_mute;
995 mMicMute = in_mute;
996 return ndk::ScopedAStatus::ok();
997}
998
Mikhail Naganovef6bc742022-10-06 00:14:19 +0000999ndk::ScopedAStatus Module::getMicrophones(std::vector<MicrophoneInfo>* _aidl_return) {
Pawan Wagh6f57cd92023-02-01 21:14:34 +00001000 *_aidl_return = getConfig().microphones;
Mikhail Naganovef6bc742022-10-06 00:14:19 +00001001 LOG(DEBUG) << __func__ << ": returning " << ::android::internal::ToString(*_aidl_return);
1002 return ndk::ScopedAStatus::ok();
1003}
1004
Mikhail Naganov3b125b72022-10-05 02:12:39 +00001005ndk::ScopedAStatus Module::updateAudioMode(AudioMode in_mode) {
Mikhail Naganov04ae8222023-01-11 15:48:10 -08001006 if (!isValidAudioMode(in_mode)) {
1007 LOG(ERROR) << __func__ << ": invalid mode " << toString(in_mode);
1008 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
1009 }
Mikhail Naganov3b125b72022-10-05 02:12:39 +00001010 // No checks for supported audio modes here, it's an informative notification.
1011 LOG(DEBUG) << __func__ << ": " << toString(in_mode);
1012 return ndk::ScopedAStatus::ok();
1013}
1014
1015ndk::ScopedAStatus Module::updateScreenRotation(ScreenRotation in_rotation) {
1016 LOG(DEBUG) << __func__ << ": " << toString(in_rotation);
1017 return ndk::ScopedAStatus::ok();
1018}
1019
1020ndk::ScopedAStatus Module::updateScreenState(bool in_isTurnedOn) {
1021 LOG(DEBUG) << __func__ << ": " << in_isTurnedOn;
1022 return ndk::ScopedAStatus::ok();
1023}
1024
Vlad Popa83a6d822022-11-07 13:53:57 +01001025ndk::ScopedAStatus Module::getSoundDose(std::shared_ptr<ISoundDose>* _aidl_return) {
Vlad Popa943b7e22022-12-08 14:24:12 +01001026 if (mSoundDose == nullptr) {
Vlad Popa2afbd1e2022-12-28 17:04:58 +01001027 mSoundDose = ndk::SharedRefBase::make<sounddose::SoundDose>();
Mikhail Naganovdf5feba2022-12-15 00:11:14 +00001028 mSoundDoseBinder = mSoundDose->asBinder();
1029 AIBinder_setMinSchedulerPolicy(mSoundDoseBinder.get(), SCHED_NORMAL,
1030 ANDROID_PRIORITY_AUDIO);
Vlad Popa943b7e22022-12-08 14:24:12 +01001031 }
1032 *_aidl_return = mSoundDose;
1033 LOG(DEBUG) << __func__ << ": returning instance of ISoundDose: " << _aidl_return->get();
Vlad Popa83a6d822022-11-07 13:53:57 +01001034 return ndk::ScopedAStatus::ok();
1035}
1036
Mikhail Naganove9f10fc2022-10-14 23:31:52 +00001037ndk::ScopedAStatus Module::generateHwAvSyncId(int32_t* _aidl_return) {
1038 LOG(DEBUG) << __func__;
1039 (void)_aidl_return;
1040 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
1041}
1042
Mikhail Naganov20047bc2023-01-05 20:16:07 +00001043const std::string Module::VendorDebug::kForceTransientBurstName = "aosp.forceTransientBurst";
Mikhail Naganov194daaa2023-01-05 22:34:20 +00001044const std::string Module::VendorDebug::kForceSynchronousDrainName = "aosp.forceSynchronousDrain";
Mikhail Naganov20047bc2023-01-05 20:16:07 +00001045
Mikhail Naganove9f10fc2022-10-14 23:31:52 +00001046ndk::ScopedAStatus Module::getVendorParameters(const std::vector<std::string>& in_ids,
1047 std::vector<VendorParameter>* _aidl_return) {
1048 LOG(DEBUG) << __func__ << ": id count: " << in_ids.size();
Mikhail Naganov20047bc2023-01-05 20:16:07 +00001049 bool allParametersKnown = true;
1050 for (const auto& id : in_ids) {
1051 if (id == VendorDebug::kForceTransientBurstName) {
1052 VendorParameter forceTransientBurst{.id = id};
1053 forceTransientBurst.ext.setParcelable(Boolean{mVendorDebug.forceTransientBurst});
1054 _aidl_return->push_back(std::move(forceTransientBurst));
Mikhail Naganov194daaa2023-01-05 22:34:20 +00001055 } else if (id == VendorDebug::kForceSynchronousDrainName) {
1056 VendorParameter forceSynchronousDrain{.id = id};
1057 forceSynchronousDrain.ext.setParcelable(Boolean{mVendorDebug.forceSynchronousDrain});
1058 _aidl_return->push_back(std::move(forceSynchronousDrain));
Mikhail Naganov20047bc2023-01-05 20:16:07 +00001059 } else {
1060 allParametersKnown = false;
1061 LOG(ERROR) << __func__ << ": unrecognized parameter \"" << id << "\"";
1062 }
1063 }
1064 if (allParametersKnown) return ndk::ScopedAStatus::ok();
1065 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
Mikhail Naganove9f10fc2022-10-14 23:31:52 +00001066}
1067
Mikhail Naganov194daaa2023-01-05 22:34:20 +00001068namespace {
1069
1070template <typename W>
1071bool extractParameter(const VendorParameter& p, decltype(W::value)* v) {
1072 std::optional<W> value;
1073 binder_status_t result = p.ext.getParcelable(&value);
1074 if (result == STATUS_OK && value.has_value()) {
1075 *v = value.value().value;
1076 return true;
1077 }
1078 LOG(ERROR) << __func__ << ": failed to read the value of the parameter \"" << p.id
1079 << "\": " << result;
1080 return false;
1081}
1082
1083} // namespace
1084
Mikhail Naganove9f10fc2022-10-14 23:31:52 +00001085ndk::ScopedAStatus Module::setVendorParameters(const std::vector<VendorParameter>& in_parameters,
1086 bool in_async) {
1087 LOG(DEBUG) << __func__ << ": parameter count " << in_parameters.size()
1088 << ", async: " << in_async;
Mikhail Naganov20047bc2023-01-05 20:16:07 +00001089 bool allParametersKnown = true;
1090 for (const auto& p : in_parameters) {
1091 if (p.id == VendorDebug::kForceTransientBurstName) {
Mikhail Naganov194daaa2023-01-05 22:34:20 +00001092 if (!extractParameter<Boolean>(p, &mVendorDebug.forceTransientBurst)) {
1093 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
1094 }
1095 } else if (p.id == VendorDebug::kForceSynchronousDrainName) {
1096 if (!extractParameter<Boolean>(p, &mVendorDebug.forceSynchronousDrain)) {
Mikhail Naganov20047bc2023-01-05 20:16:07 +00001097 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
1098 }
1099 } else {
1100 allParametersKnown = false;
1101 LOG(ERROR) << __func__ << ": unrecognized parameter \"" << p.id << "\"";
1102 }
1103 }
1104 if (allParametersKnown) return ndk::ScopedAStatus::ok();
1105 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
Mikhail Naganove9f10fc2022-10-14 23:31:52 +00001106}
1107
Mikhail Naganovfb1acde2022-12-12 18:57:36 +00001108ndk::ScopedAStatus Module::addDeviceEffect(
1109 int32_t in_portConfigId,
1110 const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_effect) {
1111 if (in_effect == nullptr) {
1112 LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", null effect";
1113 } else {
1114 LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", effect Binder "
1115 << in_effect->asBinder().get();
1116 }
1117 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
1118}
1119
1120ndk::ScopedAStatus Module::removeDeviceEffect(
1121 int32_t in_portConfigId,
1122 const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_effect) {
1123 if (in_effect == nullptr) {
1124 LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", null effect";
1125 } else {
1126 LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", effect Binder "
1127 << in_effect->asBinder().get();
1128 }
1129 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
1130}
1131
jiabin9a8e6862023-01-12 23:06:37 +00001132ndk::ScopedAStatus Module::getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType,
1133 std::vector<AudioMMapPolicyInfo>* _aidl_return) {
1134 LOG(DEBUG) << __func__ << ": mmap policy type " << toString(mmapPolicyType);
1135 std::set<int32_t> mmapSinks;
1136 std::set<int32_t> mmapSources;
1137 auto& ports = getConfig().ports;
1138 for (const auto& port : ports) {
1139 if (port.flags.getTag() == AudioIoFlags::Tag::input &&
1140 isBitPositionFlagSet(port.flags.get<AudioIoFlags::Tag::input>(),
1141 AudioInputFlags::MMAP_NOIRQ)) {
1142 mmapSinks.insert(port.id);
1143 } else if (port.flags.getTag() == AudioIoFlags::Tag::output &&
1144 isBitPositionFlagSet(port.flags.get<AudioIoFlags::Tag::output>(),
1145 AudioOutputFlags::MMAP_NOIRQ)) {
1146 mmapSources.insert(port.id);
1147 }
1148 }
1149 for (const auto& route : getConfig().routes) {
1150 if (mmapSinks.count(route.sinkPortId) != 0) {
1151 // The sink is a mix port, add the sources if they are device ports.
1152 for (int sourcePortId : route.sourcePortIds) {
1153 auto sourcePortIt = findById<AudioPort>(ports, sourcePortId);
1154 if (sourcePortIt == ports.end()) {
1155 // This must not happen
1156 LOG(ERROR) << __func__ << ": port id " << sourcePortId << " cannot be found";
1157 continue;
1158 }
1159 if (sourcePortIt->ext.getTag() != AudioPortExt::Tag::device) {
1160 // The source is not a device port, skip
1161 continue;
1162 }
1163 AudioMMapPolicyInfo policyInfo;
1164 policyInfo.device = sourcePortIt->ext.get<AudioPortExt::Tag::device>().device;
1165 // Always return AudioMMapPolicy.AUTO if the device supports mmap for
1166 // default implementation.
1167 policyInfo.mmapPolicy = AudioMMapPolicy::AUTO;
1168 _aidl_return->push_back(policyInfo);
1169 }
1170 } else {
1171 auto sinkPortIt = findById<AudioPort>(ports, route.sinkPortId);
1172 if (sinkPortIt == ports.end()) {
1173 // This must not happen
1174 LOG(ERROR) << __func__ << ": port id " << route.sinkPortId << " cannot be found";
1175 continue;
1176 }
1177 if (sinkPortIt->ext.getTag() != AudioPortExt::Tag::device) {
1178 // The sink is not a device port, skip
1179 continue;
1180 }
1181 if (count_any(mmapSources, route.sourcePortIds)) {
1182 AudioMMapPolicyInfo policyInfo;
1183 policyInfo.device = sinkPortIt->ext.get<AudioPortExt::Tag::device>().device;
1184 // Always return AudioMMapPolicy.AUTO if the device supports mmap for
1185 // default implementation.
1186 policyInfo.mmapPolicy = AudioMMapPolicy::AUTO;
1187 _aidl_return->push_back(policyInfo);
1188 }
1189 }
1190 }
1191 return ndk::ScopedAStatus::ok();
1192}
1193
Eric Laurente2432ea2023-01-12 17:47:31 +01001194ndk::ScopedAStatus Module::supportsVariableLatency(bool* _aidl_return) {
1195 LOG(DEBUG) << __func__;
1196 *_aidl_return = false;
1197 return ndk::ScopedAStatus::ok();
1198}
1199
jiabinb76981e2023-01-18 00:58:30 +00001200ndk::ScopedAStatus Module::getAAudioMixerBurstCount(int32_t* _aidl_return) {
1201 if (!isMmapSupported()) {
1202 LOG(DEBUG) << __func__ << ": mmap is not supported ";
1203 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
1204 }
1205 *_aidl_return = DEFAULT_AAUDIO_MIXER_BURST_COUNT;
1206 LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
1207 return ndk::ScopedAStatus::ok();
1208}
1209
1210ndk::ScopedAStatus Module::getAAudioHardwareBurstMinUsec(int32_t* _aidl_return) {
1211 if (!isMmapSupported()) {
1212 LOG(DEBUG) << __func__ << ": mmap is not supported ";
1213 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
1214 }
1215 *_aidl_return = DEFAULT_AAUDIO_HARDWARE_BURST_MIN_DURATION_US;
1216 LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
1217 return ndk::ScopedAStatus::ok();
1218}
1219
1220bool Module::isMmapSupported() {
1221 if (mIsMmapSupported.has_value()) {
1222 return mIsMmapSupported.value();
1223 }
1224 std::vector<AudioMMapPolicyInfo> mmapPolicyInfos;
1225 if (!getMmapPolicyInfos(AudioMMapPolicyType::DEFAULT, &mmapPolicyInfos).isOk()) {
1226 mIsMmapSupported = false;
1227 } else {
1228 mIsMmapSupported =
1229 std::find_if(mmapPolicyInfos.begin(), mmapPolicyInfos.end(), [](const auto& info) {
1230 return info.mmapPolicy == AudioMMapPolicy::AUTO ||
1231 info.mmapPolicy == AudioMMapPolicy::ALWAYS;
1232 }) != mmapPolicyInfos.end();
1233 }
1234 return mIsMmapSupported.value();
1235}
1236
jiabin253bd322023-01-25 23:57:31 +00001237ndk::ScopedAStatus Module::populateConnectedDevicePort(AudioPort* audioPort __unused) {
1238 LOG(DEBUG) << __func__ << ": do nothing and return ok";
1239 return ndk::ScopedAStatus::ok();
1240}
1241
1242ndk::ScopedAStatus Module::checkAudioPatchEndpointsMatch(
1243 const std::vector<AudioPortConfig*>& sources __unused,
1244 const std::vector<AudioPortConfig*>& sinks __unused) {
1245 LOG(DEBUG) << __func__ << ": do nothing and return ok";
1246 return ndk::ScopedAStatus::ok();
1247}
1248
Mikhail Naganovdf5adfd2021-11-11 22:09:22 +00001249} // namespace aidl::android::hardware::audio::core