Merge changes from topic "revert-2770886-AidlAudioHalModuleConfig-FQCMWOWMCH" into main am: 03a2fbc6a3 am: fb1d459f09 am: 9868600b48 am: 9ed9a05578 am: 0cfcc0f2f9

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2786757

Change-Id: I6b5a7c2db6ee69a63abc9897bb9c1716157f641e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mikhail Naganov
2023-10-14 01:35:36 +00:00
committed by Automerger Merge Worker
25 changed files with 412 additions and 795 deletions

View File

@@ -25,7 +25,6 @@
#include <android/binder_ibinder_platform.h>
#include <error/expected_utils.h>
#include "core-impl/Configuration.h"
#include "core-impl/Module.h"
#include "core-impl/ModuleBluetooth.h"
#include "core-impl/ModulePrimary.h"
@@ -133,36 +132,21 @@ bool findAudioProfile(const AudioPort& port, const AudioFormatDescription& forma
} // namespace
// static
std::shared_ptr<Module> Module::createInstance(Type type, std::unique_ptr<Configuration>&& config) {
std::shared_ptr<Module> Module::createInstance(Type type) {
switch (type) {
case Type::DEFAULT:
return ndk::SharedRefBase::make<ModulePrimary>(std::move(config));
return ndk::SharedRefBase::make<ModulePrimary>();
case Type::R_SUBMIX:
return ndk::SharedRefBase::make<ModuleRemoteSubmix>(std::move(config));
return ndk::SharedRefBase::make<ModuleRemoteSubmix>();
case Type::STUB:
return ndk::SharedRefBase::make<ModuleStub>(std::move(config));
return ndk::SharedRefBase::make<ModuleStub>();
case Type::USB:
return ndk::SharedRefBase::make<ModuleUsb>(std::move(config));
return ndk::SharedRefBase::make<ModuleUsb>();
case Type::BLUETOOTH:
return ndk::SharedRefBase::make<ModuleBluetooth>(std::move(config));
return ndk::SharedRefBase::make<ModuleBluetooth>();
}
}
// static
std::optional<Module::Type> Module::typeFromString(const std::string& type) {
if (type == "default")
return Module::Type::DEFAULT;
else if (type == "r_submix")
return Module::Type::R_SUBMIX;
else if (type == "stub")
return Module::Type::STUB;
else if (type == "usb")
return Module::Type::USB;
else if (type == "bluetooth")
return Module::Type::BLUETOOTH;
return {};
}
std::ostream& operator<<(std::ostream& os, Module::Type t) {
switch (t) {
case Module::Type::DEFAULT:
@@ -337,8 +321,26 @@ std::set<int32_t> Module::portIdsFromPortConfigIds(C portConfigIds) {
return result;
}
std::unique_ptr<Module::Configuration> Module::initializeConfig() {
return internal::getConfiguration(getType());
std::unique_ptr<internal::Configuration> Module::initializeConfig() {
std::unique_ptr<internal::Configuration> config;
switch (getType()) {
case Type::DEFAULT:
config = std::move(internal::getPrimaryConfiguration());
break;
case Type::R_SUBMIX:
config = std::move(internal::getRSubmixConfiguration());
break;
case Type::STUB:
config = std::move(internal::getStubConfiguration());
break;
case Type::USB:
config = std::move(internal::getUsbConfiguration());
break;
case Type::BLUETOOTH:
config = std::move(internal::getBluetoothConfiguration());
break;
}
return config;
}
std::vector<AudioRoute*> Module::getAudioRoutesForAudioPortImpl(int32_t portId) {
@@ -353,7 +355,7 @@ std::vector<AudioRoute*> Module::getAudioRoutesForAudioPortImpl(int32_t portId)
return result;
}
Module::Configuration& Module::getConfig() {
internal::Configuration& Module::getConfig() {
if (!mConfig) {
mConfig = std::move(initializeConfig());
}
@@ -800,7 +802,7 @@ ndk::ScopedAStatus Module::openInputStream(const OpenInputStreamArguments& in_ar
context.fillDescriptor(&_aidl_return->desc);
std::shared_ptr<StreamIn> stream;
RETURN_STATUS_IF_ERROR(createInputStream(std::move(context), in_args.sinkMetadata,
getConfig().microphones, &stream));
mConfig->microphones, &stream));
StreamWrapper streamWrapper(stream);
if (auto patchIt = mPatches.find(in_args.portConfigId); patchIt != mPatches.end()) {
RETURN_STATUS_IF_ERROR(