am: f21a5174bc
Change-Id: I55fc3e1d8020e1e788ac91f1f1f8b700c6fbcb36
gugelfrei
commit
2350fffd76
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
#define LOG_TAG "AudioPort"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <media/AudioPort.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
void AudioPort::importAudioPort(const sp<AudioPort>& port, bool force __unused)
|
||||
{
|
||||
for (const auto& profileToImport : port->mProfiles) {
|
||||
// Import only valid port, i.e. valid format, non empty rates and channels masks
|
||||
if (!profileToImport->isValid()) {
|
||||
continue;
|
||||
}
|
||||
if (std::find_if(mProfiles.begin(), mProfiles.end(),
|
||||
[profileToImport](const auto &profile) {
|
||||
return *profile == *profileToImport; }) == mProfiles.end()) {
|
||||
addAudioProfile(profileToImport);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioPort::toAudioPort(struct audio_port *port) const {
|
||||
// TODO: update this function once audio_port structure reflects the new profile definition.
|
||||
// For compatibility reason: flatening the AudioProfile into audio_port structure.
|
||||
FormatSet flatenedFormats;
|
||||
SampleRateSet flatenedRates;
|
||||
ChannelMaskSet flatenedChannels;
|
||||
for (const auto& profile : mProfiles) {
|
||||
if (profile->isValid()) {
|
||||
audio_format_t formatToExport = profile->getFormat();
|
||||
const SampleRateSet &ratesToExport = profile->getSampleRates();
|
||||
const ChannelMaskSet &channelsToExport = profile->getChannels();
|
||||
|
||||
flatenedFormats.insert(formatToExport);
|
||||
flatenedRates.insert(ratesToExport.begin(), ratesToExport.end());
|
||||
flatenedChannels.insert(channelsToExport.begin(), channelsToExport.end());
|
||||
|
||||
if (flatenedRates.size() > AUDIO_PORT_MAX_SAMPLING_RATES ||
|
||||
flatenedChannels.size() > AUDIO_PORT_MAX_CHANNEL_MASKS ||
|
||||
flatenedFormats.size() > AUDIO_PORT_MAX_FORMATS) {
|
||||
ALOGE("%s: bailing out: cannot export profiles to port config", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
port->role = mRole;
|
||||
port->type = mType;
|
||||
strlcpy(port->name, mName.c_str(), AUDIO_PORT_MAX_NAME_LEN);
|
||||
port->num_sample_rates = flatenedRates.size();
|
||||
port->num_channel_masks = flatenedChannels.size();
|
||||
port->num_formats = flatenedFormats.size();
|
||||
std::copy(flatenedRates.begin(), flatenedRates.end(), port->sample_rates);
|
||||
std::copy(flatenedChannels.begin(), flatenedChannels.end(), port->channel_masks);
|
||||
std::copy(flatenedFormats.begin(), flatenedFormats.end(), port->formats);
|
||||
|
||||
ALOGV("AudioPort::toAudioPort() num gains %zu", mGains.size());
|
||||
|
||||
port->num_gains = std::min(mGains.size(), (size_t) AUDIO_PORT_MAX_GAINS);
|
||||
for (size_t i = 0; i < port->num_gains; i++) {
|
||||
port->gains[i] = mGains[i]->getGain();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioPort::dump(std::string *dst, int spaces, bool verbose) const {
|
||||
if (!mName.empty()) {
|
||||
dst->append(base::StringPrintf("%*s- name: %s\n", spaces, "", mName.c_str()));
|
||||
}
|
||||
if (verbose) {
|
||||
std::string profilesStr;
|
||||
mProfiles.dump(&profilesStr, spaces);
|
||||
dst->append(profilesStr);
|
||||
|
||||
if (mGains.size() != 0) {
|
||||
dst->append(base::StringPrintf("%*s- gains:\n", spaces, ""));
|
||||
for (size_t i = 0; i < mGains.size(); i++) {
|
||||
std::string gainStr;
|
||||
mGains[i]->dump(&gainStr, spaces + 2, i);
|
||||
dst->append(gainStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioPort::log(const char* indent) const
|
||||
{
|
||||
ALOGI("%s Port[nm:%s, type:%d, role:%d]", indent, mName.c_str(), mType, mRole);
|
||||
}
|
||||
|
||||
// --- AudioPortConfig class implementation
|
||||
|
||||
status_t AudioPortConfig::applyAudioPortConfig(
|
||||
const struct audio_port_config *config,
|
||||
struct audio_port_config *backupConfig __unused)
|
||||
{
|
||||
if (config->config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) {
|
||||
mSamplingRate = config->sample_rate;
|
||||
}
|
||||
if (config->config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) {
|
||||
mChannelMask = config->channel_mask;
|
||||
}
|
||||
if (config->config_mask & AUDIO_PORT_CONFIG_FORMAT) {
|
||||
mFormat = config->format;
|
||||
}
|
||||
if (config->config_mask & AUDIO_PORT_CONFIG_GAIN) {
|
||||
mGain = config->gain;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename T>
|
||||
void updateField(
|
||||
const T& portConfigField, T audio_port_config::*port_config_field,
|
||||
struct audio_port_config *dstConfig, const struct audio_port_config *srcConfig,
|
||||
unsigned int configMask, T defaultValue)
|
||||
{
|
||||
if (dstConfig->config_mask & configMask) {
|
||||
if ((srcConfig != nullptr) && (srcConfig->config_mask & configMask)) {
|
||||
dstConfig->*port_config_field = srcConfig->*port_config_field;
|
||||
} else {
|
||||
dstConfig->*port_config_field = portConfigField;
|
||||
}
|
||||
} else {
|
||||
dstConfig->*port_config_field = defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AudioPortConfig::toAudioPortConfig(
|
||||
struct audio_port_config *dstConfig,
|
||||
const struct audio_port_config *srcConfig) const
|
||||
{
|
||||
updateField(mSamplingRate, &audio_port_config::sample_rate,
|
||||
dstConfig, srcConfig, AUDIO_PORT_CONFIG_SAMPLE_RATE, 0u);
|
||||
updateField(mChannelMask, &audio_port_config::channel_mask,
|
||||
dstConfig, srcConfig, AUDIO_PORT_CONFIG_CHANNEL_MASK,
|
||||
(audio_channel_mask_t)AUDIO_CHANNEL_NONE);
|
||||
updateField(mFormat, &audio_port_config::format,
|
||||
dstConfig, srcConfig, AUDIO_PORT_CONFIG_FORMAT, AUDIO_FORMAT_INVALID);
|
||||
dstConfig->id = mId;
|
||||
|
||||
sp<AudioPort> audioport = getAudioPort();
|
||||
if ((dstConfig->config_mask & AUDIO_PORT_CONFIG_GAIN) && audioport != NULL) {
|
||||
dstConfig->gain = mGain;
|
||||
if ((srcConfig != NULL) && (srcConfig->config_mask & AUDIO_PORT_CONFIG_GAIN)
|
||||
&& audioport->checkGain(&srcConfig->gain, srcConfig->gain.index) == OK) {
|
||||
dstConfig->gain = srcConfig->gain;
|
||||
}
|
||||
} else {
|
||||
dstConfig->gain.index = -1;
|
||||
}
|
||||
if (dstConfig->gain.index != -1) {
|
||||
dstConfig->config_mask |= AUDIO_PORT_CONFIG_GAIN;
|
||||
} else {
|
||||
dstConfig->config_mask &= ~AUDIO_PORT_CONFIG_GAIN;
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioPortConfig::hasGainController(bool canUseForVolume) const
|
||||
{
|
||||
sp<AudioPort> audioport = getAudioPort();
|
||||
if (!audioport) {
|
||||
return false;
|
||||
}
|
||||
return canUseForVolume ? audioport->getGains().canUseForVolume()
|
||||
: audioport->getGains().size() > 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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-base/stringprintf.h>
|
||||
#include <media/AudioPortBase.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
void AudioPortFoundation::toAudioPort(struct audio_port *port) const {
|
||||
// TODO: update this function once audio_port structure reflects the new profile definition.
|
||||
// For compatibility reason: flatening the AudioProfile into audio_port structure.
|
||||
FormatSet flatenedFormats;
|
||||
SampleRateSet flatenedRates;
|
||||
ChannelMaskSet flatenedChannels;
|
||||
for (const auto& profile : *getAudioProfileVectorBase()) {
|
||||
if (profile->isValid()) {
|
||||
audio_format_t formatToExport = profile->getFormat();
|
||||
const SampleRateSet &ratesToExport = profile->getSampleRates();
|
||||
const ChannelMaskSet &channelsToExport = profile->getChannels();
|
||||
|
||||
flatenedFormats.insert(formatToExport);
|
||||
flatenedRates.insert(ratesToExport.begin(), ratesToExport.end());
|
||||
flatenedChannels.insert(channelsToExport.begin(), channelsToExport.end());
|
||||
|
||||
if (flatenedRates.size() > AUDIO_PORT_MAX_SAMPLING_RATES ||
|
||||
flatenedChannels.size() > AUDIO_PORT_MAX_CHANNEL_MASKS ||
|
||||
flatenedFormats.size() > AUDIO_PORT_MAX_FORMATS) {
|
||||
ALOGE("%s: bailing out: cannot export profiles to port config", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
port->role = mRole;
|
||||
port->type = mType;
|
||||
strlcpy(port->name, mName.c_str(), AUDIO_PORT_MAX_NAME_LEN);
|
||||
port->num_sample_rates = flatenedRates.size();
|
||||
port->num_channel_masks = flatenedChannels.size();
|
||||
port->num_formats = flatenedFormats.size();
|
||||
std::copy(flatenedRates.begin(), flatenedRates.end(), port->sample_rates);
|
||||
std::copy(flatenedChannels.begin(), flatenedChannels.end(), port->channel_masks);
|
||||
std::copy(flatenedFormats.begin(), flatenedFormats.end(), port->formats);
|
||||
|
||||
ALOGV("AudioPort::toAudioPort() num gains %zu", mGains.size());
|
||||
|
||||
port->num_gains = std::min(mGains.size(), (size_t) AUDIO_PORT_MAX_GAINS);
|
||||
for (size_t i = 0; i < port->num_gains; i++) {
|
||||
port->gains[i] = mGains[i]->getGain();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioPortFoundation::dump(std::string *dst, int spaces, bool verbose) const {
|
||||
if (!mName.empty()) {
|
||||
dst->append(base::StringPrintf("%*s- name: %s\n", spaces, "", mName.c_str()));
|
||||
}
|
||||
if (verbose) {
|
||||
std::string profilesStr;
|
||||
getAudioProfileVectorBase()->dump(&profilesStr, spaces);
|
||||
dst->append(profilesStr);
|
||||
|
||||
if (mGains.size() != 0) {
|
||||
dst->append(base::StringPrintf("%*s- gains:\n", spaces, ""));
|
||||
for (size_t i = 0; i < mGains.size(); i++) {
|
||||
std::string gainStr;
|
||||
mGains[i]->dump(&gainStr, spaces + 2, i);
|
||||
dst->append(gainStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "DeviceDescriptorBase"
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <audio_utils/string.h>
|
||||
#include <media/DeviceDescriptorBase.h>
|
||||
#include <media/TypeConverter.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
DeviceDescriptorBase::DeviceDescriptorBase(audio_devices_t type) :
|
||||
AudioPort("", AUDIO_PORT_TYPE_DEVICE,
|
||||
audio_is_output_device(type) ? AUDIO_PORT_ROLE_SINK :
|
||||
AUDIO_PORT_ROLE_SOURCE),
|
||||
mDeviceType(type)
|
||||
{
|
||||
if (audio_is_remote_submix_device(type)) {
|
||||
mAddress = "0";
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceDescriptorBase::toAudioPortConfig(struct audio_port_config *dstConfig,
|
||||
const struct audio_port_config *srcConfig) const
|
||||
{
|
||||
dstConfig->config_mask = AUDIO_PORT_CONFIG_GAIN;
|
||||
if (mSamplingRate != 0) {
|
||||
dstConfig->config_mask |= AUDIO_PORT_CONFIG_SAMPLE_RATE;
|
||||
}
|
||||
if (mChannelMask != AUDIO_CHANNEL_NONE) {
|
||||
dstConfig->config_mask |= AUDIO_PORT_CONFIG_CHANNEL_MASK;
|
||||
}
|
||||
if (mFormat != AUDIO_FORMAT_INVALID) {
|
||||
dstConfig->config_mask |= AUDIO_PORT_CONFIG_FORMAT;
|
||||
}
|
||||
|
||||
if (srcConfig != NULL) {
|
||||
dstConfig->config_mask |= srcConfig->config_mask;
|
||||
}
|
||||
|
||||
AudioPortConfig::toAudioPortConfig(dstConfig, srcConfig);
|
||||
|
||||
dstConfig->role = audio_is_output_device(mDeviceType) ?
|
||||
AUDIO_PORT_ROLE_SINK : AUDIO_PORT_ROLE_SOURCE;
|
||||
dstConfig->type = AUDIO_PORT_TYPE_DEVICE;
|
||||
dstConfig->ext.device.type = mDeviceType;
|
||||
|
||||
(void)audio_utils_strlcpy_zerofill(dstConfig->ext.device.address, mAddress.c_str());
|
||||
}
|
||||
|
||||
void DeviceDescriptorBase::toAudioPort(struct audio_port *port) const
|
||||
{
|
||||
ALOGV("DeviceDescriptorBase::toAudioPort() handle %d type %08x", mId, mDeviceType);
|
||||
AudioPort::toAudioPort(port);
|
||||
toAudioPortConfig(&port->active_config);
|
||||
port->id = mId;
|
||||
port->ext.device.type = mDeviceType;
|
||||
(void)audio_utils_strlcpy_zerofill(port->ext.device.address, mAddress.c_str());
|
||||
}
|
||||
|
||||
void DeviceDescriptorBase::dump(std::string *dst, int spaces, int index,
|
||||
const char* extraInfo, bool verbose) const
|
||||
{
|
||||
dst->append(base::StringPrintf("%*sDevice %d:\n", spaces, "", index + 1));
|
||||
if (mId != 0) {
|
||||
dst->append(base::StringPrintf("%*s- id: %2d\n", spaces, "", mId));
|
||||
}
|
||||
|
||||
if (extraInfo != nullptr) {
|
||||
dst->append(extraInfo);
|
||||
}
|
||||
|
||||
dst->append(base::StringPrintf("%*s- type: %-48s\n",
|
||||
spaces, "", ::android::toString(mDeviceType).c_str()));
|
||||
|
||||
if (mAddress.size() != 0) {
|
||||
dst->append(base::StringPrintf("%*s- address: %-32s\n", spaces, "", mAddress.c_str()));
|
||||
}
|
||||
AudioPort::dump(dst, spaces, verbose);
|
||||
}
|
||||
|
||||
std::string DeviceDescriptorBase::toString() const
|
||||
{
|
||||
std::stringstream sstream;
|
||||
sstream << "type:0x" << std::hex << type() << ",@:" << mAddress;
|
||||
return sstream.str();
|
||||
}
|
||||
|
||||
void DeviceDescriptorBase::log() const
|
||||
{
|
||||
ALOGI("Device id:%d type:0x%08X:%s, addr:%s", mId, mDeviceType,
|
||||
::android::toString(mDeviceType).c_str(),
|
||||
mAddress.c_str());
|
||||
|
||||
AudioPort::log(" ");
|
||||
}
|
||||
|
||||
} // namespace android
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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 <media/AudioPort.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <cutils/config_utils.h>
|
||||
#include <system/audio.h>
|
||||
#include <system/audio_policy.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class DeviceDescriptorBase : public AudioPort, public AudioPortConfig
|
||||
{
|
||||
public:
|
||||
// Note that empty name refers by convention to a generic device.
|
||||
explicit DeviceDescriptorBase(audio_devices_t type);
|
||||
|
||||
virtual ~DeviceDescriptorBase() {}
|
||||
|
||||
audio_devices_t type() const { return mDeviceType; }
|
||||
std::string address() const { return mAddress; }
|
||||
void setAddress(const std::string &address) { mAddress = address; }
|
||||
|
||||
// AudioPortConfig
|
||||
virtual sp<AudioPort> getAudioPort() const {
|
||||
return static_cast<AudioPort*>(const_cast<DeviceDescriptorBase*>(this));
|
||||
}
|
||||
virtual void toAudioPortConfig(struct audio_port_config *dstConfig,
|
||||
const struct audio_port_config *srcConfig = NULL) const;
|
||||
|
||||
// AudioPort
|
||||
virtual void toAudioPort(struct audio_port *port) const;
|
||||
|
||||
void dump(std::string *dst, int spaces, int index,
|
||||
const char* extraInfo = nullptr, bool verbose = true) const;
|
||||
void log() const;
|
||||
std::string toString() const;
|
||||
|
||||
protected:
|
||||
std::string mAddress{""};
|
||||
audio_devices_t mDeviceType;
|
||||
};
|
||||
|
||||
} // namespace android
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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 <media/AudioProfile.h>
|
||||
#include <system/audio.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class AudioProfileVector : public AudioProfileVectorBase {
|
||||
public:
|
||||
virtual ~AudioProfileVector() = default;
|
||||
|
||||
ssize_t add(const sp<AudioProfile> &profile) override;
|
||||
|
||||
// This API is intended to be used by the policy manager once retrieving capabilities
|
||||
// for a profile with dynamic format, rate and channels attributes
|
||||
ssize_t addProfileFromHal(const sp<AudioProfile> &profileToAdd);
|
||||
void appendProfiles(const AudioProfileVectorBase& audioProfiles) {
|
||||
insert(end(), audioProfiles.begin(), audioProfiles.end());
|
||||
}
|
||||
|
||||
status_t checkExactProfile(const uint32_t samplingRate,
|
||||
audio_channel_mask_t channelMask,
|
||||
audio_format_t format) const;
|
||||
|
||||
status_t checkCompatibleProfile(uint32_t &samplingRate,
|
||||
audio_channel_mask_t &channelMask,
|
||||
audio_format_t &format,
|
||||
audio_port_type_t portType,
|
||||
audio_port_role_t portRole) const;
|
||||
|
||||
// Assuming that this profile vector contains input profiles,
|
||||
// find the best matching config from 'outputProfiles', according to
|
||||
// the given preferences for audio formats and channel masks.
|
||||
// Note: std::vectors are used because specialized containers for formats
|
||||
// and channels can be sorted and use their own ordering.
|
||||
status_t findBestMatchingOutputConfig(
|
||||
const AudioProfileVector &outputProfiles,
|
||||
const std::vector<audio_format_t> &preferredFormats, // order: most pref -> least pref
|
||||
const std::vector<audio_channel_mask_t> &preferredOutputChannels,
|
||||
bool preferHigherSamplingRates,
|
||||
audio_config_base *bestOutputConfig) const;
|
||||
|
||||
// One audio profile will be added for each format supported by Audio HAL
|
||||
void setFormats(const FormatVector &formats);
|
||||
|
||||
private:
|
||||
sp<AudioProfile> getProfileFor(audio_format_t format) const;
|
||||
void setSampleRatesFor(const SampleRateSet &sampleRates, audio_format_t format);
|
||||
void setChannelsFor(const ChannelMaskSet &channelMasks, audio_format_t format);
|
||||
};
|
||||
|
||||
} // namespace android
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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 <media/AudioProfile.h>
|
||||
#include <system/audio.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
void sortAudioProfiles(AudioProfileVector &audioProfileVector);
|
||||
|
||||
ssize_t addAudioProfileAndSort(AudioProfileVector &audioProfileVector,
|
||||
const sp<AudioProfile> &profile);
|
||||
|
||||
// One audio profile will be added for each format supported by Audio HAL
|
||||
void addProfilesForFormats(AudioProfileVector &audioProfileVector,
|
||||
const FormatVector &formatVector);
|
||||
|
||||
// This API is intended to be used by the policy manager once retrieving capabilities
|
||||
// for a profile with dynamic format, rate and channels attributes
|
||||
void addDynamicAudioProfileAndSort(AudioProfileVector &audioProfileVector,
|
||||
const sp<AudioProfile> &profileToAdd);
|
||||
|
||||
void appendAudioProfiles(AudioProfileVector &audioProfileVector,
|
||||
const AudioProfileVector &audioProfileVectorToAppend);
|
||||
|
||||
status_t checkExactProfile(const AudioProfileVector &audioProfileVector,
|
||||
const uint32_t samplingRate,
|
||||
audio_channel_mask_t channelMask,
|
||||
audio_format_t format);
|
||||
|
||||
status_t checkCompatibleProfile(const AudioProfileVector &audioProfileVector,
|
||||
uint32_t &samplingRate,
|
||||
audio_channel_mask_t &channelMask,
|
||||
audio_format_t &format,
|
||||
audio_port_type_t portType,
|
||||
audio_port_role_t portRole);
|
||||
|
||||
// Assuming that this profile vector contains input profiles,
|
||||
// find the best matching config from 'outputProfiles', according to
|
||||
// the given preferences for audio formats and channel masks.
|
||||
// Note: std::vectors are used because specialized containers for formats
|
||||
// and channels can be sorted and use their own ordering.
|
||||
status_t findBestMatchingOutputConfig(
|
||||
const AudioProfileVector &audioProfileVector,
|
||||
const AudioProfileVector &outputProfileVector,
|
||||
const std::vector<audio_format_t> &preferredFormatVector, // order: most pref -> least pref
|
||||
const std::vector<audio_channel_mask_t> &preferredOutputChannelVector,
|
||||
bool preferHigherSamplingRates,
|
||||
audio_config_base &bestOutputConfig);
|
||||
|
||||
|
||||
} // namespace android
|
Loading…
Reference in new issue