audio HAL: initial VTS tests am: e5d747e908
am: 4c6e690f4f
am: 29326f2ca5
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2190588 Change-Id: I91c453a695220a91cd6165655989091190446b0b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
c7fe9f1fde
4 changed files with 1520 additions and 0 deletions
32
audio/aidl/vts/Android.bp
Normal file
32
audio/aidl/vts/Android.bp
Normal file
|
@ -0,0 +1,32 @@
|
|||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalAudioCoreTargetTest",
|
||||
defaults: [
|
||||
"VtsHalTargetTestDefaults",
|
||||
"use_libaidlvintf_gtest_helper_static",
|
||||
],
|
||||
srcs: [
|
||||
"ModuleConfig.cpp",
|
||||
"VtsHalAudioCoreTargetTest.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbinder",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.audio.common-V1-cpp",
|
||||
"android.hardware.audio.core-V1-cpp",
|
||||
"android.media.audio.common.types-V1-cpp",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
}
|
330
audio/aidl/vts/ModuleConfig.cpp
Normal file
330
audio/aidl/vts/ModuleConfig.cpp
Normal file
|
@ -0,0 +1,330 @@
|
|||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <android/media/audio/common/AudioIoFlags.h>
|
||||
#include <android/media/audio/common/AudioOutputFlags.h>
|
||||
|
||||
#include "ModuleConfig.h"
|
||||
|
||||
using namespace android;
|
||||
|
||||
using android::hardware::audio::core::IModule;
|
||||
using android::media::audio::common::AudioChannelLayout;
|
||||
using android::media::audio::common::AudioFormatDescription;
|
||||
using android::media::audio::common::AudioFormatType;
|
||||
using android::media::audio::common::AudioIoFlags;
|
||||
using android::media::audio::common::AudioOutputFlags;
|
||||
using android::media::audio::common::AudioPort;
|
||||
using android::media::audio::common::AudioPortConfig;
|
||||
using android::media::audio::common::AudioPortExt;
|
||||
using android::media::audio::common::AudioProfile;
|
||||
using android::media::audio::common::Int;
|
||||
|
||||
template <typename T>
|
||||
auto findById(const std::vector<T>& v, int32_t id) {
|
||||
return std::find_if(v.begin(), v.end(), [&](const auto& p) { return p.id == id; });
|
||||
}
|
||||
|
||||
ModuleConfig::ModuleConfig(IModule* module) {
|
||||
mStatus = module->getAudioPorts(&mPorts);
|
||||
if (!mStatus.isOk()) return;
|
||||
for (const auto& port : mPorts) {
|
||||
if (port.ext.getTag() != AudioPortExt::Tag::device) continue;
|
||||
const auto& devicePort = port.ext.get<AudioPortExt::Tag::device>();
|
||||
const bool isInput = port.flags.getTag() == AudioIoFlags::Tag::input;
|
||||
if (devicePort.device.type.connection.empty()) {
|
||||
// Permanently attached device.
|
||||
if (isInput) {
|
||||
mAttachedSourceDevicePorts.insert(port.id);
|
||||
} else {
|
||||
mAttachedSinkDevicePorts.insert(port.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mStatus.isOk()) return;
|
||||
mStatus = module->getAudioRoutes(&mRoutes);
|
||||
if (!mStatus.isOk()) return;
|
||||
mStatus = module->getAudioPortConfigs(&mInitialConfigs);
|
||||
}
|
||||
|
||||
std::vector<AudioPort> ModuleConfig::getInputMixPorts() const {
|
||||
std::vector<AudioPort> result;
|
||||
std::copy_if(mPorts.begin(), mPorts.end(), std::back_inserter(result), [](const auto& port) {
|
||||
return port.ext.getTag() == AudioPortExt::Tag::mix &&
|
||||
port.flags.getTag() == AudioIoFlags::Tag::input;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<AudioPort> ModuleConfig::getOutputMixPorts() const {
|
||||
std::vector<AudioPort> result;
|
||||
std::copy_if(mPorts.begin(), mPorts.end(), std::back_inserter(result), [](const auto& port) {
|
||||
return port.ext.getTag() == AudioPortExt::Tag::mix &&
|
||||
port.flags.getTag() == AudioIoFlags::Tag::output;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<AudioPort> ModuleConfig::getAttachedSinkDevicesPortsForMixPort(
|
||||
const AudioPort& mixPort) const {
|
||||
std::vector<AudioPort> result;
|
||||
for (const auto& route : mRoutes) {
|
||||
if (mAttachedSinkDevicePorts.count(route.sinkPortId) != 0 &&
|
||||
std::find(route.sourcePortIds.begin(), route.sourcePortIds.end(), mixPort.id) !=
|
||||
route.sourcePortIds.end()) {
|
||||
const auto devicePortIt = findById<AudioPort>(mPorts, route.sinkPortId);
|
||||
if (devicePortIt != mPorts.end()) result.push_back(*devicePortIt);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<AudioPort> ModuleConfig::getAttachedSourceDevicesPortsForMixPort(
|
||||
const AudioPort& mixPort) const {
|
||||
std::vector<AudioPort> result;
|
||||
for (const auto& route : mRoutes) {
|
||||
if (route.sinkPortId == mixPort.id) {
|
||||
for (const auto srcId : route.sourcePortIds) {
|
||||
if (mAttachedSourceDevicePorts.count(srcId) != 0) {
|
||||
const auto devicePortIt = findById<AudioPort>(mPorts, srcId);
|
||||
if (devicePortIt != mPorts.end()) result.push_back(*devicePortIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<AudioPort> ModuleConfig::getSourceMixPortForAttachedDevice() const {
|
||||
for (const auto& route : mRoutes) {
|
||||
if (mAttachedSinkDevicePorts.count(route.sinkPortId) != 0) {
|
||||
const auto mixPortIt = findById<AudioPort>(mPorts, route.sourcePortIds[0]);
|
||||
if (mixPortIt != mPorts.end()) return *mixPortIt;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<ModuleConfig::SrcSinkPair> ModuleConfig::getNonRoutableSrcSinkPair(
|
||||
bool isInput) const {
|
||||
const auto mixPorts = getMixPorts(isInput);
|
||||
std::set<std::pair<int32_t, int32_t>> allowedRoutes;
|
||||
for (const auto& route : mRoutes) {
|
||||
for (const auto srcPortId : route.sourcePortIds) {
|
||||
allowedRoutes.emplace(std::make_pair(srcPortId, route.sinkPortId));
|
||||
}
|
||||
}
|
||||
auto make_pair = [isInput](auto& device, auto& mix) {
|
||||
return isInput ? std::make_pair(device, mix) : std::make_pair(mix, device);
|
||||
};
|
||||
for (const auto portId : isInput ? mAttachedSourceDevicePorts : mAttachedSinkDevicePorts) {
|
||||
const auto devicePortIt = findById<AudioPort>(mPorts, portId);
|
||||
if (devicePortIt == mPorts.end()) continue;
|
||||
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
|
||||
for (const auto& mixPort : mixPorts) {
|
||||
if (std::find(allowedRoutes.begin(), allowedRoutes.end(),
|
||||
make_pair(portId, mixPort.id)) == allowedRoutes.end()) {
|
||||
auto mixPortConfig = getSingleConfigForMixPort(isInput, mixPort);
|
||||
if (mixPortConfig.has_value()) {
|
||||
return make_pair(devicePortConfig, mixPortConfig.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<ModuleConfig::SrcSinkPair> ModuleConfig::getRoutableSrcSinkPair(bool isInput) const {
|
||||
if (isInput) {
|
||||
for (const auto& route : mRoutes) {
|
||||
auto srcPortIdIt = std::find_if(
|
||||
route.sourcePortIds.begin(), route.sourcePortIds.end(),
|
||||
[&](const auto& portId) { return mAttachedSourceDevicePorts.count(portId); });
|
||||
if (srcPortIdIt == route.sourcePortIds.end()) continue;
|
||||
const auto devicePortIt = findById<AudioPort>(mPorts, *srcPortIdIt);
|
||||
const auto mixPortIt = findById<AudioPort>(mPorts, route.sinkPortId);
|
||||
if (devicePortIt == mPorts.end() || mixPortIt == mPorts.end()) continue;
|
||||
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
|
||||
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
|
||||
if (!mixPortConfig.has_value()) continue;
|
||||
return std::make_pair(devicePortConfig, mixPortConfig.value());
|
||||
}
|
||||
} else {
|
||||
for (const auto& route : mRoutes) {
|
||||
if (mAttachedSinkDevicePorts.count(route.sinkPortId) == 0) continue;
|
||||
const auto mixPortIt = findById<AudioPort>(mPorts, route.sourcePortIds[0]);
|
||||
const auto devicePortIt = findById<AudioPort>(mPorts, route.sinkPortId);
|
||||
if (devicePortIt == mPorts.end() || mixPortIt == mPorts.end()) continue;
|
||||
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
|
||||
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
|
||||
if (!mixPortConfig.has_value()) continue;
|
||||
return std::make_pair(mixPortConfig.value(), devicePortConfig);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<ModuleConfig::SrcSinkGroup> ModuleConfig::getRoutableSrcSinkGroups(bool isInput) const {
|
||||
std::vector<SrcSinkGroup> result;
|
||||
if (isInput) {
|
||||
for (const auto& route : mRoutes) {
|
||||
std::vector<int32_t> srcPortIds;
|
||||
std::copy_if(route.sourcePortIds.begin(), route.sourcePortIds.end(),
|
||||
std::back_inserter(srcPortIds), [&](const auto& portId) {
|
||||
return mAttachedSourceDevicePorts.count(portId);
|
||||
});
|
||||
if (srcPortIds.empty()) continue;
|
||||
const auto mixPortIt = findById<AudioPort>(mPorts, route.sinkPortId);
|
||||
if (mixPortIt == mPorts.end()) continue;
|
||||
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
|
||||
if (!mixPortConfig.has_value()) continue;
|
||||
std::vector<SrcSinkPair> pairs;
|
||||
for (const auto srcPortId : srcPortIds) {
|
||||
const auto devicePortIt = findById<AudioPort>(mPorts, srcPortId);
|
||||
if (devicePortIt == mPorts.end()) continue;
|
||||
// Using all configs for every source would be too much.
|
||||
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
|
||||
pairs.emplace_back(devicePortConfig, mixPortConfig.value());
|
||||
}
|
||||
if (!pairs.empty()) {
|
||||
result.emplace_back(route, std::move(pairs));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const auto& route : mRoutes) {
|
||||
if (mAttachedSinkDevicePorts.count(route.sinkPortId) == 0) continue;
|
||||
const auto devicePortIt = findById<AudioPort>(mPorts, route.sinkPortId);
|
||||
if (devicePortIt == mPorts.end()) continue;
|
||||
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
|
||||
std::vector<SrcSinkPair> pairs;
|
||||
for (const auto srcPortId : route.sourcePortIds) {
|
||||
const auto mixPortIt = findById<AudioPort>(mPorts, srcPortId);
|
||||
if (mixPortIt == mPorts.end()) continue;
|
||||
// Using all configs for every source would be too much.
|
||||
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
|
||||
if (mixPortConfig.has_value()) {
|
||||
pairs.emplace_back(mixPortConfig.value(), devicePortConfig);
|
||||
}
|
||||
}
|
||||
if (!pairs.empty()) {
|
||||
result.emplace_back(route, std::move(pairs));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static std::vector<AudioPortConfig> combineAudioConfigs(const AudioPort& port,
|
||||
const AudioProfile& profile) {
|
||||
std::vector<AudioPortConfig> configs;
|
||||
configs.reserve(profile.channelMasks.size() * profile.sampleRates.size());
|
||||
for (auto channelMask : profile.channelMasks) {
|
||||
for (auto sampleRate : profile.sampleRates) {
|
||||
AudioPortConfig config{};
|
||||
config.portId = port.id;
|
||||
Int sr;
|
||||
sr.value = sampleRate;
|
||||
config.sampleRate = sr;
|
||||
config.channelMask = channelMask;
|
||||
config.format = profile.format;
|
||||
config.ext = port.ext;
|
||||
configs.push_back(config);
|
||||
}
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
std::vector<AudioPortConfig> ModuleConfig::generateInputAudioMixPortConfigs(
|
||||
const std::vector<AudioPort>& ports, bool singleProfile) const {
|
||||
std::vector<AudioPortConfig> result;
|
||||
for (const auto& mixPort : ports) {
|
||||
if (getAttachedSourceDevicesPortsForMixPort(mixPort).empty()) {
|
||||
continue; // no attached devices
|
||||
}
|
||||
for (const auto& profile : mixPort.profiles) {
|
||||
if (profile.format.type == AudioFormatType::DEFAULT || profile.sampleRates.empty() ||
|
||||
profile.channelMasks.empty()) {
|
||||
continue; // dynamic profile
|
||||
}
|
||||
auto configs = combineAudioConfigs(mixPort, profile);
|
||||
for (auto& config : configs) {
|
||||
config.flags = mixPort.flags;
|
||||
result.push_back(config);
|
||||
if (singleProfile) return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static std::tuple<AudioIoFlags, bool> generateOutFlags(const AudioPort& mixPort) {
|
||||
static const AudioIoFlags offloadFlags = AudioIoFlags::make<AudioIoFlags::Tag::output>(
|
||||
(1 << static_cast<int>(AudioOutputFlags::COMPRESS_OFFLOAD)) |
|
||||
(1 << static_cast<int>(AudioOutputFlags::DIRECT)));
|
||||
const bool isOffload = (mixPort.flags.get<AudioIoFlags::Tag::output>() &
|
||||
(1 << static_cast<int>(AudioOutputFlags::COMPRESS_OFFLOAD))) != 0;
|
||||
return {isOffload ? offloadFlags : mixPort.flags, isOffload};
|
||||
}
|
||||
|
||||
std::vector<AudioPortConfig> ModuleConfig::generateOutputAudioMixPortConfigs(
|
||||
const std::vector<AudioPort>& ports, bool singleProfile) const {
|
||||
std::vector<AudioPortConfig> result;
|
||||
for (const auto& mixPort : ports) {
|
||||
if (getAttachedSinkDevicesPortsForMixPort(mixPort).empty()) {
|
||||
continue; // no attached devices
|
||||
}
|
||||
auto [flags, isOffload] = generateOutFlags(mixPort);
|
||||
(void)isOffload;
|
||||
for (const auto& profile : mixPort.profiles) {
|
||||
if (profile.format.type == AudioFormatType::DEFAULT) continue;
|
||||
auto configs = combineAudioConfigs(mixPort, profile);
|
||||
for (auto& config : configs) {
|
||||
// Some combinations of flags declared in the config file require special
|
||||
// treatment.
|
||||
// if (isOffload) {
|
||||
// config.offloadInfo.info(generateOffloadInfo(config.base));
|
||||
// }
|
||||
config.flags = flags;
|
||||
result.push_back(config);
|
||||
if (singleProfile) return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<AudioPortConfig> ModuleConfig::generateAudioDevicePortConfigs(
|
||||
const std::vector<AudioPort>& ports, bool singleProfile) const {
|
||||
std::vector<AudioPortConfig> result;
|
||||
for (const auto& devicePort : ports) {
|
||||
const size_t resultSizeBefore = result.size();
|
||||
for (const auto& profile : devicePort.profiles) {
|
||||
auto configs = combineAudioConfigs(devicePort, profile);
|
||||
result.insert(result.end(), configs.begin(), configs.end());
|
||||
if (singleProfile && !result.empty()) return result;
|
||||
}
|
||||
if (resultSizeBefore == result.size()) {
|
||||
AudioPortConfig empty;
|
||||
empty.portId = devicePort.id;
|
||||
empty.ext = devicePort.ext;
|
||||
result.push_back(empty);
|
||||
}
|
||||
if (singleProfile) return result;
|
||||
}
|
||||
return result;
|
||||
}
|
131
audio/aidl/vts/ModuleConfig.h
Normal file
131
audio/aidl/vts/ModuleConfig.h
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Copyright (C) 2022 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
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <android/hardware/audio/core/AudioRoute.h>
|
||||
#include <android/hardware/audio/core/IModule.h>
|
||||
#include <android/media/audio/common/AudioPort.h>
|
||||
#include <binder/Status.h>
|
||||
|
||||
class ModuleConfig {
|
||||
public:
|
||||
using SrcSinkPair = std::pair<android::media::audio::common::AudioPortConfig,
|
||||
android::media::audio::common::AudioPortConfig>;
|
||||
using SrcSinkGroup =
|
||||
std::pair<android::hardware::audio::core::AudioRoute, std::vector<SrcSinkPair>>;
|
||||
|
||||
explicit ModuleConfig(android::hardware::audio::core::IModule* module);
|
||||
android::binder::Status getStatus() const { return mStatus; }
|
||||
std::string getError() const { return mStatus.toString8().c_str(); }
|
||||
|
||||
std::vector<android::media::audio::common::AudioPort> getInputMixPorts() const;
|
||||
std::vector<android::media::audio::common::AudioPort> getOutputMixPorts() const;
|
||||
std::vector<android::media::audio::common::AudioPort> getMixPorts(bool isInput) const {
|
||||
return isInput ? getInputMixPorts() : getOutputMixPorts();
|
||||
}
|
||||
|
||||
std::vector<android::media::audio::common::AudioPort> getAttachedDevicesPortsForMixPort(
|
||||
bool isInput, const android::media::audio::common::AudioPort& mixPort) const {
|
||||
return isInput ? getAttachedSourceDevicesPortsForMixPort(mixPort)
|
||||
: getAttachedSinkDevicesPortsForMixPort(mixPort);
|
||||
}
|
||||
std::vector<android::media::audio::common::AudioPort> getAttachedSinkDevicesPortsForMixPort(
|
||||
const android::media::audio::common::AudioPort& mixPort) const;
|
||||
std::vector<android::media::audio::common::AudioPort> getAttachedSourceDevicesPortsForMixPort(
|
||||
const android::media::audio::common::AudioPort& mixPort) const;
|
||||
std::optional<android::media::audio::common::AudioPort> getSourceMixPortForAttachedDevice()
|
||||
const;
|
||||
|
||||
std::optional<SrcSinkPair> getNonRoutableSrcSinkPair(bool isInput) const;
|
||||
std::optional<SrcSinkPair> getRoutableSrcSinkPair(bool isInput) const;
|
||||
std::vector<SrcSinkGroup> getRoutableSrcSinkGroups(bool isInput) const;
|
||||
|
||||
std::vector<android::media::audio::common::AudioPortConfig> getPortConfigsForMixPorts() const {
|
||||
auto inputs = generateInputAudioMixPortConfigs(getInputMixPorts(), false);
|
||||
auto outputs = generateOutputAudioMixPortConfigs(getOutputMixPorts(), false);
|
||||
inputs.insert(inputs.end(), outputs.begin(), outputs.end());
|
||||
return inputs;
|
||||
}
|
||||
std::vector<android::media::audio::common::AudioPortConfig> getPortConfigsForMixPorts(
|
||||
bool isInput) const {
|
||||
return isInput ? generateInputAudioMixPortConfigs(getInputMixPorts(), false)
|
||||
: generateOutputAudioMixPortConfigs(getOutputMixPorts(), false);
|
||||
}
|
||||
std::vector<android::media::audio::common::AudioPortConfig> getPortConfigsForMixPorts(
|
||||
bool isInput, const android::media::audio::common::AudioPort& port) const {
|
||||
return isInput ? generateInputAudioMixPortConfigs({port}, false)
|
||||
: generateOutputAudioMixPortConfigs({port}, false);
|
||||
}
|
||||
std::optional<android::media::audio::common::AudioPortConfig> getSingleConfigForMixPort(
|
||||
bool isInput) const {
|
||||
const auto config = isInput ? generateInputAudioMixPortConfigs(getInputMixPorts(), true)
|
||||
: generateOutputAudioMixPortConfigs(getOutputMixPorts(), true);
|
||||
// TODO: Avoid returning configs for offload since they require an extra
|
||||
// argument to openOutputStream.
|
||||
if (!config.empty()) {
|
||||
return *config.begin();
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
std::optional<android::media::audio::common::AudioPortConfig> getSingleConfigForMixPort(
|
||||
bool isInput, const android::media::audio::common::AudioPort& port) const {
|
||||
const auto config = isInput ? generateInputAudioMixPortConfigs({port}, true)
|
||||
: generateOutputAudioMixPortConfigs({port}, true);
|
||||
if (!config.empty()) {
|
||||
return *config.begin();
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
android::media::audio::common::AudioPortConfig getSingleConfigForDevicePort(
|
||||
const android::media::audio::common::AudioPort& port) const {
|
||||
for (const auto& config : mInitialConfigs) {
|
||||
if (config.portId == port.id) return config;
|
||||
}
|
||||
const auto config = generateAudioDevicePortConfigs({port}, true);
|
||||
return *config.begin();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<android::media::audio::common::AudioPortConfig> generateInputAudioMixPortConfigs(
|
||||
const std::vector<android::media::audio::common::AudioPort>& ports,
|
||||
bool singleProfile) const;
|
||||
std::vector<android::media::audio::common::AudioPortConfig> generateOutputAudioMixPortConfigs(
|
||||
const std::vector<android::media::audio::common::AudioPort>& ports,
|
||||
bool singleProfile) const;
|
||||
|
||||
// Unlike MixPorts, the generator for DevicePorts always returns a non-empty
|
||||
// vector for a non-empty input port list. If there are no profiles in the
|
||||
// port, a vector with an empty config is returned.
|
||||
std::vector<android::media::audio::common::AudioPortConfig> generateAudioDevicePortConfigs(
|
||||
const std::vector<android::media::audio::common::AudioPort>& ports,
|
||||
bool singleProfile) const;
|
||||
|
||||
android::binder::Status mStatus = android::binder::Status::ok();
|
||||
std::vector<android::media::audio::common::AudioPort> mPorts;
|
||||
std::vector<android::media::audio::common::AudioPortConfig> mInitialConfigs;
|
||||
std::set<int32_t> mAttachedSinkDevicePorts;
|
||||
std::set<int32_t> mAttachedSourceDevicePorts;
|
||||
std::vector<android::hardware::audio::core::AudioRoute> mRoutes;
|
||||
};
|
1027
audio/aidl/vts/VtsHalAudioCoreTargetTest.cpp
Normal file
1027
audio/aidl/vts/VtsHalAudioCoreTargetTest.cpp
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue