2021-11-11 22:09:22 +00:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-09-12 22:57:14 +00:00
|
|
|
#include <Utils.h>
|
2021-11-11 22:09:22 +00:00
|
|
|
#include <aidl/android/media/audio/common/AudioChannelLayout.h>
|
|
|
|
|
#include <aidl/android/media/audio/common/AudioDeviceType.h>
|
2022-05-02 22:52:13 +00:00
|
|
|
#include <aidl/android/media/audio/common/AudioFormatDescription.h>
|
2021-11-11 22:09:22 +00:00
|
|
|
#include <aidl/android/media/audio/common/AudioFormatType.h>
|
|
|
|
|
#include <aidl/android/media/audio/common/AudioIoFlags.h>
|
|
|
|
|
#include <aidl/android/media/audio/common/AudioOutputFlags.h>
|
2022-06-17 21:41:19 +00:00
|
|
|
#include <media/stagefright/foundation/MediaDefs.h>
|
2021-11-11 22:09:22 +00:00
|
|
|
|
|
|
|
|
#include "core-impl/Configuration.h"
|
|
|
|
|
|
2023-03-09 18:19:01 -08:00
|
|
|
using aidl::android::hardware::audio::common::makeBitPositionFlagMask;
|
2021-11-11 22:09:22 +00:00
|
|
|
using aidl::android::media::audio::common::AudioChannelLayout;
|
2022-05-02 22:52:13 +00:00
|
|
|
using aidl::android::media::audio::common::AudioDeviceDescription;
|
2021-11-11 22:09:22 +00:00
|
|
|
using aidl::android::media::audio::common::AudioDeviceType;
|
|
|
|
|
using aidl::android::media::audio::common::AudioFormatDescription;
|
|
|
|
|
using aidl::android::media::audio::common::AudioFormatType;
|
|
|
|
|
using aidl::android::media::audio::common::AudioGainConfig;
|
|
|
|
|
using aidl::android::media::audio::common::AudioIoFlags;
|
|
|
|
|
using aidl::android::media::audio::common::AudioOutputFlags;
|
|
|
|
|
using aidl::android::media::audio::common::AudioPort;
|
|
|
|
|
using aidl::android::media::audio::common::AudioPortConfig;
|
|
|
|
|
using aidl::android::media::audio::common::AudioPortDeviceExt;
|
|
|
|
|
using aidl::android::media::audio::common::AudioPortExt;
|
|
|
|
|
using aidl::android::media::audio::common::AudioPortMixExt;
|
|
|
|
|
using aidl::android::media::audio::common::AudioProfile;
|
|
|
|
|
using aidl::android::media::audio::common::Int;
|
2023-02-09 17:52:50 -08:00
|
|
|
using aidl::android::media::audio::common::MicrophoneInfo;
|
2021-11-11 22:09:22 +00:00
|
|
|
using aidl::android::media::audio::common::PcmType;
|
|
|
|
|
|
|
|
|
|
namespace aidl::android::hardware::audio::core::internal {
|
|
|
|
|
|
2022-06-17 21:41:19 +00:00
|
|
|
static void fillProfile(AudioProfile* profile, const std::vector<int32_t>& channelLayouts,
|
|
|
|
|
const std::vector<int32_t>& sampleRates) {
|
|
|
|
|
for (auto layout : channelLayouts) {
|
|
|
|
|
profile->channelMasks.push_back(
|
|
|
|
|
AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout));
|
|
|
|
|
}
|
|
|
|
|
profile->sampleRates.insert(profile->sampleRates.end(), sampleRates.begin(), sampleRates.end());
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 22:09:22 +00:00
|
|
|
static AudioProfile createProfile(PcmType pcmType, const std::vector<int32_t>& channelLayouts,
|
|
|
|
|
const std::vector<int32_t>& sampleRates) {
|
|
|
|
|
AudioProfile profile;
|
|
|
|
|
profile.format.type = AudioFormatType::PCM;
|
|
|
|
|
profile.format.pcm = pcmType;
|
2022-06-17 21:41:19 +00:00
|
|
|
fillProfile(&profile, channelLayouts, sampleRates);
|
|
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static AudioProfile createProfile(const std::string& encodingType,
|
|
|
|
|
const std::vector<int32_t>& channelLayouts,
|
|
|
|
|
const std::vector<int32_t>& sampleRates) {
|
|
|
|
|
AudioProfile profile;
|
|
|
|
|
profile.format.encoding = encodingType;
|
|
|
|
|
fillProfile(&profile, channelLayouts, sampleRates);
|
2021-11-11 22:09:22 +00:00
|
|
|
return profile;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-02 22:52:13 +00:00
|
|
|
static AudioPortExt createDeviceExt(AudioDeviceType devType, int32_t flags,
|
|
|
|
|
std::string connection = "") {
|
2021-11-11 22:09:22 +00:00
|
|
|
AudioPortDeviceExt deviceExt;
|
|
|
|
|
deviceExt.device.type.type = devType;
|
2023-01-27 16:08:29 -08:00
|
|
|
if (devType == AudioDeviceType::IN_MICROPHONE && connection.empty()) {
|
|
|
|
|
deviceExt.device.address = "bottom";
|
|
|
|
|
} else if (devType == AudioDeviceType::IN_MICROPHONE_BACK && connection.empty()) {
|
|
|
|
|
deviceExt.device.address = "back";
|
|
|
|
|
}
|
2022-05-02 22:52:13 +00:00
|
|
|
deviceExt.device.type.connection = std::move(connection);
|
2021-11-11 22:09:22 +00:00
|
|
|
deviceExt.flags = flags;
|
|
|
|
|
return AudioPortExt::make<AudioPortExt::Tag::device>(deviceExt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static AudioPortExt createPortMixExt(int32_t maxOpenStreamCount, int32_t maxActiveStreamCount) {
|
|
|
|
|
AudioPortMixExt mixExt;
|
|
|
|
|
mixExt.maxOpenStreamCount = maxOpenStreamCount;
|
|
|
|
|
mixExt.maxActiveStreamCount = maxActiveStreamCount;
|
|
|
|
|
return AudioPortExt::make<AudioPortExt::Tag::mix>(mixExt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static AudioPort createPort(int32_t id, const std::string& name, int32_t flags, bool isInput,
|
|
|
|
|
const AudioPortExt& ext) {
|
|
|
|
|
AudioPort port;
|
|
|
|
|
port.id = id;
|
|
|
|
|
port.name = name;
|
|
|
|
|
port.flags = isInput ? AudioIoFlags::make<AudioIoFlags::Tag::input>(flags)
|
|
|
|
|
: AudioIoFlags::make<AudioIoFlags::Tag::output>(flags);
|
|
|
|
|
port.ext = ext;
|
|
|
|
|
return port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static AudioPortConfig createPortConfig(int32_t id, int32_t portId, PcmType pcmType, int32_t layout,
|
|
|
|
|
int32_t sampleRate, int32_t flags, bool isInput,
|
|
|
|
|
const AudioPortExt& ext) {
|
|
|
|
|
AudioPortConfig config;
|
|
|
|
|
config.id = id;
|
|
|
|
|
config.portId = portId;
|
|
|
|
|
config.sampleRate = Int{.value = sampleRate};
|
|
|
|
|
config.channelMask = AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout);
|
|
|
|
|
config.format = AudioFormatDescription{.type = AudioFormatType::PCM, .pcm = pcmType};
|
|
|
|
|
config.gain = AudioGainConfig();
|
|
|
|
|
config.flags = isInput ? AudioIoFlags::make<AudioIoFlags::Tag::input>(flags)
|
|
|
|
|
: AudioIoFlags::make<AudioIoFlags::Tag::output>(flags);
|
|
|
|
|
config.ext = ext;
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 00:33:47 +00:00
|
|
|
static AudioRoute createRoute(const std::vector<AudioPort>& sources, const AudioPort& sink) {
|
2021-11-11 22:09:22 +00:00
|
|
|
AudioRoute route;
|
2022-12-09 00:33:47 +00:00
|
|
|
route.sinkPortId = sink.id;
|
|
|
|
|
std::transform(sources.begin(), sources.end(), std::back_inserter(route.sourcePortIds),
|
|
|
|
|
[](const auto& port) { return port.id; });
|
2021-11-11 22:09:22 +00:00
|
|
|
return route;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 00:33:47 +00:00
|
|
|
// Primary (default) configuration:
|
2022-05-02 22:52:13 +00:00
|
|
|
//
|
|
|
|
|
// Device ports:
|
2022-12-09 00:33:47 +00:00
|
|
|
// * "Speaker", OUT_SPEAKER, default
|
2022-05-02 22:52:13 +00:00
|
|
|
// - no profiles specified
|
2023-07-24 14:51:36 -07:00
|
|
|
// * "Built-In Mic", IN_MICROPHONE, default
|
2022-05-02 22:52:13 +00:00
|
|
|
// - no profiles specified
|
2022-12-09 00:33:47 +00:00
|
|
|
// * "Telephony Tx", OUT_TELEPHONY_TX
|
|
|
|
|
// - no profiles specified
|
|
|
|
|
// * "Telephony Rx", IN_TELEPHONY_RX
|
|
|
|
|
// - no profiles specified
|
|
|
|
|
// * "FM Tuner", IN_FM_TUNER
|
|
|
|
|
// - no profiles specified
|
2022-05-02 22:52:13 +00:00
|
|
|
//
|
|
|
|
|
// Mix ports:
|
|
|
|
|
// * "primary output", PRIMARY, 1 max open, 1 max active stream
|
2022-12-09 00:33:47 +00:00
|
|
|
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
2023-07-24 14:51:36 -07:00
|
|
|
// * "primary input", 1 max open, 1 max active stream
|
|
|
|
|
// - profile PCM 16-bit; MONO, STEREO;
|
|
|
|
|
// 8000, 11025, 16000, 32000, 44100, 48000
|
2022-12-09 00:33:47 +00:00
|
|
|
// * "telephony_tx", 1 max open, 1 max active stream
|
|
|
|
|
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// * "telephony_rx", 1 max open, 1 max active stream
|
|
|
|
|
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// * "fm_tuner", 1 max open, 1 max active stream
|
|
|
|
|
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
2022-05-02 22:52:13 +00:00
|
|
|
//
|
|
|
|
|
// Routes:
|
2023-07-24 14:51:36 -07:00
|
|
|
// "primary out" -> "Speaker"
|
|
|
|
|
// "Built-In Mic" -> "primary input"
|
2022-12-09 00:33:47 +00:00
|
|
|
// "Telephony Rx" -> "telephony_rx"
|
2023-07-24 14:51:36 -07:00
|
|
|
// "telephony_tx" -> "Telephony Tx"
|
2022-12-09 00:33:47 +00:00
|
|
|
// "FM Tuner" -> "fm_tuner"
|
2022-05-02 22:52:13 +00:00
|
|
|
//
|
|
|
|
|
// Initial port configs:
|
2023-07-24 14:51:36 -07:00
|
|
|
// * "Speaker" device port: PCM 16-bit; STEREO; 48000
|
|
|
|
|
// * "Built-In Mic" device port: PCM 16-bit; MONO; 48000
|
|
|
|
|
// * "Telephony Tx" device port: PCM 16-bit; MONO; 48000
|
|
|
|
|
// * "Telephony Rx" device port: PCM 16-bit; MONO; 48000
|
|
|
|
|
// * "FM Tuner" device port: PCM 16-bit; STEREO; 48000
|
2022-05-02 22:52:13 +00:00
|
|
|
//
|
2022-12-09 00:33:47 +00:00
|
|
|
std::unique_ptr<Configuration> getPrimaryConfiguration() {
|
|
|
|
|
static const Configuration configuration = []() {
|
2022-05-02 22:52:13 +00:00
|
|
|
const std::vector<AudioProfile> standardPcmAudioProfiles = {
|
|
|
|
|
createProfile(PcmType::INT_16_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
2022-12-09 00:33:47 +00:00
|
|
|
{8000, 11025, 16000, 32000, 44100, 48000})};
|
2021-11-11 22:09:22 +00:00
|
|
|
Configuration c;
|
|
|
|
|
|
2022-12-09 00:33:47 +00:00
|
|
|
// Device ports
|
|
|
|
|
|
|
|
|
|
AudioPort speakerOutDevice =
|
|
|
|
|
createPort(c.nextPortId++, "Speaker", 0, false,
|
2021-11-11 22:09:22 +00:00
|
|
|
createDeviceExt(AudioDeviceType::OUT_SPEAKER,
|
|
|
|
|
1 << AudioPortDeviceExt::FLAG_INDEX_DEFAULT_DEVICE));
|
2022-12-09 00:33:47 +00:00
|
|
|
c.ports.push_back(speakerOutDevice);
|
2022-05-02 22:52:13 +00:00
|
|
|
c.initialConfigs.push_back(
|
2023-07-24 14:51:36 -07:00
|
|
|
createPortConfig(speakerOutDevice.id, speakerOutDevice.id, PcmType::INT_16_BIT,
|
2022-05-02 22:52:13 +00:00
|
|
|
AudioChannelLayout::LAYOUT_STEREO, 48000, 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_SPEAKER, 0)));
|
2021-11-11 22:09:22 +00:00
|
|
|
|
2022-12-09 00:33:47 +00:00
|
|
|
AudioPort micInDevice =
|
2023-07-24 14:51:36 -07:00
|
|
|
createPort(c.nextPortId++, "Built-In Mic", 0, true,
|
2022-12-09 00:33:47 +00:00
|
|
|
createDeviceExt(AudioDeviceType::IN_MICROPHONE,
|
|
|
|
|
1 << AudioPortDeviceExt::FLAG_INDEX_DEFAULT_DEVICE));
|
|
|
|
|
c.ports.push_back(micInDevice);
|
|
|
|
|
c.initialConfigs.push_back(
|
2023-07-24 14:51:36 -07:00
|
|
|
createPortConfig(micInDevice.id, micInDevice.id, PcmType::INT_16_BIT,
|
2022-12-09 00:33:47 +00:00
|
|
|
AudioChannelLayout::LAYOUT_MONO, 48000, 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_MICROPHONE, 0)));
|
|
|
|
|
|
|
|
|
|
AudioPort telephonyTxOutDevice =
|
|
|
|
|
createPort(c.nextPortId++, "Telephony Tx", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_TELEPHONY_TX, 0));
|
|
|
|
|
c.ports.push_back(telephonyTxOutDevice);
|
|
|
|
|
c.initialConfigs.push_back(
|
|
|
|
|
createPortConfig(telephonyTxOutDevice.id, telephonyTxOutDevice.id,
|
2023-07-24 14:51:36 -07:00
|
|
|
PcmType::INT_16_BIT, AudioChannelLayout::LAYOUT_MONO, 48000, 0,
|
2022-12-09 00:33:47 +00:00
|
|
|
false, createDeviceExt(AudioDeviceType::OUT_TELEPHONY_TX, 0)));
|
|
|
|
|
|
|
|
|
|
AudioPort telephonyRxInDevice =
|
|
|
|
|
createPort(c.nextPortId++, "Telephony Rx", 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_TELEPHONY_RX, 0));
|
|
|
|
|
c.ports.push_back(telephonyRxInDevice);
|
|
|
|
|
c.initialConfigs.push_back(
|
|
|
|
|
createPortConfig(telephonyRxInDevice.id, telephonyRxInDevice.id,
|
2023-07-24 14:51:36 -07:00
|
|
|
PcmType::INT_16_BIT, AudioChannelLayout::LAYOUT_MONO, 48000, 0,
|
2022-12-09 00:33:47 +00:00
|
|
|
true, createDeviceExt(AudioDeviceType::IN_TELEPHONY_RX, 0)));
|
|
|
|
|
|
|
|
|
|
AudioPort fmTunerInDevice = createPort(c.nextPortId++, "FM Tuner", 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_FM_TUNER, 0));
|
|
|
|
|
c.ports.push_back(fmTunerInDevice);
|
|
|
|
|
c.initialConfigs.push_back(
|
2023-07-24 14:51:36 -07:00
|
|
|
createPortConfig(fmTunerInDevice.id, fmTunerInDevice.id, PcmType::INT_16_BIT,
|
2022-12-09 00:33:47 +00:00
|
|
|
AudioChannelLayout::LAYOUT_STEREO, 48000, 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_FM_TUNER, 0)));
|
|
|
|
|
|
|
|
|
|
// Mix ports
|
|
|
|
|
|
2021-11-11 22:09:22 +00:00
|
|
|
AudioPort primaryOutMix = createPort(c.nextPortId++, "primary output",
|
2022-09-12 22:57:14 +00:00
|
|
|
makeBitPositionFlagMask(AudioOutputFlags::PRIMARY),
|
2021-11-11 22:09:22 +00:00
|
|
|
false, createPortMixExt(1, 1));
|
2022-05-02 22:52:13 +00:00
|
|
|
primaryOutMix.profiles.insert(primaryOutMix.profiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.end());
|
2021-11-11 22:09:22 +00:00
|
|
|
c.ports.push_back(primaryOutMix);
|
|
|
|
|
|
|
|
|
|
AudioPort primaryInMix =
|
2023-07-24 14:51:36 -07:00
|
|
|
createPort(c.nextPortId++, "primary input", 0, true, createPortMixExt(1, 1));
|
2021-11-11 22:09:22 +00:00
|
|
|
primaryInMix.profiles.push_back(
|
|
|
|
|
createProfile(PcmType::INT_16_BIT,
|
2023-07-24 14:51:36 -07:00
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{8000, 11025, 16000, 32000, 44100, 48000}));
|
2021-11-11 22:09:22 +00:00
|
|
|
c.ports.push_back(primaryInMix);
|
|
|
|
|
|
2022-12-09 00:33:47 +00:00
|
|
|
AudioPort telephonyTxOutMix =
|
|
|
|
|
createPort(c.nextPortId++, "telephony_tx", 0, false, createPortMixExt(1, 1));
|
|
|
|
|
telephonyTxOutMix.profiles.insert(telephonyTxOutMix.profiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.end());
|
|
|
|
|
c.ports.push_back(telephonyTxOutMix);
|
|
|
|
|
|
|
|
|
|
AudioPort telephonyRxInMix =
|
|
|
|
|
createPort(c.nextPortId++, "telephony_rx", 0, true, createPortMixExt(1, 1));
|
|
|
|
|
telephonyRxInMix.profiles.insert(telephonyRxInMix.profiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.end());
|
|
|
|
|
c.ports.push_back(telephonyRxInMix);
|
|
|
|
|
|
|
|
|
|
AudioPort fmTunerInMix =
|
|
|
|
|
createPort(c.nextPortId++, "fm_tuner", 0, true, createPortMixExt(1, 1));
|
|
|
|
|
fmTunerInMix.profiles.insert(fmTunerInMix.profiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.end());
|
|
|
|
|
c.ports.push_back(fmTunerInMix);
|
|
|
|
|
|
2023-07-24 14:51:36 -07:00
|
|
|
c.routes.push_back(createRoute({primaryOutMix}, speakerOutDevice));
|
2023-07-11 17:24:08 -07:00
|
|
|
c.routes.push_back(createRoute({micInDevice}, primaryInMix));
|
2022-12-09 00:33:47 +00:00
|
|
|
c.routes.push_back(createRoute({telephonyRxInDevice}, telephonyRxInMix));
|
2023-07-24 14:51:36 -07:00
|
|
|
c.routes.push_back(createRoute({telephonyTxOutMix}, telephonyTxOutDevice));
|
2022-12-09 00:33:47 +00:00
|
|
|
c.routes.push_back(createRoute({fmTunerInDevice}, fmTunerInMix));
|
|
|
|
|
|
|
|
|
|
c.portConfigs.insert(c.portConfigs.end(), c.initialConfigs.begin(), c.initialConfigs.end());
|
|
|
|
|
|
|
|
|
|
MicrophoneInfo mic;
|
|
|
|
|
mic.id = "mic";
|
|
|
|
|
mic.device = micInDevice.ext.get<AudioPortExt::Tag::device>().device;
|
|
|
|
|
mic.group = 0;
|
|
|
|
|
mic.indexInTheGroup = 0;
|
|
|
|
|
c.microphones = std::vector<MicrophoneInfo>{mic};
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}();
|
|
|
|
|
return std::make_unique<Configuration>(configuration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remote Submix configuration:
|
|
|
|
|
//
|
|
|
|
|
// Device ports:
|
|
|
|
|
// * "Remote Submix Out", OUT_SUBMIX
|
2023-08-10 12:47:44 +08:00
|
|
|
// - no profiles specified
|
2022-12-09 00:33:47 +00:00
|
|
|
// * "Remote Submix In", IN_SUBMIX
|
2023-08-10 12:47:44 +08:00
|
|
|
// - no profiles specified
|
2022-12-09 00:33:47 +00:00
|
|
|
//
|
|
|
|
|
// Mix ports:
|
2023-08-10 12:47:44 +08:00
|
|
|
// * "r_submix output", unlimited max open, unlimited max active stream
|
|
|
|
|
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// - profile PCM 24-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// - profile PCM 32-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// - profile PCM 32-bit float; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// * "r_submix input", unlimited max open, unlimited max active stream
|
|
|
|
|
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// - profile PCM 24-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// - profile PCM 32-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
|
|
|
|
// - profile PCM 32-bit float; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
2022-12-09 00:33:47 +00:00
|
|
|
//
|
|
|
|
|
// Routes:
|
|
|
|
|
// "r_submix output" -> "Remote Submix Out"
|
|
|
|
|
// "Remote Submix In" -> "r_submix input"
|
|
|
|
|
//
|
|
|
|
|
std::unique_ptr<Configuration> getRSubmixConfiguration() {
|
|
|
|
|
static const Configuration configuration = []() {
|
|
|
|
|
Configuration c;
|
2023-08-10 12:47:44 +08:00
|
|
|
const std::vector<AudioProfile> standardPcmAudioProfiles{
|
|
|
|
|
createProfile(PcmType::FLOAT_32_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{8000, 11025, 16000, 32000, 44100, 48000}),
|
|
|
|
|
createProfile(PcmType::INT_32_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{8000, 11025, 16000, 32000, 44100, 48000}),
|
|
|
|
|
createProfile(PcmType::INT_24_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{8000, 11025, 16000, 32000, 44100, 48000}),
|
|
|
|
|
createProfile(PcmType::INT_16_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{8000, 11025, 16000, 32000, 44100, 48000})};
|
2022-12-09 00:33:47 +00:00
|
|
|
|
|
|
|
|
// Device ports
|
|
|
|
|
|
2023-05-12 13:51:06 -07:00
|
|
|
AudioPort rsubmixOutDevice =
|
|
|
|
|
createPort(c.nextPortId++, "Remote Submix Out", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_VIRTUAL));
|
2022-12-09 00:33:47 +00:00
|
|
|
c.ports.push_back(rsubmixOutDevice);
|
2023-08-10 12:47:44 +08:00
|
|
|
c.connectedProfiles[rsubmixOutDevice.id] = standardPcmAudioProfiles;
|
2021-11-11 22:09:22 +00:00
|
|
|
|
2023-08-10 12:47:44 +08:00
|
|
|
AudioPort rsubmixInDevice =
|
|
|
|
|
createPort(c.nextPortId++, "Remote Submix In", 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_SUBMIX, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_VIRTUAL));
|
2022-12-09 00:33:47 +00:00
|
|
|
c.ports.push_back(rsubmixInDevice);
|
2023-08-10 12:47:44 +08:00
|
|
|
c.connectedProfiles[rsubmixInDevice.id] = standardPcmAudioProfiles;
|
2021-11-11 22:09:22 +00:00
|
|
|
|
2022-12-09 00:33:47 +00:00
|
|
|
// Mix ports
|
2022-05-02 22:52:13 +00:00
|
|
|
|
2022-12-09 00:33:47 +00:00
|
|
|
AudioPort rsubmixOutMix =
|
2023-08-10 12:47:44 +08:00
|
|
|
createPort(c.nextPortId++, "r_submix output", 0, false, createPortMixExt(0, 0));
|
|
|
|
|
rsubmixOutMix.profiles = standardPcmAudioProfiles;
|
2022-12-09 00:33:47 +00:00
|
|
|
c.ports.push_back(rsubmixOutMix);
|
|
|
|
|
|
|
|
|
|
AudioPort rsubmixInMix =
|
2023-08-10 12:47:44 +08:00
|
|
|
createPort(c.nextPortId++, "r_submix input", 0, true, createPortMixExt(0, 0));
|
|
|
|
|
rsubmixInMix.profiles = standardPcmAudioProfiles;
|
2022-12-09 00:33:47 +00:00
|
|
|
c.ports.push_back(rsubmixInMix);
|
|
|
|
|
|
|
|
|
|
c.routes.push_back(createRoute({rsubmixOutMix}, rsubmixOutDevice));
|
|
|
|
|
c.routes.push_back(createRoute({rsubmixInDevice}, rsubmixInMix));
|
2021-11-11 22:09:22 +00:00
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}();
|
2022-12-09 00:33:47 +00:00
|
|
|
return std::make_unique<Configuration>(configuration);
|
2021-11-11 22:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 19:07:15 +00:00
|
|
|
// Usb configuration:
|
|
|
|
|
//
|
|
|
|
|
// Device ports:
|
2023-07-11 17:24:08 -07:00
|
|
|
// * "USB Device Out", OUT_DEVICE, CONNECTION_USB
|
|
|
|
|
// - no profiles specified
|
2023-01-20 19:07:15 +00:00
|
|
|
// * "USB Headset Out", OUT_HEADSET, CONNECTION_USB
|
|
|
|
|
// - no profiles specified
|
2023-07-11 17:24:08 -07:00
|
|
|
// * "USB Device In", IN_DEVICE, CONNECTION_USB
|
|
|
|
|
// - no profiles specified
|
2023-01-20 19:07:15 +00:00
|
|
|
// * "USB Headset In", IN_HEADSET, CONNECTION_USB
|
|
|
|
|
// - no profiles specified
|
|
|
|
|
//
|
|
|
|
|
// Mix ports:
|
2023-07-11 17:24:08 -07:00
|
|
|
// * "usb_device output", 1 max open, 1 max active stream
|
2023-01-20 19:07:15 +00:00
|
|
|
// - no profiles specified
|
2023-07-11 17:24:08 -07:00
|
|
|
// * "usb_device input", 1 max open, 1 max active stream
|
2023-01-20 19:07:15 +00:00
|
|
|
// - no profiles specified
|
|
|
|
|
//
|
2023-07-11 17:24:08 -07:00
|
|
|
// Routes:
|
|
|
|
|
// * "usb_device output" -> "USB Device Out"
|
|
|
|
|
// * "usb_device output" -> "USB Headset Out"
|
|
|
|
|
// * "USB Device In", "USB Headset In" -> "usb_device input"
|
|
|
|
|
//
|
2023-01-20 19:07:15 +00:00
|
|
|
// Profiles for device port connected state:
|
2023-07-11 17:24:08 -07:00
|
|
|
// * "USB Device Out", "USB Headset Out":
|
2023-01-20 19:07:15 +00:00
|
|
|
// - profile PCM 16-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
|
|
|
|
// - profile PCM 24-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
2023-07-11 17:24:08 -07:00
|
|
|
// * "USB Device In", "USB Headset In":
|
2023-01-20 19:07:15 +00:00
|
|
|
// - profile PCM 16-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
|
|
|
|
// - profile PCM 24-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
|
|
|
|
//
|
|
|
|
|
std::unique_ptr<Configuration> getUsbConfiguration() {
|
|
|
|
|
static const Configuration configuration = []() {
|
|
|
|
|
const std::vector<AudioProfile> standardPcmAudioProfiles = {
|
|
|
|
|
createProfile(PcmType::INT_16_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
|
|
|
|
|
AudioChannelLayout::INDEX_MASK_1, AudioChannelLayout::INDEX_MASK_2},
|
|
|
|
|
{44100, 48000}),
|
|
|
|
|
createProfile(PcmType::INT_24_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
|
|
|
|
|
AudioChannelLayout::INDEX_MASK_1, AudioChannelLayout::INDEX_MASK_2},
|
|
|
|
|
{44100, 48000})};
|
|
|
|
|
Configuration c;
|
|
|
|
|
|
|
|
|
|
// Device ports
|
|
|
|
|
|
2023-07-11 17:24:08 -07:00
|
|
|
AudioPort usbOutDevice =
|
|
|
|
|
createPort(c.nextPortId++, "USB Device Out", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_DEVICE, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_USB));
|
|
|
|
|
c.ports.push_back(usbOutDevice);
|
|
|
|
|
c.connectedProfiles[usbOutDevice.id] = standardPcmAudioProfiles;
|
|
|
|
|
|
2023-01-20 19:07:15 +00:00
|
|
|
AudioPort usbOutHeadset =
|
|
|
|
|
createPort(c.nextPortId++, "USB Headset Out", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_HEADSET, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_USB));
|
|
|
|
|
c.ports.push_back(usbOutHeadset);
|
|
|
|
|
c.connectedProfiles[usbOutHeadset.id] = standardPcmAudioProfiles;
|
|
|
|
|
|
2023-07-11 17:24:08 -07:00
|
|
|
AudioPort usbInDevice = createPort(c.nextPortId++, "USB Device In", 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_DEVICE, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_USB));
|
|
|
|
|
c.ports.push_back(usbInDevice);
|
|
|
|
|
c.connectedProfiles[usbInDevice.id] = standardPcmAudioProfiles;
|
|
|
|
|
|
2023-01-20 19:07:15 +00:00
|
|
|
AudioPort usbInHeadset =
|
|
|
|
|
createPort(c.nextPortId++, "USB Headset In", 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_HEADSET, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_USB));
|
|
|
|
|
c.ports.push_back(usbInHeadset);
|
|
|
|
|
c.connectedProfiles[usbInHeadset.id] = standardPcmAudioProfiles;
|
|
|
|
|
|
|
|
|
|
// Mix ports
|
|
|
|
|
|
2023-07-11 17:24:08 -07:00
|
|
|
AudioPort usbDeviceOutMix =
|
|
|
|
|
createPort(c.nextPortId++, "usb_device output", 0, false, createPortMixExt(1, 1));
|
|
|
|
|
c.ports.push_back(usbDeviceOutMix);
|
|
|
|
|
|
|
|
|
|
AudioPort usbDeviceInMix =
|
|
|
|
|
createPort(c.nextPortId++, "usb_device input", 0, true, createPortMixExt(1, 1));
|
|
|
|
|
c.ports.push_back(usbDeviceInMix);
|
|
|
|
|
|
|
|
|
|
c.routes.push_back(createRoute({usbDeviceOutMix}, usbOutDevice));
|
|
|
|
|
c.routes.push_back(createRoute({usbDeviceOutMix}, usbOutHeadset));
|
|
|
|
|
c.routes.push_back(createRoute({usbInDevice, usbInHeadset}, usbDeviceInMix));
|
2023-01-20 19:07:15 +00:00
|
|
|
|
2023-07-11 17:24:08 -07:00
|
|
|
return c;
|
|
|
|
|
}();
|
|
|
|
|
return std::make_unique<Configuration>(configuration);
|
|
|
|
|
}
|
2023-01-20 19:07:15 +00:00
|
|
|
|
2023-07-11 17:24:08 -07:00
|
|
|
// Stub configuration:
|
|
|
|
|
//
|
|
|
|
|
// Device ports:
|
|
|
|
|
// * "Test Out", OUT_AFE_PROXY
|
|
|
|
|
// - no profiles specified
|
|
|
|
|
// * "Test In", IN_AFE_PROXY
|
|
|
|
|
// - no profiles specified
|
|
|
|
|
//
|
|
|
|
|
// Mix ports:
|
|
|
|
|
// * "test output", 1 max open, 1 max active stream
|
|
|
|
|
// - profile PCM 24-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
|
audio: Ensure proper priority and scheduler for service threads
Change audio worker threads priority to ..._URGENT_AUDIO to match
the coupled thread in the audio flinger.
Set SCHED_FIFO scheduler for FAST threads (also to match AF fast
mixer/capture threads). In order to enable that, grand SYS_NICE
capability to the HAL service process and provide "getTid"
function in the StreamWorker class. For testing, add a "FAST"
output to the "stub" module in the HAL configuration.
Bug: 286914845
Test: atest libaudioaidlcommon_test
Test: atest VtsHalAudioCoreTargetTest
Test: adb shell ps -A -T -o PID,TID,NI,PCY,PRI,RTPRIO,SCHED,CMD
for the HAL service process during VTS test. For regular
"reader"/"writer" threads should see 'NI 19, PRI 38',
for FAST "writer" should see 'NI -19, PRI 43, RTPRIO 3, SCH 1'
Change-Id: Iab7e21ebc139ff11cf9b7f4a1645960db8dadd43
2023-08-07 17:11:14 -07:00
|
|
|
// * "test fast output", 1 max open, 1 max active stream
|
|
|
|
|
// - profile PCM 24-bit; STEREO; 44100, 48000
|
|
|
|
|
// * "test compressed offload", DIRECT|COMPRESS_OFFLOAD|NON_BLOCKING, 1 max open, 1 max active
|
|
|
|
|
// stream
|
2023-07-11 17:24:08 -07:00
|
|
|
// - profile MP3; MONO, STEREO; 44100, 48000
|
|
|
|
|
// * "test input", 2 max open, 2 max active streams
|
|
|
|
|
// - profile PCM 24-bit; MONO, STEREO, FRONT_BACK;
|
2023-07-24 14:51:36 -07:00
|
|
|
// 8000, 11025, 16000, 22050, 32000, 44100, 48000
|
2023-07-11 17:24:08 -07:00
|
|
|
//
|
|
|
|
|
// Routes:
|
audio: Ensure proper priority and scheduler for service threads
Change audio worker threads priority to ..._URGENT_AUDIO to match
the coupled thread in the audio flinger.
Set SCHED_FIFO scheduler for FAST threads (also to match AF fast
mixer/capture threads). In order to enable that, grand SYS_NICE
capability to the HAL service process and provide "getTid"
function in the StreamWorker class. For testing, add a "FAST"
output to the "stub" module in the HAL configuration.
Bug: 286914845
Test: atest libaudioaidlcommon_test
Test: atest VtsHalAudioCoreTargetTest
Test: adb shell ps -A -T -o PID,TID,NI,PCY,PRI,RTPRIO,SCHED,CMD
for the HAL service process during VTS test. For regular
"reader"/"writer" threads should see 'NI 19, PRI 38',
for FAST "writer" should see 'NI -19, PRI 43, RTPRIO 3, SCH 1'
Change-Id: Iab7e21ebc139ff11cf9b7f4a1645960db8dadd43
2023-08-07 17:11:14 -07:00
|
|
|
// "test output", "test fast output", "test compressed offload" -> "Test Out"
|
2023-07-11 17:24:08 -07:00
|
|
|
// "Test In" -> "test input"
|
|
|
|
|
//
|
|
|
|
|
// Initial port configs:
|
|
|
|
|
// * "Test Out" device port: PCM 24-bit; STEREO; 48000
|
|
|
|
|
// * "Test In" device port: PCM 24-bit; MONO; 48000
|
|
|
|
|
//
|
|
|
|
|
std::unique_ptr<Configuration> getStubConfiguration() {
|
|
|
|
|
static const Configuration configuration = []() {
|
|
|
|
|
Configuration c;
|
|
|
|
|
|
|
|
|
|
// Device ports
|
|
|
|
|
|
|
|
|
|
AudioPort testOutDevice = createPort(c.nextPortId++, "Test Out", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_AFE_PROXY, 0));
|
|
|
|
|
c.ports.push_back(testOutDevice);
|
|
|
|
|
c.initialConfigs.push_back(
|
|
|
|
|
createPortConfig(testOutDevice.id, testOutDevice.id, PcmType::INT_24_BIT,
|
|
|
|
|
AudioChannelLayout::LAYOUT_STEREO, 48000, 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_AFE_PROXY, 0)));
|
|
|
|
|
|
|
|
|
|
AudioPort testInDevice = createPort(c.nextPortId++, "Test In", 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_AFE_PROXY, 0));
|
|
|
|
|
c.ports.push_back(testInDevice);
|
|
|
|
|
c.initialConfigs.push_back(
|
|
|
|
|
createPortConfig(testInDevice.id, testInDevice.id, PcmType::INT_24_BIT,
|
|
|
|
|
AudioChannelLayout::LAYOUT_MONO, 48000, 0, true,
|
|
|
|
|
createDeviceExt(AudioDeviceType::IN_AFE_PROXY, 0)));
|
|
|
|
|
|
|
|
|
|
// Mix ports
|
|
|
|
|
|
|
|
|
|
AudioPort testOutMix =
|
|
|
|
|
createPort(c.nextPortId++, "test output", 0, false, createPortMixExt(1, 1));
|
|
|
|
|
testOutMix.profiles.push_back(
|
|
|
|
|
createProfile(PcmType::INT_24_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{8000, 11025, 16000, 32000, 44100, 48000}));
|
|
|
|
|
c.ports.push_back(testOutMix);
|
|
|
|
|
|
audio: Ensure proper priority and scheduler for service threads
Change audio worker threads priority to ..._URGENT_AUDIO to match
the coupled thread in the audio flinger.
Set SCHED_FIFO scheduler for FAST threads (also to match AF fast
mixer/capture threads). In order to enable that, grand SYS_NICE
capability to the HAL service process and provide "getTid"
function in the StreamWorker class. For testing, add a "FAST"
output to the "stub" module in the HAL configuration.
Bug: 286914845
Test: atest libaudioaidlcommon_test
Test: atest VtsHalAudioCoreTargetTest
Test: adb shell ps -A -T -o PID,TID,NI,PCY,PRI,RTPRIO,SCHED,CMD
for the HAL service process during VTS test. For regular
"reader"/"writer" threads should see 'NI 19, PRI 38',
for FAST "writer" should see 'NI -19, PRI 43, RTPRIO 3, SCH 1'
Change-Id: Iab7e21ebc139ff11cf9b7f4a1645960db8dadd43
2023-08-07 17:11:14 -07:00
|
|
|
AudioPort testFastOutMix = createPort(c.nextPortId++, "test fast output",
|
|
|
|
|
makeBitPositionFlagMask({AudioOutputFlags::FAST}),
|
|
|
|
|
false, createPortMixExt(1, 1));
|
|
|
|
|
testFastOutMix.profiles.push_back(createProfile(
|
|
|
|
|
PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {44100, 48000}));
|
|
|
|
|
c.ports.push_back(testFastOutMix);
|
|
|
|
|
|
2023-07-11 17:24:08 -07:00
|
|
|
AudioPort compressedOffloadOutMix =
|
audio: Ensure proper priority and scheduler for service threads
Change audio worker threads priority to ..._URGENT_AUDIO to match
the coupled thread in the audio flinger.
Set SCHED_FIFO scheduler for FAST threads (also to match AF fast
mixer/capture threads). In order to enable that, grand SYS_NICE
capability to the HAL service process and provide "getTid"
function in the StreamWorker class. For testing, add a "FAST"
output to the "stub" module in the HAL configuration.
Bug: 286914845
Test: atest libaudioaidlcommon_test
Test: atest VtsHalAudioCoreTargetTest
Test: adb shell ps -A -T -o PID,TID,NI,PCY,PRI,RTPRIO,SCHED,CMD
for the HAL service process during VTS test. For regular
"reader"/"writer" threads should see 'NI 19, PRI 38',
for FAST "writer" should see 'NI -19, PRI 43, RTPRIO 3, SCH 1'
Change-Id: Iab7e21ebc139ff11cf9b7f4a1645960db8dadd43
2023-08-07 17:11:14 -07:00
|
|
|
createPort(c.nextPortId++, "test compressed offload",
|
2023-07-11 17:24:08 -07:00
|
|
|
makeBitPositionFlagMask({AudioOutputFlags::DIRECT,
|
|
|
|
|
AudioOutputFlags::COMPRESS_OFFLOAD,
|
|
|
|
|
AudioOutputFlags::NON_BLOCKING}),
|
|
|
|
|
false, createPortMixExt(1, 1));
|
|
|
|
|
compressedOffloadOutMix.profiles.push_back(
|
|
|
|
|
createProfile(::android::MEDIA_MIMETYPE_AUDIO_MPEG,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{44100, 48000}));
|
|
|
|
|
c.ports.push_back(compressedOffloadOutMix);
|
|
|
|
|
|
|
|
|
|
AudioPort testInMIx =
|
|
|
|
|
createPort(c.nextPortId++, "test input", 0, true, createPortMixExt(2, 2));
|
|
|
|
|
testInMIx.profiles.push_back(
|
|
|
|
|
createProfile(PcmType::INT_16_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
|
|
|
|
|
AudioChannelLayout::LAYOUT_FRONT_BACK},
|
2023-07-24 14:51:36 -07:00
|
|
|
{8000, 11025, 16000, 22050, 32000, 44100, 48000}));
|
2023-07-11 17:24:08 -07:00
|
|
|
testInMIx.profiles.push_back(
|
|
|
|
|
createProfile(PcmType::INT_24_BIT,
|
|
|
|
|
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
|
|
|
|
|
AudioChannelLayout::LAYOUT_FRONT_BACK},
|
2023-07-24 14:51:36 -07:00
|
|
|
{8000, 11025, 16000, 22050, 32000, 44100, 48000}));
|
2023-07-11 17:24:08 -07:00
|
|
|
c.ports.push_back(testInMIx);
|
|
|
|
|
|
audio: Ensure proper priority and scheduler for service threads
Change audio worker threads priority to ..._URGENT_AUDIO to match
the coupled thread in the audio flinger.
Set SCHED_FIFO scheduler for FAST threads (also to match AF fast
mixer/capture threads). In order to enable that, grand SYS_NICE
capability to the HAL service process and provide "getTid"
function in the StreamWorker class. For testing, add a "FAST"
output to the "stub" module in the HAL configuration.
Bug: 286914845
Test: atest libaudioaidlcommon_test
Test: atest VtsHalAudioCoreTargetTest
Test: adb shell ps -A -T -o PID,TID,NI,PCY,PRI,RTPRIO,SCHED,CMD
for the HAL service process during VTS test. For regular
"reader"/"writer" threads should see 'NI 19, PRI 38',
for FAST "writer" should see 'NI -19, PRI 43, RTPRIO 3, SCH 1'
Change-Id: Iab7e21ebc139ff11cf9b7f4a1645960db8dadd43
2023-08-07 17:11:14 -07:00
|
|
|
c.routes.push_back(
|
|
|
|
|
createRoute({testOutMix, testFastOutMix, compressedOffloadOutMix}, testOutDevice));
|
2023-07-11 17:24:08 -07:00
|
|
|
c.routes.push_back(createRoute({testInDevice}, testInMIx));
|
|
|
|
|
|
|
|
|
|
c.portConfigs.insert(c.portConfigs.end(), c.initialConfigs.begin(), c.initialConfigs.end());
|
2023-01-20 19:07:15 +00:00
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}();
|
|
|
|
|
return std::make_unique<Configuration>(configuration);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-26 13:13:35 -07:00
|
|
|
// Bluetooth configuration:
|
|
|
|
|
//
|
|
|
|
|
// Device ports:
|
|
|
|
|
// * "BT A2DP Out", OUT_DEVICE, CONNECTION_BT_A2DP
|
|
|
|
|
// - profile PCM 16-bit; STEREO; 44100, 48000, 88200, 96000
|
2023-07-24 14:51:36 -07:00
|
|
|
// * "BT A2DP Headphones", OUT_HEADPHONE, CONNECTION_BT_A2DP
|
2023-07-26 13:13:35 -07:00
|
|
|
// - profile PCM 16-bit; STEREO; 44100, 48000, 88200, 96000
|
|
|
|
|
// * "BT A2DP Speaker", OUT_SPEAKER, CONNECTION_BT_A2DP
|
|
|
|
|
// - profile PCM 16-bit; STEREO; 44100, 48000, 88200, 96000
|
|
|
|
|
// * "BT Hearing Aid Out", OUT_HEARING_AID, CONNECTION_WIRELESS
|
|
|
|
|
// - no profiles specified
|
|
|
|
|
//
|
|
|
|
|
// Mix ports:
|
|
|
|
|
// * "a2dp output", 1 max open, 1 max active stream
|
|
|
|
|
// - no profiles specified
|
|
|
|
|
// * "hearing aid output", 1 max open, 1 max active stream
|
|
|
|
|
// - profile PCM 16-bit; STEREO; 16000, 24000
|
|
|
|
|
//
|
|
|
|
|
// Routes:
|
|
|
|
|
// "a2dp output" -> "BT A2DP Out"
|
|
|
|
|
// "a2dp output" -> "BT A2DP Headphones"
|
|
|
|
|
// "a2dp output" -> "BT A2DP Speaker"
|
|
|
|
|
// "hearing aid output" -> "BT Hearing Aid Out"
|
|
|
|
|
//
|
|
|
|
|
std::unique_ptr<Configuration> getBluetoothConfiguration() {
|
|
|
|
|
static const Configuration configuration = []() {
|
|
|
|
|
const std::vector<AudioProfile> standardPcmAudioProfiles = {
|
|
|
|
|
createProfile(PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO},
|
|
|
|
|
{44100, 48000, 88200, 96000})};
|
|
|
|
|
Configuration c;
|
|
|
|
|
|
|
|
|
|
// Device ports
|
|
|
|
|
AudioPort btOutDevice =
|
|
|
|
|
createPort(c.nextPortId++, "BT A2DP Out", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_DEVICE, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_BT_A2DP));
|
2023-07-24 14:51:36 -07:00
|
|
|
btOutDevice.profiles.insert(btOutDevice.profiles.begin(), standardPcmAudioProfiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.end());
|
2023-07-26 13:13:35 -07:00
|
|
|
c.ports.push_back(btOutDevice);
|
|
|
|
|
c.connectedProfiles[btOutDevice.id] = standardPcmAudioProfiles;
|
|
|
|
|
|
|
|
|
|
AudioPort btOutHeadphone =
|
|
|
|
|
createPort(c.nextPortId++, "BT A2DP Headphones", 0, false,
|
2023-07-24 14:51:36 -07:00
|
|
|
createDeviceExt(AudioDeviceType::OUT_HEADPHONE, 0,
|
2023-07-26 13:13:35 -07:00
|
|
|
AudioDeviceDescription::CONNECTION_BT_A2DP));
|
2023-07-24 14:51:36 -07:00
|
|
|
btOutHeadphone.profiles.insert(btOutHeadphone.profiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.end());
|
2023-07-26 13:13:35 -07:00
|
|
|
c.ports.push_back(btOutHeadphone);
|
|
|
|
|
c.connectedProfiles[btOutHeadphone.id] = standardPcmAudioProfiles;
|
|
|
|
|
|
|
|
|
|
AudioPort btOutSpeaker =
|
|
|
|
|
createPort(c.nextPortId++, "BT A2DP Speaker", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_SPEAKER, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_BT_A2DP));
|
2023-07-24 14:51:36 -07:00
|
|
|
btOutSpeaker.profiles.insert(btOutSpeaker.profiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.begin(),
|
|
|
|
|
standardPcmAudioProfiles.end());
|
2023-07-26 13:13:35 -07:00
|
|
|
c.ports.push_back(btOutSpeaker);
|
|
|
|
|
c.connectedProfiles[btOutSpeaker.id] = standardPcmAudioProfiles;
|
|
|
|
|
|
|
|
|
|
AudioPort btOutHearingAid =
|
|
|
|
|
createPort(c.nextPortId++, "BT Hearing Aid Out", 0, false,
|
|
|
|
|
createDeviceExt(AudioDeviceType::OUT_HEARING_AID, 0,
|
|
|
|
|
AudioDeviceDescription::CONNECTION_WIRELESS));
|
|
|
|
|
c.ports.push_back(btOutHearingAid);
|
|
|
|
|
c.connectedProfiles[btOutHearingAid.id] = std::vector<AudioProfile>(
|
|
|
|
|
{createProfile(PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {16000})});
|
|
|
|
|
|
|
|
|
|
// Mix ports
|
2023-07-24 14:51:36 -07:00
|
|
|
AudioPort btOutMix =
|
|
|
|
|
createPort(c.nextPortId++, "a2dp output", 0, false, createPortMixExt(1, 1));
|
|
|
|
|
c.ports.push_back(btOutMix);
|
2023-07-26 13:13:35 -07:00
|
|
|
|
2023-07-24 14:51:36 -07:00
|
|
|
AudioPort btHearingOutMix =
|
|
|
|
|
createPort(c.nextPortId++, "hearing aid output", 0, false, createPortMixExt(1, 1));
|
|
|
|
|
btHearingOutMix.profiles.push_back(createProfile(
|
2023-07-26 13:13:35 -07:00
|
|
|
PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {16000, 24000}));
|
2023-07-24 14:51:36 -07:00
|
|
|
c.ports.push_back(btHearingOutMix);
|
2023-07-26 13:13:35 -07:00
|
|
|
|
2023-07-24 14:51:36 -07:00
|
|
|
c.routes.push_back(createRoute({btOutMix}, btOutDevice));
|
|
|
|
|
c.routes.push_back(createRoute({btOutMix}, btOutHeadphone));
|
|
|
|
|
c.routes.push_back(createRoute({btOutMix}, btOutSpeaker));
|
|
|
|
|
c.routes.push_back(createRoute({btHearingOutMix}, btOutHearingAid));
|
2023-07-26 13:13:35 -07:00
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}();
|
|
|
|
|
return std::make_unique<Configuration>(configuration);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 22:09:22 +00:00
|
|
|
} // namespace aidl::android::hardware::audio::core::internal
|