mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge changes from topic "aosp-default-wrapper"
* changes: HidlUtils: remove temporary conversion functions audio: Update default effect HAL wrapper to support V7 audio: Update default wrapper to support V7 audio: Extend HidlUtils for the default wrapper needs
This commit is contained in:
@@ -66,9 +66,10 @@ interface IStream {
|
||||
* Retrieves basic stream configuration: sample rate, audio format,
|
||||
* channel mask.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return config basic stream configuration.
|
||||
*/
|
||||
getAudioProperties() generates (AudioConfigBase config);
|
||||
getAudioProperties() generates (Result retval, AudioConfigBase config);
|
||||
|
||||
/**
|
||||
* Sets stream parameters. Only sets parameters that are specified.
|
||||
|
||||
@@ -225,6 +225,10 @@ static inline bool isUnknownAudioChannelMask(const std::string& mask) {
|
||||
return stringToAudioChannelMask(mask) == AudioChannelMask::UNKNOWN;
|
||||
}
|
||||
|
||||
static inline bool isUnknownAudioContentType(const std::string& contentType) {
|
||||
return stringToAudioContentType(contentType) == AudioContentType::UNKNOWN;
|
||||
}
|
||||
|
||||
static inline bool isUnknownAudioDevice(const std::string& device) {
|
||||
return stringToAudioDevice(device) == AudioDevice::UNKNOWN && !isVendorExtension(device);
|
||||
}
|
||||
@@ -237,6 +241,10 @@ static inline bool isUnknownAudioGainMode(const std::string& mode) {
|
||||
return stringToAudioGainMode(mode) == AudioGainMode::UNKNOWN;
|
||||
}
|
||||
|
||||
static inline bool isUnknownAudioInOutFlag(const std::string& flag) {
|
||||
return stringToAudioInOutFlag(flag) == AudioInOutFlag::UNKNOWN;
|
||||
}
|
||||
|
||||
static inline bool isUnknownAudioSource(const std::string& source) {
|
||||
return stringToAudioSource(source) == AudioSource::UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -107,14 +107,14 @@ Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
|
||||
}
|
||||
|
||||
Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
|
||||
const EffectConfig config = {{} /* inputCfg */,
|
||||
// outputCfg
|
||||
{{} /* buffer */,
|
||||
48000 /* samplingRateHz */,
|
||||
toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO),
|
||||
toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT),
|
||||
EffectBufferAccess::ACCESS_ACCUMULATE,
|
||||
0 /* mask */}};
|
||||
const EffectConfig config = {
|
||||
{} /* inputCfg */,
|
||||
// outputCfg
|
||||
{{} /* buffer */,
|
||||
{toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT), 48000 /* samplingRateHz */,
|
||||
toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO)}, /* base */
|
||||
EffectBufferAccess::ACCESS_ACCUMULATE,
|
||||
0 /* mask */}};
|
||||
_hidl_cb(Result::OK, config);
|
||||
return Void();
|
||||
}
|
||||
|
||||
@@ -95,6 +95,25 @@ status_t HidlUtils::audioChannelMaskFromHal(audio_channel_mask_t halChannelMask,
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioChannelMasksFromHal(const std::vector<std::string>& halChannelMasks,
|
||||
hidl_vec<AudioChannelMask>* channelMasks) {
|
||||
hidl_vec<AudioChannelMask> tempChannelMasks;
|
||||
tempChannelMasks.resize(halChannelMasks.size());
|
||||
size_t tempPos = 0;
|
||||
for (const auto& halChannelMask : halChannelMasks) {
|
||||
if (!halChannelMask.empty() && !xsd::isUnknownAudioChannelMask(halChannelMask)) {
|
||||
tempChannelMasks[tempPos++] = halChannelMask;
|
||||
}
|
||||
}
|
||||
if (tempPos == tempChannelMasks.size()) {
|
||||
*channelMasks = std::move(tempChannelMasks);
|
||||
} else {
|
||||
*channelMasks = hidl_vec<AudioChannelMask>(tempChannelMasks.begin(),
|
||||
tempChannelMasks.begin() + tempPos);
|
||||
}
|
||||
return halChannelMasks.size() == channelMasks->size() ? NO_ERROR : BAD_VALUE;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioChannelMaskToHal(const AudioChannelMask& channelMask,
|
||||
audio_channel_mask_t* halChannelMask) {
|
||||
if (!xsd::isUnknownAudioChannelMask(channelMask) &&
|
||||
@@ -127,6 +146,28 @@ status_t HidlUtils::audioConfigBaseToHal(const AudioConfigBase& configBase,
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioContentTypeFromHal(const audio_content_type_t halContentType,
|
||||
AudioContentType* contentType) {
|
||||
*contentType = audio_content_type_to_string(halContentType);
|
||||
if (!contentType->empty() && !xsd::isUnknownAudioContentType(*contentType)) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
ALOGE("Unknown audio content type value 0x%X", halContentType);
|
||||
*contentType = toString(xsd::AudioContentType::AUDIO_CONTENT_TYPE_UNKNOWN);
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioContentTypeToHal(const AudioContentType& contentType,
|
||||
audio_content_type_t* halContentType) {
|
||||
if (!xsd::isUnknownAudioContentType(contentType) &&
|
||||
audio_content_type_from_string(contentType.c_str(), halContentType)) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
ALOGE("Unknown audio content type \"%s\"", contentType.c_str());
|
||||
*halContentType = AUDIO_CONTENT_TYPE_UNKNOWN;
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioDeviceTypeFromHal(audio_devices_t halDevice, AudioDevice* device) {
|
||||
*device = audio_device_to_string(halDevice);
|
||||
if (!device->empty() && !xsd::isUnknownAudioDevice(*device)) {
|
||||
@@ -155,6 +196,24 @@ status_t HidlUtils::audioFormatFromHal(audio_format_t halFormat, AudioFormat* fo
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioFormatsFromHal(const std::vector<std::string>& halFormats,
|
||||
hidl_vec<AudioFormat>* formats) {
|
||||
hidl_vec<AudioFormat> tempFormats;
|
||||
tempFormats.resize(halFormats.size());
|
||||
size_t tempPos = 0;
|
||||
for (const auto& halFormat : halFormats) {
|
||||
if (!halFormat.empty() && !xsd::isUnknownAudioFormat(halFormat)) {
|
||||
tempFormats[tempPos++] = halFormat;
|
||||
}
|
||||
}
|
||||
if (tempPos == tempFormats.size()) {
|
||||
*formats = std::move(tempFormats);
|
||||
} else {
|
||||
*formats = hidl_vec<AudioFormat>(tempFormats.begin(), tempFormats.begin() + tempPos);
|
||||
}
|
||||
return halFormats.size() == formats->size() ? NO_ERROR : BAD_VALUE;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioFormatToHal(const AudioFormat& format, audio_format_t* halFormat) {
|
||||
if (!xsd::isUnknownAudioFormat(format) && audio_format_from_string(format.c_str(), halFormat)) {
|
||||
return NO_ERROR;
|
||||
|
||||
@@ -43,6 +43,7 @@ filegroup {
|
||||
name: "android.hardware.audio.common-util@2-6",
|
||||
srcs: [
|
||||
"HidlUtils.cpp",
|
||||
"HidlUtilsCommon.cpp",
|
||||
"UuidUtils.cpp",
|
||||
],
|
||||
}
|
||||
@@ -132,6 +133,7 @@ cc_library {
|
||||
defaults: ["android.hardware.audio.common-util_default"],
|
||||
srcs: [
|
||||
"7.0/HidlUtils.cpp",
|
||||
"HidlUtilsCommon.cpp",
|
||||
"UuidUtils.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace common {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
status_t HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
|
||||
status_t HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, bool, AudioConfig* config) {
|
||||
config->sampleRateHz = halConfig.sample_rate;
|
||||
config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
|
||||
config->format = AudioFormat(halConfig.format);
|
||||
@@ -47,8 +47,8 @@ status_t HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t*
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig,
|
||||
AudioGainConfig* config) {
|
||||
status_t HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig, bool,
|
||||
AudioGainConfig* config) {
|
||||
config->index = halConfig.index;
|
||||
config->mode = EnumBitfield<AudioGainMode>(halConfig.mode);
|
||||
config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
|
||||
@@ -56,6 +56,7 @@ void HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig
|
||||
config->values[i] = halConfig.values[i];
|
||||
}
|
||||
config->rampDurationMs = halConfig.ramp_duration_ms;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioGainConfigToHal(const AudioGainConfig& config,
|
||||
@@ -71,7 +72,7 @@ status_t HidlUtils::audioGainConfigToHal(const AudioGainConfig& config,
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) {
|
||||
status_t HidlUtils::audioGainFromHal(const struct audio_gain& halGain, bool, AudioGain* gain) {
|
||||
gain->mode = EnumBitfield<AudioGainMode>(halGain.mode);
|
||||
gain->channelMask = EnumBitfield<AudioChannelMask>(halGain.channel_mask);
|
||||
gain->minValue = halGain.min_value;
|
||||
@@ -80,6 +81,7 @@ void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* ga
|
||||
gain->stepValue = halGain.step_value;
|
||||
gain->minRampMs = halGain.min_ramp_ms;
|
||||
gain->maxRampMs = halGain.max_ramp_ms;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) {
|
||||
@@ -182,7 +184,7 @@ status_t HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halCo
|
||||
config->sampleRateHz = halConfig.sample_rate;
|
||||
config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
|
||||
config->format = AudioFormat(halConfig.format);
|
||||
audioGainConfigFromHal(halConfig.gain, &config->gain);
|
||||
audioGainConfigFromHal(halConfig.gain, false /*isInput--ignored*/, &config->gain);
|
||||
switch (halConfig.type) {
|
||||
case AUDIO_PORT_TYPE_NONE:
|
||||
break;
|
||||
@@ -272,7 +274,7 @@ status_t HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort
|
||||
}
|
||||
port->gains.resize(halPort.num_gains);
|
||||
for (size_t i = 0; i < halPort.num_gains; ++i) {
|
||||
audioGainFromHal(halPort.gains[i], &port->gains[i]);
|
||||
audioGainFromHal(halPort.gains[i], false /*isInput--ignored*/, &port->gains[i]);
|
||||
}
|
||||
audioPortConfigFromHal(halPort.active_config, &port->activeConfig);
|
||||
switch (halPort.type) {
|
||||
@@ -351,6 +353,18 @@ status_t HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* hal
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION >= 5
|
||||
status_t HidlUtils::deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
|
||||
char* halDeviceAddress) {
|
||||
return deviceAddressToHalImpl(device, halDeviceType, halDeviceAddress);
|
||||
}
|
||||
|
||||
status_t HidlUtils::deviceAddressFromHal(audio_devices_t halDeviceType,
|
||||
const char* halDeviceAddress, DeviceAddress* device) {
|
||||
return deviceAddressFromHalImpl(halDeviceType, halDeviceAddress, device);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
} // namespace common
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
#include <system/audio.h>
|
||||
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
@@ -32,25 +30,25 @@ namespace common {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::hidl_vec;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
|
||||
struct HidlUtils {
|
||||
#if MAJOR_VERSION < 7
|
||||
static status_t audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config);
|
||||
static void audioGainConfigFromHal(const struct audio_gain_config& halConfig,
|
||||
AudioGainConfig* config);
|
||||
static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
|
||||
#else
|
||||
static status_t audioConfigFromHal(const audio_config_t& halConfig, bool isInput,
|
||||
AudioConfig* config);
|
||||
static status_t audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
|
||||
#if MAJOR_VERSION >= 4
|
||||
static status_t audioContentTypeFromHal(const audio_content_type_t halContentType,
|
||||
AudioContentType* contentType);
|
||||
static status_t audioContentTypeToHal(const AudioContentType& contentType,
|
||||
audio_content_type_t* halContentType);
|
||||
#endif
|
||||
static status_t audioGainConfigFromHal(const struct audio_gain_config& halConfig, bool isInput,
|
||||
AudioGainConfig* config);
|
||||
static status_t audioGainFromHal(const struct audio_gain& halGain, bool isInput,
|
||||
AudioGain* gain);
|
||||
#endif
|
||||
static status_t audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
|
||||
static status_t audioGainConfigToHal(const AudioGainConfig& config,
|
||||
struct audio_gain_config* halConfig);
|
||||
static status_t audioGainFromHal(const struct audio_gain& halGain, bool isInput,
|
||||
AudioGain* gain);
|
||||
static status_t audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
|
||||
static status_t audioUsageFromHal(audio_usage_t halUsage, AudioUsage* usage);
|
||||
static status_t audioUsageToHal(const AudioUsage& usage, audio_usage_t* halUsage);
|
||||
@@ -64,43 +62,25 @@ struct HidlUtils {
|
||||
struct audio_port_config* halConfig);
|
||||
static status_t audioPortConfigsFromHal(unsigned int numHalConfigs,
|
||||
const struct audio_port_config* halConfigs,
|
||||
hidl_vec<AudioPortConfig>* configs) {
|
||||
status_t result = NO_ERROR;
|
||||
configs->resize(numHalConfigs);
|
||||
for (unsigned int i = 0; i < numHalConfigs; ++i) {
|
||||
if (status_t status = audioPortConfigFromHal(halConfigs[i], &(*configs)[i]);
|
||||
status != NO_ERROR) {
|
||||
result = status;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
hidl_vec<AudioPortConfig>* configs);
|
||||
static status_t audioPortConfigsToHal(const hidl_vec<AudioPortConfig>& configs,
|
||||
std::unique_ptr<audio_port_config[]>* halConfigs) {
|
||||
status_t result = NO_ERROR;
|
||||
halConfigs->reset(new audio_port_config[configs.size()]);
|
||||
for (size_t i = 0; i < configs.size(); ++i) {
|
||||
if (status_t status = audioPortConfigToHal(configs[i], &(*halConfigs)[i]);
|
||||
status != NO_ERROR) {
|
||||
result = status;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// PLEASE DO NOT USE, will be removed in a couple of days
|
||||
static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
|
||||
const hidl_vec<AudioPortConfig>& configs) {
|
||||
std::unique_ptr<audio_port_config[]> halConfigs;
|
||||
(void)audioPortConfigsToHal(configs, &halConfigs);
|
||||
return halConfigs;
|
||||
}
|
||||
|
||||
std::unique_ptr<audio_port_config[]>* halConfigs);
|
||||
static status_t audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
|
||||
static status_t audioPortToHal(const AudioPort& port, struct audio_port* halPort);
|
||||
static status_t audioSourceFromHal(audio_source_t halSource, AudioSource* source);
|
||||
static status_t audioSourceToHal(const AudioSource& source, audio_source_t* halSource);
|
||||
#if MAJOR_VERSION >= 5
|
||||
static status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
|
||||
char* halDeviceAddress);
|
||||
static status_t deviceAddressFromHal(audio_devices_t halDeviceType,
|
||||
const char* halDeviceAddress, DeviceAddress* device);
|
||||
#endif
|
||||
|
||||
#if MAJOR_VERSION >= 7
|
||||
static status_t audioChannelMaskFromHal(audio_channel_mask_t halChannelMask, bool isInput,
|
||||
AudioChannelMask* channelMask);
|
||||
static status_t audioChannelMasksFromHal(const std::vector<std::string>& halChannelMasks,
|
||||
hidl_vec<AudioChannelMask>* channelMasks);
|
||||
static status_t audioChannelMaskToHal(const AudioChannelMask& channelMask,
|
||||
audio_channel_mask_t* halChannelMask);
|
||||
static status_t audioConfigBaseFromHal(const audio_config_base_t& halConfigBase, bool isInput,
|
||||
@@ -110,6 +90,8 @@ struct HidlUtils {
|
||||
static status_t audioDeviceTypeFromHal(audio_devices_t halDevice, AudioDevice* device);
|
||||
static status_t audioDeviceTypeToHal(const AudioDevice& device, audio_devices_t* halDevice);
|
||||
static status_t audioFormatFromHal(audio_format_t halFormat, AudioFormat* format);
|
||||
static status_t audioFormatsFromHal(const std::vector<std::string>& halFormats,
|
||||
hidl_vec<AudioFormat>* formats);
|
||||
static status_t audioFormatToHal(const AudioFormat& format, audio_format_t* halFormat);
|
||||
static status_t audioGainModeMaskFromHal(audio_gain_mode_t halGainModeMask,
|
||||
hidl_vec<AudioGainMode>* gainModeMask);
|
||||
@@ -121,16 +103,10 @@ struct HidlUtils {
|
||||
AudioProfile* profile);
|
||||
static status_t audioProfileToHal(const AudioProfile& profile,
|
||||
struct audio_profile* halProfile);
|
||||
static status_t audioSourceFromHal(audio_source_t halSource, AudioSource* source);
|
||||
static status_t audioSourceToHal(const AudioSource& source, audio_source_t* halSource);
|
||||
static status_t audioStreamTypeFromHal(audio_stream_type_t halStreamType,
|
||||
AudioStreamType* streamType);
|
||||
static status_t audioStreamTypeToHal(const AudioStreamType& streamType,
|
||||
audio_stream_type_t* halStreamType);
|
||||
static status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
|
||||
char* halDeviceAddress);
|
||||
static status_t deviceAddressFromHal(audio_devices_t halDeviceType,
|
||||
const char* halDeviceAddress, DeviceAddress* device);
|
||||
|
||||
private:
|
||||
static status_t audioIndexChannelMaskFromHal(audio_channel_mask_t halChannelMask,
|
||||
@@ -150,9 +126,114 @@ struct HidlUtils {
|
||||
struct audio_port_config_device_ext* device,
|
||||
struct audio_port_config_mix_ext* mix,
|
||||
struct audio_port_config_session_ext* session);
|
||||
#endif // MAJOR_VERSION >= 7
|
||||
|
||||
// V4 and below have DeviceAddress defined in the 'core' interface.
|
||||
// To avoid duplicating code, the implementations of deviceAddressTo/FromHal
|
||||
// are defined as templates. These templates can be only used directly by V4
|
||||
// and below.
|
||||
#if MAJOR_VERSION >= 5
|
||||
private:
|
||||
#endif
|
||||
template <typename DA>
|
||||
static status_t deviceAddressToHalImpl(const DA& device, audio_devices_t* halDeviceType,
|
||||
char* halDeviceAddress);
|
||||
template <typename DA>
|
||||
static status_t deviceAddressFromHalImpl(audio_devices_t halDeviceType,
|
||||
const char* halDeviceAddress, DA* device);
|
||||
};
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
#if MAJOR_VERSION >= 4
|
||||
inline status_t HidlUtils::audioContentTypeFromHal(const audio_content_type_t halContentType,
|
||||
AudioContentType* contentType) {
|
||||
*contentType = AudioContentType(halContentType);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
inline status_t HidlUtils::audioContentTypeToHal(const AudioContentType& contentType,
|
||||
audio_content_type_t* halContentType) {
|
||||
*halContentType = static_cast<audio_content_type_t>(contentType);
|
||||
return NO_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline status_t HidlUtils::audioSourceFromHal(audio_source_t halSource, AudioSource* source) {
|
||||
*source = AudioSource(halSource);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
inline status_t HidlUtils::audioSourceToHal(const AudioSource& source, audio_source_t* halSource) {
|
||||
*halSource = static_cast<audio_source_t>(source);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
template <typename DA>
|
||||
status_t HidlUtils::deviceAddressToHalImpl(const DA& device, audio_devices_t* halDeviceType,
|
||||
char* halDeviceAddress) {
|
||||
*halDeviceType = static_cast<audio_devices_t>(device.device);
|
||||
memset(halDeviceAddress, 0, AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
if (audio_is_a2dp_out_device(*halDeviceType) || audio_is_a2dp_in_device(*halDeviceType)) {
|
||||
snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
device.address.mac[0], device.address.mac[1], device.address.mac[2],
|
||||
device.address.mac[3], device.address.mac[4], device.address.mac[5]);
|
||||
} else if (*halDeviceType == AUDIO_DEVICE_OUT_IP || *halDeviceType == AUDIO_DEVICE_IN_IP) {
|
||||
snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%d.%d.%d.%d",
|
||||
device.address.ipv4[0], device.address.ipv4[1], device.address.ipv4[2],
|
||||
device.address.ipv4[3]);
|
||||
} else if (audio_is_usb_out_device(*halDeviceType) || audio_is_usb_in_device(*halDeviceType)) {
|
||||
snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "card=%d;device=%d",
|
||||
device.address.alsa.card, device.address.alsa.device);
|
||||
} else if (*halDeviceType == AUDIO_DEVICE_OUT_BUS || *halDeviceType == AUDIO_DEVICE_IN_BUS) {
|
||||
snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%s", device.busAddress.c_str());
|
||||
} else if (*halDeviceType == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
|
||||
*halDeviceType == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
|
||||
snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%s",
|
||||
device.rSubmixAddress.c_str());
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
template <typename DA>
|
||||
status_t HidlUtils::deviceAddressFromHalImpl(audio_devices_t halDeviceType,
|
||||
const char* halDeviceAddress, DA* device) {
|
||||
if (device == nullptr) {
|
||||
return BAD_VALUE;
|
||||
}
|
||||
device->device = AudioDevice(halDeviceType);
|
||||
if (halDeviceAddress == nullptr ||
|
||||
strnlen(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
if (audio_is_a2dp_out_device(halDeviceType) || audio_is_a2dp_in_device(halDeviceType)) {
|
||||
int status =
|
||||
sscanf(halDeviceAddress, "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX", &device->address.mac[0],
|
||||
&device->address.mac[1], &device->address.mac[2], &device->address.mac[3],
|
||||
&device->address.mac[4], &device->address.mac[5]);
|
||||
return status == 6 ? OK : BAD_VALUE;
|
||||
} else if (halDeviceType == AUDIO_DEVICE_OUT_IP || halDeviceType == AUDIO_DEVICE_IN_IP) {
|
||||
int status = sscanf(halDeviceAddress, "%hhu.%hhu.%hhu.%hhu", &device->address.ipv4[0],
|
||||
&device->address.ipv4[1], &device->address.ipv4[2],
|
||||
&device->address.ipv4[3]);
|
||||
return status == 4 ? OK : BAD_VALUE;
|
||||
} else if (audio_is_usb_out_device(halDeviceType) || audio_is_usb_in_device(halDeviceType)) {
|
||||
int status = sscanf(halDeviceAddress, "card=%d;device=%d", &device->address.alsa.card,
|
||||
&device->address.alsa.device);
|
||||
return status == 2 ? OK : BAD_VALUE;
|
||||
} else if (halDeviceType == AUDIO_DEVICE_OUT_BUS || halDeviceType == AUDIO_DEVICE_IN_BUS) {
|
||||
device->busAddress = halDeviceAddress;
|
||||
return OK;
|
||||
} else if (halDeviceType == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
|
||||
halDeviceType == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
|
||||
device->rSubmixAddress = halDeviceAddress;
|
||||
return OK;
|
||||
}
|
||||
device->busAddress = halDeviceAddress;
|
||||
return NO_ERROR;
|
||||
}
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
} // namespace common
|
||||
|
||||
58
audio/common/all-versions/default/HidlUtilsCommon.cpp
Normal file
58
audio/common/all-versions/default/HidlUtilsCommon.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 "HidlUtils.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
status_t HidlUtils::audioPortConfigsFromHal(unsigned int numHalConfigs,
|
||||
const struct audio_port_config* halConfigs,
|
||||
hidl_vec<AudioPortConfig>* configs) {
|
||||
status_t result = NO_ERROR;
|
||||
configs->resize(numHalConfigs);
|
||||
for (unsigned int i = 0; i < numHalConfigs; ++i) {
|
||||
if (status_t status = audioPortConfigFromHal(halConfigs[i], &(*configs)[i]);
|
||||
status != NO_ERROR) {
|
||||
result = status;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t HidlUtils::audioPortConfigsToHal(const hidl_vec<AudioPortConfig>& configs,
|
||||
std::unique_ptr<audio_port_config[]>* halConfigs) {
|
||||
status_t result = NO_ERROR;
|
||||
halConfigs->reset(new audio_port_config[configs.size()]);
|
||||
for (size_t i = 0; i < configs.size(); ++i) {
|
||||
if (status_t status = audioPortConfigToHal(configs[i], &(*halConfigs)[i]);
|
||||
status != NO_ERROR) {
|
||||
result = status;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <xsdc/XsdcSupport.h>
|
||||
|
||||
using namespace android;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
namespace xsd {
|
||||
@@ -36,6 +37,8 @@ using namespace ::android::audio::policy::configuration::V7_0;
|
||||
|
||||
static constexpr audio_channel_mask_t kInvalidHalChannelMask =
|
||||
static_cast<audio_channel_mask_t>(0xFFFFFFFFU);
|
||||
static constexpr audio_content_type_t kInvalidHalContentType =
|
||||
static_cast<audio_content_type_t>(0xFFFFFFFFU);
|
||||
static constexpr audio_devices_t kInvalidHalDevice = static_cast<audio_devices_t>(0xFFFFFFFFU);
|
||||
static constexpr audio_format_t kInvalidHalFormat = static_cast<audio_format_t>(0xFFFFFFFFU);
|
||||
static constexpr audio_gain_mode_t kInvalidHalGainMode =
|
||||
@@ -117,6 +120,34 @@ TEST(HidlUtils, ConvertChannelMask) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertInvalidChannelMasksFromHal) {
|
||||
std::vector<std::string> validAndInvalidChannelMasks = {
|
||||
toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO), "random string", ""};
|
||||
hidl_vec<AudioChannelMask> validChannelMask;
|
||||
EXPECT_EQ(BAD_VALUE,
|
||||
HidlUtils::audioChannelMasksFromHal(validAndInvalidChannelMasks, &validChannelMask));
|
||||
EXPECT_EQ(1, validChannelMask.size());
|
||||
EXPECT_EQ(validAndInvalidChannelMasks[0], validChannelMask[0]);
|
||||
|
||||
std::vector<std::string> invalidChannelMasks = {"random string", ""};
|
||||
hidl_vec<AudioChannelMask> empty;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioChannelMasksFromHal(invalidChannelMasks, &empty));
|
||||
EXPECT_EQ(0, empty.size());
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertChannelMasksFromHal) {
|
||||
std::vector<std::string> allHalChannelMasks;
|
||||
for (const auto enumVal : xsdc_enum_range<xsd::AudioChannelMask>{}) {
|
||||
allHalChannelMasks.push_back(toString(enumVal));
|
||||
}
|
||||
hidl_vec<AudioChannelMask> allChannelMasks;
|
||||
EXPECT_EQ(NO_ERROR, HidlUtils::audioChannelMasksFromHal(allHalChannelMasks, &allChannelMasks));
|
||||
EXPECT_EQ(allHalChannelMasks.size(), allChannelMasks.size());
|
||||
for (size_t i = 0; i < allHalChannelMasks.size(); ++i) {
|
||||
EXPECT_EQ(allHalChannelMasks[i], allChannelMasks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertInvalidConfigBase) {
|
||||
AudioConfigBase invalid;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioConfigBaseFromHal({.sample_rate = 0,
|
||||
@@ -147,6 +178,26 @@ TEST(HidlUtils, ConvertConfigBase) {
|
||||
EXPECT_EQ(configBase, configBaseBack);
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertInvalidContentType) {
|
||||
AudioContentType invalid;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioContentTypeFromHal(kInvalidHalContentType, &invalid));
|
||||
audio_content_type_t halInvalid;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioContentTypeToHal("random string", &halInvalid));
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertContentType) {
|
||||
for (const auto enumVal : xsdc_enum_range<xsd::AudioContentType>{}) {
|
||||
const AudioContentType contentType = toString(enumVal);
|
||||
audio_content_type_t halContentType;
|
||||
AudioContentType contentTypeBack;
|
||||
EXPECT_EQ(NO_ERROR, HidlUtils::audioContentTypeToHal(contentType, &halContentType))
|
||||
<< "Conversion of \"" << contentType << "\" failed";
|
||||
EXPECT_EQ(NO_ERROR, HidlUtils::audioContentTypeFromHal(halContentType, &contentTypeBack))
|
||||
<< "Conversion of content type " << halContentType << " failed";
|
||||
EXPECT_EQ(contentType, contentTypeBack);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertInvalidDeviceType) {
|
||||
AudioDevice invalid;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioDeviceTypeFromHal(kInvalidHalDevice, &invalid));
|
||||
@@ -314,6 +365,33 @@ TEST(HidlUtils, ConvertFormat) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertInvalidFormatsFromHal) {
|
||||
std::vector<std::string> validAndInvalidFormats = {
|
||||
toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT), "random string", ""};
|
||||
hidl_vec<AudioFormat> validFormat;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioFormatsFromHal(validAndInvalidFormats, &validFormat));
|
||||
EXPECT_EQ(1, validFormat.size());
|
||||
EXPECT_EQ(validAndInvalidFormats[0], validFormat[0]);
|
||||
|
||||
std::vector<std::string> invalidFormats = {"random string", ""};
|
||||
hidl_vec<AudioFormat> empty;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioFormatsFromHal(invalidFormats, &empty));
|
||||
EXPECT_EQ(0, empty.size());
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertFormatsFromHal) {
|
||||
std::vector<std::string> allHalFormats;
|
||||
for (const auto enumVal : xsdc_enum_range<xsd::AudioFormat>{}) {
|
||||
allHalFormats.push_back(toString(enumVal));
|
||||
}
|
||||
hidl_vec<AudioFormat> allFormats;
|
||||
EXPECT_EQ(NO_ERROR, HidlUtils::audioFormatsFromHal(allHalFormats, &allFormats));
|
||||
EXPECT_EQ(allHalFormats.size(), allFormats.size());
|
||||
for (size_t i = 0; i < allHalFormats.size(); ++i) {
|
||||
EXPECT_EQ(allHalFormats[i], allFormats[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HidlUtils, ConvertInvalidGainModeMask) {
|
||||
hidl_vec<AudioGainMode> invalid;
|
||||
EXPECT_EQ(BAD_VALUE, HidlUtils::audioGainModeMaskFromHal(kInvalidHalGainMode, &invalid));
|
||||
|
||||
@@ -125,13 +125,15 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
enabled: false,
|
||||
name: "android.hardware.audio@7.0-impl",
|
||||
defaults: ["android.hardware.audio-impl_default"],
|
||||
shared_libs: [
|
||||
"android.hardware.audio@7.0",
|
||||
"android.hardware.audio.common@7.0",
|
||||
"android.hardware.audio.common@7.0-enums",
|
||||
"android.hardware.audio.common@7.0-util",
|
||||
"libbase",
|
||||
"libxml2",
|
||||
],
|
||||
cflags: [
|
||||
"-DMAJOR_VERSION=7",
|
||||
|
||||
@@ -18,8 +18,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if MAJOR_VERSION >= 7
|
||||
#include <android_audio_policy_configuration_V7_0-enums.h>
|
||||
#endif
|
||||
#include <HidlUtils.h>
|
||||
#include <log/log.h>
|
||||
#include <media/AudioContainers.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -27,73 +30,36 @@ namespace audio {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
// TODO(mnaganov): Use method from HidlUtils for V7
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
std::string deviceAddressToHal(const DeviceAddress& address) {
|
||||
// HAL assumes that the address is NUL-terminated.
|
||||
audio_devices_t halDevice;
|
||||
char halAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
memset(halAddress, 0, sizeof(halAddress));
|
||||
audio_devices_t halDevice = static_cast<audio_devices_t>(address.device);
|
||||
if (getAudioDeviceOutAllA2dpSet().count(halDevice) > 0 ||
|
||||
halDevice == AUDIO_DEVICE_IN_BLUETOOTH_A2DP) {
|
||||
snprintf(halAddress, sizeof(halAddress), "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
address.address.mac[0], address.address.mac[1], address.address.mac[2],
|
||||
address.address.mac[3], address.address.mac[4], address.address.mac[5]);
|
||||
} else if (halDevice == AUDIO_DEVICE_OUT_IP || halDevice == AUDIO_DEVICE_IN_IP) {
|
||||
snprintf(halAddress, sizeof(halAddress), "%d.%d.%d.%d", address.address.ipv4[0],
|
||||
address.address.ipv4[1], address.address.ipv4[2], address.address.ipv4[3]);
|
||||
} else if (getAudioDeviceOutAllUsbSet().count(halDevice) > 0 ||
|
||||
getAudioDeviceInAllUsbSet().count(halDevice) > 0) {
|
||||
snprintf(halAddress, sizeof(halAddress), "card=%d;device=%d", address.address.alsa.card,
|
||||
address.address.alsa.device);
|
||||
} else if (halDevice == AUDIO_DEVICE_OUT_BUS || halDevice == AUDIO_DEVICE_IN_BUS) {
|
||||
snprintf(halAddress, sizeof(halAddress), "%s", address.busAddress.c_str());
|
||||
} else if (halDevice == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
|
||||
halDevice == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
|
||||
snprintf(halAddress, sizeof(halAddress), "%s", address.rSubmixAddress.c_str());
|
||||
}
|
||||
(void)deviceAddressToHal(address, &halDevice, halAddress);
|
||||
return halAddress;
|
||||
}
|
||||
#endif
|
||||
|
||||
status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
|
||||
char* halDeviceAddress) {
|
||||
#if MAJOR_VERSION >= 5
|
||||
return HidlUtils::deviceAddressToHal(device, halDeviceType, halDeviceAddress);
|
||||
#else
|
||||
return HidlUtils::deviceAddressToHalImpl(device, halDeviceType, halDeviceAddress);
|
||||
#endif
|
||||
}
|
||||
|
||||
status_t deviceAddressFromHal(audio_devices_t halDeviceType, const char* halDeviceAddress,
|
||||
DeviceAddress* device) {
|
||||
#if MAJOR_VERSION >= 5
|
||||
return HidlUtils::deviceAddressFromHal(halDeviceType, halDeviceAddress, device);
|
||||
#else
|
||||
return HidlUtils::deviceAddressFromHalImpl(halDeviceType, halDeviceAddress, device);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION >= 4
|
||||
status_t deviceAddressFromHal(audio_devices_t device, const char* halAddress,
|
||||
DeviceAddress* address) {
|
||||
if (address == nullptr) {
|
||||
return BAD_VALUE;
|
||||
}
|
||||
address->device = AudioDevice(device);
|
||||
if (halAddress == nullptr || strnlen(halAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (getAudioDeviceOutAllA2dpSet().count(device) > 0 ||
|
||||
device == AUDIO_DEVICE_IN_BLUETOOTH_A2DP) {
|
||||
int status =
|
||||
sscanf(halAddress, "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX", &address->address.mac[0],
|
||||
&address->address.mac[1], &address->address.mac[2], &address->address.mac[3],
|
||||
&address->address.mac[4], &address->address.mac[5]);
|
||||
return status == 6 ? OK : BAD_VALUE;
|
||||
} else if (device == AUDIO_DEVICE_OUT_IP || device == AUDIO_DEVICE_IN_IP) {
|
||||
int status =
|
||||
sscanf(halAddress, "%hhu.%hhu.%hhu.%hhu", &address->address.ipv4[0],
|
||||
&address->address.ipv4[1], &address->address.ipv4[2], &address->address.ipv4[3]);
|
||||
return status == 4 ? OK : BAD_VALUE;
|
||||
} else if (getAudioDeviceOutAllUsbSet().count(device) > 0 ||
|
||||
getAudioDeviceInAllUsbSet().count(device) > 0) {
|
||||
int status = sscanf(halAddress, "card=%d;device=%d", &address->address.alsa.card,
|
||||
&address->address.alsa.device);
|
||||
return status == 2 ? OK : BAD_VALUE;
|
||||
} else if (device == AUDIO_DEVICE_OUT_BUS || device == AUDIO_DEVICE_IN_BUS) {
|
||||
address->busAddress = halAddress;
|
||||
return OK;
|
||||
} else if (device == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
|
||||
device == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
|
||||
address->rSubmixAddress = halAddress;
|
||||
return OK;
|
||||
}
|
||||
address->busAddress = halAddress;
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst,
|
||||
const struct audio_microphone_characteristic_t& src) {
|
||||
bool status = false;
|
||||
@@ -131,6 +97,44 @@ bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst,
|
||||
}
|
||||
return status;
|
||||
}
|
||||
#endif // MAJOR_VERSION >= 4
|
||||
|
||||
#if MAJOR_VERSION >= 7
|
||||
namespace xsd {
|
||||
using namespace ::android::audio::policy::configuration::V7_0;
|
||||
}
|
||||
|
||||
bool audioInputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_input_flags_t* halFlags) {
|
||||
bool success = true;
|
||||
*halFlags = {};
|
||||
for (const auto& flag : flags) {
|
||||
audio_input_flags_t halFlag;
|
||||
if (!xsd::isUnknownAudioInOutFlag(flag) &&
|
||||
audio_input_flag_from_string(flag.c_str(), &halFlag)) {
|
||||
*halFlags = static_cast<audio_input_flags_t>(*halFlags | halFlag);
|
||||
} else {
|
||||
ALOGE("Unknown audio input flag \"%s\"", flag.c_str());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool audioOutputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_output_flags_t* halFlags) {
|
||||
bool success = true;
|
||||
*halFlags = {};
|
||||
for (const auto& flag : flags) {
|
||||
audio_output_flags_t halFlag;
|
||||
if (!xsd::isUnknownAudioInOutFlag(flag) &&
|
||||
audio_output_flag_from_string(flag.c_str(), &halFlag)) {
|
||||
*halFlags = static_cast<audio_output_flags_t>(*halFlags | halFlag);
|
||||
} else {
|
||||
ALOGE("Unknown audio output flag \"%s\"", flag.c_str());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -150,63 +150,76 @@ Return<void> Device::getInputBufferSize(const AudioConfig& config, getInputBuffe
|
||||
std::tuple<Result, sp<IStreamOut>> Device::openOutputStreamImpl(int32_t ioHandle,
|
||||
const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioOutputFlagBitfield flags,
|
||||
const AudioOutputFlags& flags,
|
||||
AudioConfig* suggestedConfig) {
|
||||
audio_config_t halConfig;
|
||||
HidlUtils::audioConfigToHal(config, &halConfig);
|
||||
audio_stream_out_t* halStream;
|
||||
ALOGV(
|
||||
"open_output_stream handle: %d devices: %x flags: %#x "
|
||||
"srate: %d format %#x channels %x address %s",
|
||||
ioHandle, static_cast<audio_devices_t>(device.device),
|
||||
static_cast<audio_output_flags_t>(flags), halConfig.sample_rate, halConfig.format,
|
||||
halConfig.channel_mask, deviceAddressToHal(device).c_str());
|
||||
int status =
|
||||
mDevice->open_output_stream(mDevice, ioHandle, static_cast<audio_devices_t>(device.device),
|
||||
static_cast<audio_output_flags_t>(flags), &halConfig,
|
||||
&halStream, deviceAddressToHal(device).c_str());
|
||||
audio_devices_t halDevice;
|
||||
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
if (deviceAddressToHal(device, &halDevice, halDeviceAddress) != NO_ERROR) {
|
||||
return {Result::INVALID_ARGUMENTS, nullptr};
|
||||
}
|
||||
audio_output_flags_t halFlags;
|
||||
if (!audioOutputFlagsToHal(flags, &halFlags)) {
|
||||
return {Result::INVALID_ARGUMENTS, nullptr};
|
||||
}
|
||||
ALOGV("open_output_stream handle: %d devices: %x flags: %#x "
|
||||
"srate: %d format %#x channels %x address %s",
|
||||
ioHandle, halDevice, halFlags, halConfig.sample_rate, halConfig.format,
|
||||
halConfig.channel_mask, halDeviceAddress);
|
||||
int status = mDevice->open_output_stream(mDevice, ioHandle, halDevice, halFlags, &halConfig,
|
||||
&halStream, halDeviceAddress);
|
||||
ALOGV("open_output_stream status %d stream %p", status, halStream);
|
||||
sp<IStreamOut> streamOut;
|
||||
if (status == OK) {
|
||||
streamOut = new StreamOut(this, halStream);
|
||||
++mOpenedStreamsCount;
|
||||
}
|
||||
status_t convertStatus = HidlUtils::audioConfigFromHal(halConfig, suggestedConfig);
|
||||
status_t convertStatus =
|
||||
HidlUtils::audioConfigFromHal(halConfig, false /*isInput*/, suggestedConfig);
|
||||
ALOGW_IF(convertStatus != OK, "%s: suggested config with incompatible fields", __func__);
|
||||
return {analyzeStatus("open_output_stream", status, {EINVAL} /*ignore*/), streamOut};
|
||||
}
|
||||
|
||||
std::tuple<Result, sp<IStreamIn>> Device::openInputStreamImpl(
|
||||
int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
|
||||
AudioInputFlagBitfield flags, AudioSource source, AudioConfig* suggestedConfig) {
|
||||
int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
|
||||
const AudioInputFlags& flags, AudioSource source, AudioConfig* suggestedConfig) {
|
||||
audio_config_t halConfig;
|
||||
HidlUtils::audioConfigToHal(config, &halConfig);
|
||||
audio_stream_in_t* halStream;
|
||||
ALOGV(
|
||||
"open_input_stream handle: %d devices: %x flags: %#x "
|
||||
"srate: %d format %#x channels %x address %s source %d",
|
||||
ioHandle, static_cast<audio_devices_t>(device.device),
|
||||
static_cast<audio_input_flags_t>(flags), halConfig.sample_rate, halConfig.format,
|
||||
halConfig.channel_mask, deviceAddressToHal(device).c_str(),
|
||||
static_cast<audio_source_t>(source));
|
||||
int status = mDevice->open_input_stream(
|
||||
mDevice, ioHandle, static_cast<audio_devices_t>(device.device), &halConfig, &halStream,
|
||||
static_cast<audio_input_flags_t>(flags), deviceAddressToHal(device).c_str(),
|
||||
static_cast<audio_source_t>(source));
|
||||
audio_devices_t halDevice;
|
||||
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
if (deviceAddressToHal(device, &halDevice, halDeviceAddress) != NO_ERROR) {
|
||||
return {Result::INVALID_ARGUMENTS, nullptr};
|
||||
}
|
||||
audio_input_flags_t halFlags;
|
||||
audio_source_t halSource;
|
||||
if (!audioInputFlagsToHal(flags, &halFlags) ||
|
||||
HidlUtils::audioSourceToHal(source, &halSource) != NO_ERROR) {
|
||||
return {Result::INVALID_ARGUMENTS, nullptr};
|
||||
}
|
||||
ALOGV("open_input_stream handle: %d devices: %x flags: %#x "
|
||||
"srate: %d format %#x channels %x address %s source %d",
|
||||
ioHandle, halDevice, halFlags, halConfig.sample_rate, halConfig.format,
|
||||
halConfig.channel_mask, halDeviceAddress, halSource);
|
||||
int status = mDevice->open_input_stream(mDevice, ioHandle, halDevice, &halConfig, &halStream,
|
||||
halFlags, halDeviceAddress, halSource);
|
||||
ALOGV("open_input_stream status %d stream %p", status, halStream);
|
||||
sp<IStreamIn> streamIn;
|
||||
if (status == OK) {
|
||||
streamIn = new StreamIn(this, halStream);
|
||||
++mOpenedStreamsCount;
|
||||
}
|
||||
status_t convertStatus = HidlUtils::audioConfigFromHal(halConfig, suggestedConfig);
|
||||
status_t convertStatus =
|
||||
HidlUtils::audioConfigFromHal(halConfig, true /*isInput*/, suggestedConfig);
|
||||
ALOGW_IF(convertStatus != OK, "%s: suggested config with incompatible fields", __func__);
|
||||
return {analyzeStatus("open_input_stream", status, {EINVAL} /*ignore*/), streamIn};
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION == 2
|
||||
Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioOutputFlagBitfield flags,
|
||||
const AudioConfig& config, AudioOutputFlags flags,
|
||||
openOutputStream_cb _hidl_cb) {
|
||||
AudioConfig suggestedConfig;
|
||||
auto [result, streamOut] =
|
||||
@@ -216,7 +229,7 @@ Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& dev
|
||||
}
|
||||
|
||||
Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
const AudioConfig& config, AudioInputFlags flags,
|
||||
AudioSource source, openInputStream_cb _hidl_cb) {
|
||||
AudioConfig suggestedConfig;
|
||||
auto [result, streamIn] =
|
||||
@@ -227,7 +240,12 @@ Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& devi
|
||||
|
||||
#elif MAJOR_VERSION >= 4
|
||||
Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioOutputFlagBitfield flags,
|
||||
const AudioConfig& config,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioOutputFlags flags,
|
||||
#else
|
||||
const AudioOutputFlags& flags,
|
||||
#endif
|
||||
const SourceMetadata& sourceMetadata,
|
||||
openOutputStream_cb _hidl_cb) {
|
||||
AudioConfig suggestedConfig;
|
||||
@@ -241,7 +259,12 @@ Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& dev
|
||||
}
|
||||
|
||||
Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
const AudioConfig& config,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioInputFlags flags,
|
||||
#else
|
||||
const AudioInputFlags& flags,
|
||||
#endif
|
||||
const SinkMetadata& sinkMetadata,
|
||||
openInputStream_cb _hidl_cb) {
|
||||
if (sinkMetadata.tracks.size() == 0) {
|
||||
@@ -271,9 +294,7 @@ Return<bool> Device::supportsAudioPatches() {
|
||||
Return<void> Device::createAudioPatch(const hidl_vec<AudioPortConfig>& sources,
|
||||
const hidl_vec<AudioPortConfig>& sinks,
|
||||
createAudioPatch_cb _hidl_cb) {
|
||||
auto [retval, patch] = createOrUpdateAudioPatch(
|
||||
static_cast<AudioPatchHandle>(AudioHandleConsts::AUDIO_PATCH_HANDLE_NONE), sources,
|
||||
sinks);
|
||||
auto [retval, patch] = createOrUpdateAudioPatch(AudioPatchHandle{}, sources, sinks);
|
||||
_hidl_cb(retval, patch);
|
||||
return Void();
|
||||
}
|
||||
@@ -454,7 +475,7 @@ Return<void> Device::updateAudioPatch(int32_t previousPatch,
|
||||
const hidl_vec<AudioPortConfig>& sources,
|
||||
const hidl_vec<AudioPortConfig>& sinks,
|
||||
createAudioPatch_cb _hidl_cb) {
|
||||
if (previousPatch != static_cast<int32_t>(AudioHandleConsts::AUDIO_PATCH_HANDLE_NONE)) {
|
||||
if (previousPatch != static_cast<int32_t>(AudioPatchHandle{})) {
|
||||
auto [retval, patch] = createOrUpdateAudioPatch(previousPatch, sources, sinks);
|
||||
_hidl_cb(retval, patch);
|
||||
} else {
|
||||
|
||||
@@ -149,9 +149,15 @@ Result ParametersUtil::setParametersImpl(const hidl_vec<ParameterValue>& context
|
||||
}
|
||||
return setParams(params);
|
||||
}
|
||||
|
||||
Result ParametersUtil::setParam(const char* name, const DeviceAddress& address) {
|
||||
AudioParameter params(String8(deviceAddressToHal(address).c_str()));
|
||||
params.addInt(String8(name), int(address.device));
|
||||
audio_devices_t halDeviceType;
|
||||
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
if (deviceAddressToHal(address, &halDeviceType, halDeviceAddress) != NO_ERROR) {
|
||||
return Result::INVALID_ARGUMENTS;
|
||||
}
|
||||
AudioParameter params{String8(halDeviceAddress)};
|
||||
params.addInt(String8(name), halDeviceType);
|
||||
return setParams(params);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,28 +73,36 @@ Return<void> PrimaryDevice::getInputBufferSize(const AudioConfig& config,
|
||||
|
||||
#if MAJOR_VERSION == 2
|
||||
Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioOutputFlagBitfield flags,
|
||||
const AudioConfig& config, AudioOutputFlags flags,
|
||||
openOutputStream_cb _hidl_cb) {
|
||||
return mDevice->openOutputStream(ioHandle, device, config, flags, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> PrimaryDevice::openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
const AudioConfig& config, AudioInputFlags flags,
|
||||
AudioSource source, openInputStream_cb _hidl_cb) {
|
||||
return mDevice->openInputStream(ioHandle, device, config, flags, source, _hidl_cb);
|
||||
}
|
||||
#elif MAJOR_VERSION >= 4
|
||||
Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioOutputFlagBitfield flags,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioOutputFlags flags,
|
||||
#else
|
||||
const AudioOutputFlags& flags,
|
||||
#endif
|
||||
const SourceMetadata& sourceMetadata,
|
||||
openOutputStream_cb _hidl_cb) {
|
||||
return mDevice->openOutputStream(ioHandle, device, config, flags, sourceMetadata, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> PrimaryDevice::openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
const AudioConfig& config,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioInputFlags flags,
|
||||
#else
|
||||
const AudioInputFlags& flags,
|
||||
#endif
|
||||
const SinkMetadata& sinkMetadata,
|
||||
openInputStream_cb _hidl_cb) {
|
||||
return mDevice->openInputStream(ioHandle, device, config, flags, sinkMetadata, _hidl_cb);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <HidlUtils.h>
|
||||
#include <android/log.h>
|
||||
#include <hardware/audio.h>
|
||||
#include <hardware/audio_effect.h>
|
||||
@@ -35,7 +36,11 @@ namespace audio {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
Stream::Stream(audio_stream_t* stream) : mStream(stream) {}
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
Stream::Stream(bool isInput, audio_stream_t* stream) : mIsInput(isInput), mStream(stream) {
|
||||
(void)mIsInput; // prevent 'unused field' warnings in pre-V7 versions.
|
||||
}
|
||||
|
||||
Stream::~Stream() {
|
||||
mStream = nullptr;
|
||||
@@ -78,6 +83,7 @@ Return<uint64_t> Stream::getBufferSize() {
|
||||
return mStream->get_buffer_size(mStream);
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<uint32_t> Stream::getSampleRate() {
|
||||
return mStream->get_sample_rate(mStream);
|
||||
}
|
||||
@@ -201,6 +207,96 @@ Return<void> Stream::getAudioProperties(getAudioProperties_cb _hidl_cb) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
#else // MAJOR_VERSION <= 6
|
||||
|
||||
Return<void> Stream::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) {
|
||||
String8 halListValue;
|
||||
Result result = getParam(AudioParameter::keyStreamSupportedFormats, &halListValue);
|
||||
hidl_vec<AudioProfile> profiles;
|
||||
if (result != Result::OK) {
|
||||
_hidl_cb(result, profiles);
|
||||
return Void();
|
||||
}
|
||||
// Ensure that the separator is one character, despite that it's defined as a C string.
|
||||
static_assert(sizeof(AUDIO_PARAMETER_VALUE_LIST_SEPARATOR) == 2);
|
||||
std::vector<std::string> halFormats =
|
||||
util::splitString(halListValue.string(), AUDIO_PARAMETER_VALUE_LIST_SEPARATOR[0]);
|
||||
hidl_vec<AudioFormat> formats;
|
||||
(void)HidlUtils::audioFormatsFromHal(halFormats, &formats);
|
||||
std::vector<AudioProfile> tempProfiles;
|
||||
for (const auto& format : formats) {
|
||||
audio_format_t halFormat;
|
||||
if (status_t status = HidlUtils::audioFormatToHal(format, &halFormat); status != NO_ERROR) {
|
||||
continue;
|
||||
}
|
||||
AudioParameter context;
|
||||
context.addInt(String8(AUDIO_PARAMETER_STREAM_FORMAT), int(halFormat));
|
||||
// Query supported sample rates for the format.
|
||||
result = getParam(AudioParameter::keyStreamSupportedSamplingRates, &halListValue, context);
|
||||
if (result != Result::OK) break;
|
||||
std::vector<std::string> halSampleRates =
|
||||
util::splitString(halListValue.string(), AUDIO_PARAMETER_VALUE_LIST_SEPARATOR[0]);
|
||||
hidl_vec<uint32_t> sampleRates;
|
||||
sampleRates.resize(halSampleRates.size());
|
||||
for (size_t i = 0; i < sampleRates.size(); ++i) {
|
||||
sampleRates[i] = std::stoi(halSampleRates[i]);
|
||||
}
|
||||
// Query supported channel masks for the format.
|
||||
result = getParam(AudioParameter::keyStreamSupportedChannels, &halListValue, context);
|
||||
if (result != Result::OK) break;
|
||||
std::vector<std::string> halChannelMasks =
|
||||
util::splitString(halListValue.string(), AUDIO_PARAMETER_VALUE_LIST_SEPARATOR[0]);
|
||||
hidl_vec<AudioChannelMask> channelMasks;
|
||||
(void)HidlUtils::audioChannelMasksFromHal(halChannelMasks, &channelMasks);
|
||||
// Create a profile.
|
||||
if (channelMasks.size() != 0 && sampleRates.size() != 0) {
|
||||
tempProfiles.push_back({.format = format,
|
||||
.sampleRates = std::move(sampleRates),
|
||||
.channelMasks = std::move(channelMasks)});
|
||||
}
|
||||
}
|
||||
// Legacy get_parameter does not return a status_t, thus can not advertise of failure.
|
||||
// Note that the method must not return an empty list if this capability is supported.
|
||||
if (!tempProfiles.empty()) {
|
||||
profiles = tempProfiles;
|
||||
} else {
|
||||
result = Result::NOT_SUPPORTED;
|
||||
}
|
||||
_hidl_cb(result, profiles);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Stream::getAudioProperties(getAudioProperties_cb _hidl_cb) {
|
||||
audio_config_base_t halConfigBase = {mStream->get_sample_rate(mStream),
|
||||
mStream->get_channels(mStream),
|
||||
mStream->get_format(mStream)};
|
||||
AudioConfigBase configBase = {};
|
||||
status_t status = HidlUtils::audioConfigBaseFromHal(halConfigBase, mIsInput, &configBase);
|
||||
_hidl_cb(Stream::analyzeStatus("get_audio_properties", status), configBase);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Result> Stream::setAudioProperties(const AudioConfigBase& config) {
|
||||
audio_config_base_t halConfigBase = {};
|
||||
status_t status = HidlUtils::audioConfigBaseToHal(config, &halConfigBase);
|
||||
if (status != NO_ERROR) {
|
||||
return Stream::analyzeStatus("set_audio_properties", status);
|
||||
}
|
||||
if (Result result = setParam(AudioParameter::keySamplingRate,
|
||||
static_cast<int>(halConfigBase.sample_rate));
|
||||
result != Result::OK) {
|
||||
return result;
|
||||
}
|
||||
if (Result result =
|
||||
setParam(AudioParameter::keyChannels, static_cast<int>(halConfigBase.channel_mask));
|
||||
result != Result::OK) {
|
||||
return result;
|
||||
}
|
||||
return setParam(AudioParameter::keyFormat, static_cast<int>(halConfigBase.format));
|
||||
}
|
||||
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
|
||||
Return<Result> Stream::addEffect(uint64_t effectId) {
|
||||
effect_handle_t halEffect = EffectMap::getInstance().get(effectId);
|
||||
if (halEffect != NULL) {
|
||||
@@ -257,12 +353,14 @@ Return<Result> Stream::setConnectedState(const DeviceAddress& address, bool conn
|
||||
}
|
||||
#elif MAJOR_VERSION >= 4
|
||||
Return<void> Stream::getDevices(getDevices_cb _hidl_cb) {
|
||||
int device = 0;
|
||||
Result retval = getParam(AudioParameter::keyRouting, &device);
|
||||
int halDevice = 0;
|
||||
Result retval = getParam(AudioParameter::keyRouting, &halDevice);
|
||||
hidl_vec<DeviceAddress> devices;
|
||||
if (retval == Result::OK) {
|
||||
devices.resize(1);
|
||||
devices[0].device = static_cast<AudioDevice>(device);
|
||||
retval = Stream::analyzeStatus("get_devices",
|
||||
deviceAddressFromHal(static_cast<audio_devices_t>(halDevice),
|
||||
nullptr, &devices[0]));
|
||||
}
|
||||
_hidl_cb(retval, devices);
|
||||
return Void();
|
||||
@@ -273,14 +371,13 @@ Return<Result> Stream::setDevices(const hidl_vec<DeviceAddress>& devices) {
|
||||
if (devices.size() > 1) {
|
||||
return Result::NOT_SUPPORTED;
|
||||
}
|
||||
DeviceAddress address;
|
||||
DeviceAddress address{};
|
||||
if (devices.size() == 1) {
|
||||
address = devices[0];
|
||||
} else {
|
||||
address.device = AudioDevice::NONE;
|
||||
}
|
||||
return setParam(AudioParameter::keyRouting, address);
|
||||
}
|
||||
|
||||
Return<void> Stream::getParameters(const hidl_vec<ParameterValue>& context,
|
||||
const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) {
|
||||
getParametersImpl(context, keys, _hidl_cb);
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
//#define LOG_NDEBUG 0
|
||||
#define ATRACE_TAG ATRACE_TAG_AUDIO
|
||||
|
||||
#include <HidlUtils.h>
|
||||
#include <android/log.h>
|
||||
#include <hardware/audio.h>
|
||||
#include <utils/Trace.h>
|
||||
#include <memory>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
@@ -36,6 +37,8 @@ namespace audio {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
namespace {
|
||||
|
||||
class ReadThread : public Thread {
|
||||
@@ -141,7 +144,7 @@ bool ReadThread::threadLoop() {
|
||||
StreamIn::StreamIn(const sp<Device>& device, audio_stream_in_t* stream)
|
||||
: mDevice(device),
|
||||
mStream(stream),
|
||||
mStreamCommon(new Stream(&stream->common)),
|
||||
mStreamCommon(new Stream(true /*isInput*/, &stream->common)),
|
||||
mStreamMmap(new StreamMmap<audio_stream_in_t>(stream)),
|
||||
mEfGroup(nullptr),
|
||||
mStopReadThread(false) {}
|
||||
@@ -177,6 +180,7 @@ Return<uint64_t> StreamIn::getBufferSize() {
|
||||
return mStreamCommon->getBufferSize();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<uint32_t> StreamIn::getSampleRate() {
|
||||
return mStreamCommon->getSampleRate();
|
||||
}
|
||||
@@ -223,6 +227,18 @@ Return<Result> StreamIn::setFormat(AudioFormat format) {
|
||||
return mStreamCommon->setFormat(format);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
Return<void> StreamIn::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) {
|
||||
return mStreamCommon->getSupportedProfiles(_hidl_cb);
|
||||
}
|
||||
|
||||
Return<Result> StreamIn::setAudioProperties(const AudioConfigBase& config) {
|
||||
return mStreamCommon->setAudioProperties(config);
|
||||
}
|
||||
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
|
||||
Return<void> StreamIn::getAudioProperties(getAudioProperties_cb _hidl_cb) {
|
||||
return mStreamCommon->getAudioProperties(_hidl_cb);
|
||||
}
|
||||
@@ -321,9 +337,11 @@ Return<Result> StreamIn::close() {
|
||||
Return<void> StreamIn::getAudioSource(getAudioSource_cb _hidl_cb) {
|
||||
int halSource;
|
||||
Result retval = mStreamCommon->getParam(AudioParameter::keyInputSource, &halSource);
|
||||
AudioSource source(AudioSource::DEFAULT);
|
||||
AudioSource source = {};
|
||||
if (retval == Result::OK) {
|
||||
source = AudioSource(halSource);
|
||||
retval = Stream::analyzeStatus(
|
||||
"get_audio_source",
|
||||
HidlUtils::audioSourceFromHal(static_cast<audio_source_t>(halSource), &source));
|
||||
}
|
||||
_hidl_cb(retval, source);
|
||||
return Void();
|
||||
@@ -340,7 +358,11 @@ Return<Result> StreamIn::setGain(float gain) {
|
||||
Return<void> StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCount,
|
||||
prepareForReading_cb _hidl_cb) {
|
||||
status_t status;
|
||||
#if MAJOR_VERSION <= 6
|
||||
ThreadInfo threadInfo = {0, 0};
|
||||
#else
|
||||
int32_t threadInfo = 0;
|
||||
#endif
|
||||
|
||||
// Wrap the _hidl_cb to return an error
|
||||
auto sendError = [&threadInfo, &_hidl_cb](Result result) {
|
||||
@@ -410,8 +432,12 @@ Return<void> StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCoun
|
||||
mStatusMQ = std::move(tempStatusMQ);
|
||||
mReadThread = tempReadThread.release();
|
||||
mEfGroup = tempElfGroup.release();
|
||||
#if MAJOR_VERSION <= 6
|
||||
threadInfo.pid = getpid();
|
||||
threadInfo.tid = mReadThread->getTid();
|
||||
#else
|
||||
threadInfo = mReadThread->getTid();
|
||||
#endif
|
||||
_hidl_cb(Result::OK, *mCommandMQ->getDesc(), *mDataMQ->getDesc(), *mStatusMQ->getDesc(),
|
||||
threadInfo);
|
||||
return Void();
|
||||
@@ -459,16 +485,13 @@ Return<void> StreamIn::updateSinkMetadata(const SinkMetadata& sinkMetadata) {
|
||||
std::vector<record_track_metadata> halTracks;
|
||||
halTracks.reserve(sinkMetadata.tracks.size());
|
||||
for (auto& metadata : sinkMetadata.tracks) {
|
||||
record_track_metadata halTrackMetadata = {
|
||||
.source = static_cast<audio_source_t>(metadata.source), .gain = metadata.gain};
|
||||
record_track_metadata halTrackMetadata = {.gain = metadata.gain};
|
||||
(void)HidlUtils::audioSourceToHal(metadata.source, &halTrackMetadata.source);
|
||||
#if MAJOR_VERSION >= 5
|
||||
if (metadata.destination.getDiscriminator() ==
|
||||
RecordTrackMetadata::Destination::hidl_discriminator::device) {
|
||||
halTrackMetadata.dest_device =
|
||||
static_cast<audio_devices_t>(metadata.destination.device().device);
|
||||
strncpy(halTrackMetadata.dest_device_address,
|
||||
deviceAddressToHal(metadata.destination.device()).c_str(),
|
||||
AUDIO_DEVICE_MAX_ADDRESS_LEN);
|
||||
(void)deviceAddressToHal(metadata.destination.device(), &halTrackMetadata.dest_device,
|
||||
halTrackMetadata.dest_device_address);
|
||||
}
|
||||
#endif
|
||||
halTracks.push_back(halTrackMetadata);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <HidlUtils.h>
|
||||
#include <android/log.h>
|
||||
#include <hardware/audio.h>
|
||||
#include <utils/Trace.h>
|
||||
@@ -36,6 +37,8 @@ namespace audio {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
namespace {
|
||||
|
||||
class WriteThread : public Thread {
|
||||
@@ -142,7 +145,7 @@ bool WriteThread::threadLoop() {
|
||||
StreamOut::StreamOut(const sp<Device>& device, audio_stream_out_t* stream)
|
||||
: mDevice(device),
|
||||
mStream(stream),
|
||||
mStreamCommon(new Stream(&stream->common)),
|
||||
mStreamCommon(new Stream(false /*isInput*/, &stream->common)),
|
||||
mStreamMmap(new StreamMmap<audio_stream_out_t>(stream)),
|
||||
mEfGroup(nullptr),
|
||||
mStopWriteThread(false) {}
|
||||
@@ -182,6 +185,7 @@ Return<uint64_t> StreamOut::getBufferSize() {
|
||||
return mStreamCommon->getBufferSize();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<uint32_t> StreamOut::getSampleRate() {
|
||||
return mStreamCommon->getSampleRate();
|
||||
}
|
||||
@@ -228,6 +232,18 @@ Return<Result> StreamOut::setFormat(AudioFormat format) {
|
||||
return mStreamCommon->setFormat(format);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
Return<void> StreamOut::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) {
|
||||
return mStreamCommon->getSupportedProfiles(_hidl_cb);
|
||||
}
|
||||
|
||||
Return<Result> StreamOut::setAudioProperties(const AudioConfigBase& config) {
|
||||
return mStreamCommon->setAudioProperties(config);
|
||||
}
|
||||
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
|
||||
Return<void> StreamOut::getAudioProperties(getAudioProperties_cb _hidl_cb) {
|
||||
return mStreamCommon->getAudioProperties(_hidl_cb);
|
||||
}
|
||||
@@ -327,7 +343,11 @@ Return<Result> StreamOut::setVolume(float left, float right) {
|
||||
Return<void> StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCount,
|
||||
prepareForWriting_cb _hidl_cb) {
|
||||
status_t status;
|
||||
#if MAJOR_VERSION <= 6
|
||||
ThreadInfo threadInfo = {0, 0};
|
||||
#else
|
||||
int32_t threadInfo = 0;
|
||||
#endif
|
||||
|
||||
// Wrap the _hidl_cb to return an error
|
||||
auto sendError = [&threadInfo, &_hidl_cb](Result result) {
|
||||
@@ -396,8 +416,12 @@ Return<void> StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCou
|
||||
mStatusMQ = std::move(tempStatusMQ);
|
||||
mWriteThread = tempWriteThread.release();
|
||||
mEfGroup = tempElfGroup.release();
|
||||
#if MAJOR_VERSION <= 6
|
||||
threadInfo.pid = getpid();
|
||||
threadInfo.tid = mWriteThread->getTid();
|
||||
#else
|
||||
threadInfo = mWriteThread->getTid();
|
||||
#endif
|
||||
_hidl_cb(Result::OK, *mCommandMQ->getDesc(), *mDataMQ->getDesc(), *mStatusMQ->getDesc(),
|
||||
threadInfo);
|
||||
return Void();
|
||||
@@ -565,14 +589,14 @@ Return<void> StreamOut::updateSourceMetadata(const SourceMetadata& sourceMetadat
|
||||
if (mStream->update_source_metadata == nullptr) {
|
||||
return Void(); // not supported by the HAL
|
||||
}
|
||||
std::vector<playback_track_metadata> halTracks;
|
||||
std::vector<playback_track_metadata_t> halTracks;
|
||||
halTracks.reserve(sourceMetadata.tracks.size());
|
||||
for (auto& metadata : sourceMetadata.tracks) {
|
||||
halTracks.push_back({
|
||||
.usage = static_cast<audio_usage_t>(metadata.usage),
|
||||
.content_type = static_cast<audio_content_type_t>(metadata.contentType),
|
||||
.gain = metadata.gain,
|
||||
});
|
||||
playback_track_metadata_t halTrackMetadata = {.gain = metadata.gain};
|
||||
(void)HidlUtils::audioUsageToHal(metadata.usage, &halTrackMetadata.usage);
|
||||
(void)HidlUtils::audioContentTypeToHal(metadata.contentType,
|
||||
&halTrackMetadata.content_type);
|
||||
halTracks.push_back(std::move(halTrackMetadata));
|
||||
}
|
||||
const source_metadata_t halMetadata = {
|
||||
.track_count = halTracks.size(),
|
||||
|
||||
@@ -23,22 +23,54 @@
|
||||
|
||||
#include <system/audio.h>
|
||||
|
||||
#include <VersionUtils.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::hidl_vec;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
// Temporary version for compatibility with forks of the default implementation.
|
||||
// Will be removed, do not use!
|
||||
std::string deviceAddressToHal(const DeviceAddress& address);
|
||||
#endif
|
||||
|
||||
status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
|
||||
char* halDeviceAddress);
|
||||
status_t deviceAddressFromHal(audio_devices_t halDeviceType, const char* halDeviceAddress,
|
||||
DeviceAddress* device);
|
||||
|
||||
#if MAJOR_VERSION >= 4
|
||||
bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst,
|
||||
const struct audio_microphone_characteristic_t& src);
|
||||
#endif
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
using AudioInputFlags =
|
||||
::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
|
||||
using AudioOutputFlags =
|
||||
::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
|
||||
|
||||
inline bool audioInputFlagsToHal(AudioInputFlags flags, audio_input_flags_t* halFlags) {
|
||||
*halFlags = static_cast<audio_input_flags_t>(flags);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool audioOutputFlagsToHal(AudioOutputFlags flags, audio_output_flags_t* halFlags) {
|
||||
*halFlags = static_cast<audio_output_flags_t>(flags);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool audioInputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_input_flags_t* halFlags);
|
||||
bool audioOutputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_output_flags_t* halFlags);
|
||||
#endif
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
} // namespace audio
|
||||
|
||||
@@ -44,8 +44,13 @@ using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
#if MAJOR_VERSION <= 6
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
|
||||
using AudioInputFlags =
|
||||
::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
|
||||
using AudioOutputFlags =
|
||||
::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
|
||||
#else
|
||||
using AudioInputFlags = hidl_vec<::android::hardware::audio::CPP_VERSION::AudioInOutFlag>;
|
||||
using AudioOutputFlags = hidl_vec<::android::hardware::audio::CPP_VERSION::AudioInOutFlag>;
|
||||
#endif
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
@@ -67,28 +72,36 @@ struct Device : public IDevice, public ParametersUtil {
|
||||
std::tuple<Result, sp<IStreamOut>> openOutputStreamImpl(int32_t ioHandle,
|
||||
const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
AudioOutputFlagBitfield flags,
|
||||
const AudioOutputFlags& flags,
|
||||
AudioConfig* suggestedConfig);
|
||||
std::tuple<Result, sp<IStreamIn>> openInputStreamImpl(
|
||||
int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
|
||||
AudioInputFlagBitfield flags, AudioSource source, AudioConfig* suggestedConfig);
|
||||
#if MAJOR_VERSION == 2
|
||||
int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
|
||||
const AudioInputFlags& flags, AudioSource source, AudioConfig* suggestedConfig);
|
||||
|
||||
Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioOutputFlagBitfield flags,
|
||||
openOutputStream_cb _hidl_cb) override;
|
||||
Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
AudioSource source, openInputStream_cb _hidl_cb) override;
|
||||
#elif MAJOR_VERSION >= 4
|
||||
Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioOutputFlagBitfield flags,
|
||||
const SourceMetadata& sourceMetadata,
|
||||
openOutputStream_cb _hidl_cb) override;
|
||||
Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
const SinkMetadata& sinkMetadata,
|
||||
openInputStream_cb _hidl_cb) override;
|
||||
const AudioConfig& config,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioOutputFlags flags,
|
||||
#else
|
||||
const AudioOutputFlags& flags,
|
||||
#endif
|
||||
#if MAJOR_VERSION >= 4
|
||||
const SourceMetadata& sourceMetadata,
|
||||
#endif
|
||||
openOutputStream_cb _hidl_cb) override;
|
||||
Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioInputFlags flags,
|
||||
#else
|
||||
const AudioInputFlags& flags,
|
||||
#endif
|
||||
#if MAJOR_VERSION == 2
|
||||
AudioSource source,
|
||||
#elif MAJOR_VERSION >= 4
|
||||
const SinkMetadata& sinkMetadata,
|
||||
#endif
|
||||
openInputStream_cb _hidl_cb) override;
|
||||
|
||||
Return<bool> supportsAudioPatches() override;
|
||||
Return<void> createAudioPatch(const hidl_vec<AudioPortConfig>& sources,
|
||||
|
||||
@@ -54,21 +54,29 @@ struct PrimaryDevice : public IPrimaryDevice {
|
||||
getInputBufferSize_cb _hidl_cb) override;
|
||||
|
||||
Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioOutputFlagBitfield flags,
|
||||
const AudioConfig& config,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioOutputFlags flags,
|
||||
#else
|
||||
const AudioOutputFlags& flags,
|
||||
#endif
|
||||
#if MAJOR_VERSION >= 4
|
||||
const SourceMetadata& sourceMetadata,
|
||||
#endif
|
||||
openOutputStream_cb _hidl_cb) override;
|
||||
|
||||
Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
AudioSource source, openInputStream_cb _hidl_cb);
|
||||
#if MAJOR_VERSION >= 4
|
||||
Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
|
||||
const AudioConfig& config, AudioInputFlagBitfield flags,
|
||||
const SinkMetadata& sinkMetadata,
|
||||
openInputStream_cb _hidl_cb) override;
|
||||
const AudioConfig& config,
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioInputFlags flags,
|
||||
#else
|
||||
const AudioInputFlags& flags,
|
||||
#endif
|
||||
#if MAJOR_VERSION == 2
|
||||
AudioSource source,
|
||||
#elif MAJOR_VERSION >= 4
|
||||
const SinkMetadata& sinkMetadata,
|
||||
#endif
|
||||
openInputStream_cb _hidl_cb) override;
|
||||
|
||||
Return<bool> supportsAudioPatches() override;
|
||||
Return<void> createAudioPatch(const hidl_vec<AudioPortConfig>& sources,
|
||||
|
||||
@@ -41,12 +41,14 @@ using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
#if MAJOR_VERSION <= 6
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
|
||||
#endif
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
struct Stream : public IStream, public ParametersUtil {
|
||||
explicit Stream(audio_stream_t* stream);
|
||||
Stream(bool isInput, audio_stream_t* stream);
|
||||
|
||||
/** 1GiB is the maximum buffer size the HAL client is allowed to request.
|
||||
* This value has been chosen to be under SIZE_MAX and still big enough
|
||||
@@ -59,6 +61,7 @@ struct Stream : public IStream, public ParametersUtil {
|
||||
Return<uint64_t> getFrameSize() override;
|
||||
Return<uint64_t> getFrameCount() override;
|
||||
Return<uint64_t> getBufferSize() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<uint32_t> getSampleRate() override;
|
||||
#if MAJOR_VERSION == 2
|
||||
Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
|
||||
@@ -72,6 +75,10 @@ struct Stream : public IStream, public ParametersUtil {
|
||||
Return<AudioFormat> getFormat() override;
|
||||
Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
|
||||
Return<Result> setFormat(AudioFormat format) override;
|
||||
#else
|
||||
Return<void> getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) override;
|
||||
Return<Result> setAudioProperties(const AudioConfigBase& config) override;
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
|
||||
Return<Result> addEffect(uint64_t effectId) override;
|
||||
Return<Result> removeEffect(uint64_t effectId) override;
|
||||
@@ -110,13 +117,14 @@ struct Stream : public IStream, public ParametersUtil {
|
||||
const std::vector<int>& ignoreErrors);
|
||||
|
||||
private:
|
||||
audio_stream_t* mStream;
|
||||
const bool mIsInput;
|
||||
audio_stream_t* mStream;
|
||||
|
||||
virtual ~Stream();
|
||||
virtual ~Stream();
|
||||
|
||||
// Methods from ParametersUtil.
|
||||
char* halGetParameters(const char* keys) override;
|
||||
int halSetParameters(const char* keysAndValues) override;
|
||||
// Methods from ParametersUtil.
|
||||
char* halGetParameters(const char* keys) override;
|
||||
int halSetParameters(const char* keysAndValues) override;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -56,6 +56,7 @@ struct StreamIn : public IStreamIn {
|
||||
Return<uint64_t> getFrameSize() override;
|
||||
Return<uint64_t> getFrameCount() override;
|
||||
Return<uint64_t> getBufferSize() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<uint32_t> getSampleRate() override;
|
||||
#if MAJOR_VERSION == 2
|
||||
Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
|
||||
@@ -69,6 +70,10 @@ struct StreamIn : public IStreamIn {
|
||||
Return<AudioFormat> getFormat() override;
|
||||
Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
|
||||
Return<Result> setFormat(AudioFormat format) override;
|
||||
#else
|
||||
Return<void> getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) override;
|
||||
Return<Result> setAudioProperties(const AudioConfigBase& config) override;
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
|
||||
Return<Result> addEffect(uint64_t effectId) override;
|
||||
Return<Result> removeEffect(uint64_t effectId) override;
|
||||
|
||||
@@ -56,6 +56,7 @@ struct StreamOut : public IStreamOut {
|
||||
Return<uint64_t> getFrameSize() override;
|
||||
Return<uint64_t> getFrameCount() override;
|
||||
Return<uint64_t> getBufferSize() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<uint32_t> getSampleRate() override;
|
||||
#if MAJOR_VERSION == 2
|
||||
Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
|
||||
@@ -69,6 +70,10 @@ struct StreamOut : public IStreamOut {
|
||||
Return<AudioFormat> getFormat() override;
|
||||
Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
|
||||
Return<Result> setFormat(AudioFormat format) override;
|
||||
#else
|
||||
Return<void> getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) override;
|
||||
Return<Result> setAudioProperties(const AudioConfigBase& config) override;
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
|
||||
Return<Result> addEffect(uint64_t effectId) override;
|
||||
Return<Result> removeEffect(uint64_t effectId) override;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include PATH(android/hardware/audio/FILE_VERSION/types.h)
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <system/audio.h>
|
||||
@@ -70,6 +72,16 @@ static inline Result analyzeStatus(const char* className, const char* funcName,
|
||||
return analyzeStatus(status);
|
||||
}
|
||||
|
||||
static inline std::vector<std::string> splitString(const std::string& s, char separator) {
|
||||
std::istringstream iss(s);
|
||||
std::string t;
|
||||
std::vector<std::string> result;
|
||||
while (std::getline(iss, t, separator)) {
|
||||
result.push_back(std::move(t));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
|
||||
@@ -1179,9 +1179,11 @@ static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig)
|
||||
EXPECT_EQ(expectedConfig.channelMask, mask);
|
||||
EXPECT_EQ(expectedConfig.format, format);
|
||||
#elif MAJOR_VERSION >= 7
|
||||
Result res;
|
||||
AudioConfigBase actualConfig{};
|
||||
auto ret = stream->getAudioProperties(returnIn(actualConfig));
|
||||
auto ret = stream->getAudioProperties(returnIn(res, actualConfig));
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
EXPECT_EQ(Result::OK, res);
|
||||
EXPECT_EQ(expectedConfig.base.sampleRateHz, actualConfig.sampleRateHz);
|
||||
EXPECT_EQ(expectedConfig.base.channelMask, actualConfig.channelMask);
|
||||
EXPECT_EQ(expectedConfig.base.format, actualConfig.format);
|
||||
|
||||
@@ -46,23 +46,38 @@ interface IVirtualizerEffect extends IEffect {
|
||||
*/
|
||||
getStrength() generates (Result retval, uint16_t strength);
|
||||
|
||||
struct SpeakerAngle {
|
||||
struct SpeakerAngles {
|
||||
/** Speaker channel mask */
|
||||
vec<AudioChannelMask> mask;
|
||||
// all angles are expressed in degrees and
|
||||
// are relative to the listener.
|
||||
int16_t azimuth; // 0 is the direction the listener faces
|
||||
// 180 is behind the listener
|
||||
// -90 is to their left
|
||||
int16_t elevation; // 0 is the horizontal plane
|
||||
// +90 is above the listener, -90 is below
|
||||
AudioChannelMask mask;
|
||||
/**
|
||||
* Horizontal speaker position angles for each channel ordered from LSb
|
||||
* to MSb in the channel mask. The number of values is the number of
|
||||
* channels in the channel mask.
|
||||
*
|
||||
* All angles are expressed in degrees and are relative to the listener.
|
||||
* - 0 is the direction the listener faces;
|
||||
* - 180 is behind the listener;
|
||||
* - -90 is to their left.
|
||||
*/
|
||||
vec<int16_t> azimuth;
|
||||
/**
|
||||
* Vertical speaker position angles for each channel ordered from LSb
|
||||
* to MSb in the channel mask. The number of values is the number of
|
||||
* channels in the channel mask.
|
||||
*
|
||||
* All angles are expressed in degrees and are relative to the listener.
|
||||
* - 0 is the horizontal plane of the listener;
|
||||
* - +90 is above the listener;
|
||||
* - -90 is below the listener.
|
||||
*/
|
||||
vec<int16_t> elevation;
|
||||
};
|
||||
/**
|
||||
* Retrieves virtual speaker angles for the given channel mask on the
|
||||
* specified device.
|
||||
*/
|
||||
getVirtualSpeakerAngles(vec<AudioChannelMask> mask, DeviceAddress device)
|
||||
generates (Result retval, vec<SpeakerAngle> speakerAngles);
|
||||
getVirtualSpeakerAngles(AudioChannelMask mask, DeviceAddress device)
|
||||
generates (Result retval, SpeakerAngles speakerAngles);
|
||||
|
||||
/**
|
||||
* Forces the virtualizer effect for the given output device.
|
||||
|
||||
@@ -271,9 +271,7 @@ enum EffectConfigParameters : int32_t {
|
||||
*/
|
||||
struct EffectBufferConfig {
|
||||
AudioBuffer buffer;
|
||||
uint32_t samplingRateHz;
|
||||
AudioChannelMask channels;
|
||||
AudioFormat format;
|
||||
AudioConfigBase base;
|
||||
EffectBufferAccess accessMode;
|
||||
bitfield<EffectConfigParameters> mask;
|
||||
};
|
||||
@@ -292,9 +290,9 @@ enum EffectFeature : int32_t {
|
||||
|
||||
struct EffectAuxChannelsConfig {
|
||||
/** Channel mask for main channels. */
|
||||
vec<AudioChannelMask> mainChannels;
|
||||
AudioChannelMask mainChannels;
|
||||
/** Channel mask for auxiliary channels. */
|
||||
vec<AudioChannelMask> auxChannels;
|
||||
AudioChannelMask auxChannels;
|
||||
};
|
||||
|
||||
struct EffectOffloadParameter {
|
||||
|
||||
@@ -31,9 +31,7 @@ namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
AcousticEchoCancelerEffect::AcousticEchoCancelerEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(handle)) {}
|
||||
|
||||
AcousticEchoCancelerEffect::~AcousticEchoCancelerEffect() {}
|
||||
: mEffect(new Effect(true /*isInput*/, handle)) {}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> AcousticEchoCancelerEffect::init() {
|
||||
@@ -58,10 +56,32 @@ Return<Result> AcousticEchoCancelerEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> AcousticEchoCancelerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> AcousticEchoCancelerEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> AcousticEchoCancelerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> AcousticEchoCancelerEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> AcousticEchoCancelerEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> AcousticEchoCancelerEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> AcousticEchoCancelerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -82,10 +102,6 @@ Return<Result> AcousticEchoCancelerEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> AcousticEchoCancelerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> AcousticEchoCancelerEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -108,10 +124,6 @@ Return<Result> AcousticEchoCancelerEffect::setAuxChannelsConfig(
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> AcousticEchoCancelerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> AcousticEchoCancelerEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,15 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -61,14 +69,12 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -98,7 +104,7 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~AcousticEchoCancelerEffect();
|
||||
virtual ~AcousticEchoCancelerEffect() = default;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -105,7 +105,6 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
enabled: false,
|
||||
name: "android.hardware.audio.effect@7.0-impl",
|
||||
defaults: ["android.hardware.audio.effect-impl_default"],
|
||||
shared_libs: [
|
||||
|
||||
@@ -30,9 +30,7 @@ namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
AutomaticGainControlEffect::AutomaticGainControlEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(handle)) {}
|
||||
|
||||
AutomaticGainControlEffect::~AutomaticGainControlEffect() {}
|
||||
: mEffect(new Effect(true /*isInput*/, handle)) {}
|
||||
|
||||
void AutomaticGainControlEffect::propertiesFromHal(
|
||||
const t_agc_settings& halProperties, IAutomaticGainControlEffect::AllProperties* properties) {
|
||||
@@ -71,10 +69,32 @@ Return<Result> AutomaticGainControlEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> AutomaticGainControlEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> AutomaticGainControlEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> AutomaticGainControlEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> AutomaticGainControlEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> AutomaticGainControlEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> AutomaticGainControlEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> AutomaticGainControlEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -95,10 +115,6 @@ Return<Result> AutomaticGainControlEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> AutomaticGainControlEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> AutomaticGainControlEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -121,10 +137,6 @@ Return<Result> AutomaticGainControlEffect::setAuxChannelsConfig(
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> AutomaticGainControlEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> AutomaticGainControlEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,15 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -63,14 +71,12 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -107,7 +113,7 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~AutomaticGainControlEffect();
|
||||
virtual ~AutomaticGainControlEffect() = default;
|
||||
|
||||
void propertiesFromHal(const t_agc_settings& halProperties,
|
||||
IAutomaticGainControlEffect::AllProperties* properties);
|
||||
|
||||
@@ -30,9 +30,8 @@ namespace effect {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
BassBoostEffect::BassBoostEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
|
||||
|
||||
BassBoostEffect::~BassBoostEffect() {}
|
||||
BassBoostEffect::BassBoostEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(false /*isInput*/, handle)) {}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> BassBoostEffect::init() {
|
||||
@@ -57,10 +56,32 @@ Return<Result> BassBoostEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> BassBoostEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> BassBoostEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> BassBoostEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> BassBoostEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> BassBoostEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> BassBoostEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> BassBoostEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -80,10 +101,6 @@ Return<Result> BassBoostEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> BassBoostEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> BassBoostEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -105,10 +122,6 @@ Return<Result> BassBoostEffect::setAuxChannelsConfig(const EffectAuxChannelsConf
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> BassBoostEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> BassBoostEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,15 @@ struct BassBoostEffect : public IBassBoostEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -63,14 +71,12 @@ struct BassBoostEffect : public IBassBoostEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -100,7 +106,7 @@ struct BassBoostEffect : public IBassBoostEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~BassBoostEffect();
|
||||
virtual ~BassBoostEffect() = default;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -30,9 +30,8 @@ namespace effect {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
DownmixEffect::DownmixEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
|
||||
|
||||
DownmixEffect::~DownmixEffect() {}
|
||||
DownmixEffect::DownmixEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(false /*isInput*/, handle)) {}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> DownmixEffect::init() {
|
||||
@@ -57,10 +56,32 @@ Return<Result> DownmixEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> DownmixEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> DownmixEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> DownmixEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> DownmixEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> DownmixEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -80,10 +101,6 @@ Return<Result> DownmixEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> DownmixEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -105,10 +122,6 @@ Return<Result> DownmixEffect::setAuxChannelsConfig(const EffectAuxChannelsConfig
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> DownmixEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,15 @@ struct DownmixEffect : public IDownmixEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -61,14 +69,12 @@ struct DownmixEffect : public IDownmixEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -97,7 +103,7 @@ struct DownmixEffect : public IDownmixEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~DownmixEffect();
|
||||
virtual ~DownmixEffect() = default;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#define ATRACE_TAG ATRACE_TAG_AUDIO
|
||||
|
||||
#include <HidlUtils.h>
|
||||
#include <android/log.h>
|
||||
#include <media/EffectsFactoryApi.h>
|
||||
#include <utils/Trace.h>
|
||||
@@ -40,7 +41,10 @@ namespace effect {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
|
||||
#endif
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -136,9 +140,12 @@ bool ProcessThread::threadLoop() {
|
||||
const char* Effect::sContextResultOfCommand = "returned status";
|
||||
const char* Effect::sContextCallToCommand = "error";
|
||||
const char* Effect::sContextCallFunction = sContextCallToCommand;
|
||||
const char* Effect::sContextConversion = "conversion";
|
||||
|
||||
Effect::Effect(effect_handle_t handle)
|
||||
: mHandle(handle), mEfGroup(nullptr), mStopProcessThread(false) {}
|
||||
Effect::Effect(bool isInput, effect_handle_t handle)
|
||||
: mIsInput(isInput), mHandle(handle), mEfGroup(nullptr), mStopProcessThread(false) {
|
||||
(void)mIsInput; // prevent 'unused field' warnings in pre-V7 versions.
|
||||
}
|
||||
|
||||
Effect::~Effect() {
|
||||
ATRACE_CALL();
|
||||
@@ -180,7 +187,8 @@ std::unique_ptr<uint8_t[]> Effect::hidlVecToHal(const hidl_vec<T>& vec, uint32_t
|
||||
return halData;
|
||||
}
|
||||
|
||||
// static
|
||||
#if MAJOR_VERSION <= 6
|
||||
|
||||
void Effect::effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
|
||||
EffectAuxChannelsConfig* config) {
|
||||
config->mainChannels = AudioChannelBitfield(halConfig.main_channels);
|
||||
@@ -194,7 +202,6 @@ void Effect::effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
|
||||
halConfig->aux_channels = static_cast<audio_channel_mask_t>(config.auxChannels);
|
||||
}
|
||||
|
||||
// static
|
||||
void Effect::effectBufferConfigFromHal(const buffer_config_t& halConfig,
|
||||
EffectBufferConfig* config) {
|
||||
config->buffer.id = 0;
|
||||
@@ -223,7 +230,56 @@ void Effect::effectBufferConfigToHal(const EffectBufferConfig& config, buffer_co
|
||||
halConfig->mask = static_cast<uint8_t>(config.mask);
|
||||
}
|
||||
|
||||
#else // MAJOR_VERSION <= 6
|
||||
|
||||
void Effect::effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
|
||||
EffectAuxChannelsConfig* config) {
|
||||
(void)HidlUtils::audioChannelMaskFromHal(halConfig.main_channels, mIsInput,
|
||||
&config->mainChannels);
|
||||
(void)HidlUtils::audioChannelMaskFromHal(halConfig.aux_channels, mIsInput,
|
||||
&config->auxChannels);
|
||||
}
|
||||
|
||||
// static
|
||||
void Effect::effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
|
||||
channel_config_t* halConfig) {
|
||||
(void)HidlUtils::audioChannelMaskToHal(config.mainChannels, &halConfig->main_channels);
|
||||
(void)HidlUtils::audioChannelMaskToHal(config.auxChannels, &halConfig->aux_channels);
|
||||
}
|
||||
|
||||
void Effect::effectBufferConfigFromHal(const buffer_config_t& halConfig,
|
||||
EffectBufferConfig* config) {
|
||||
config->buffer.id = 0;
|
||||
config->buffer.frameCount = 0;
|
||||
audio_config_base_t halConfigBase = {halConfig.samplingRate,
|
||||
static_cast<audio_channel_mask_t>(halConfig.channels),
|
||||
static_cast<audio_format_t>(halConfig.format)};
|
||||
(void)HidlUtils::audioConfigBaseFromHal(halConfigBase, mIsInput, &config->base);
|
||||
config->accessMode = EffectBufferAccess(halConfig.accessMode);
|
||||
config->mask = static_cast<decltype(config->mask)>(halConfig.mask);
|
||||
}
|
||||
|
||||
// static
|
||||
void Effect::effectBufferConfigToHal(const EffectBufferConfig& config, buffer_config_t* halConfig) {
|
||||
// Note: setting the buffers directly is considered obsolete. They need to be set
|
||||
// using 'setProcessBuffers'.
|
||||
halConfig->buffer.frameCount = 0;
|
||||
halConfig->buffer.raw = nullptr;
|
||||
audio_config_base_t halConfigBase;
|
||||
(void)HidlUtils::audioConfigBaseToHal(config.base, &halConfigBase);
|
||||
halConfig->samplingRate = halConfigBase.sample_rate;
|
||||
halConfig->channels = halConfigBase.channel_mask;
|
||||
halConfig->format = halConfigBase.format;
|
||||
// Note: The framework code does not use BP.
|
||||
halConfig->bufferProvider.cookie = nullptr;
|
||||
halConfig->bufferProvider.getBuffer = nullptr;
|
||||
halConfig->bufferProvider.releaseBuffer = nullptr;
|
||||
halConfig->accessMode = static_cast<uint8_t>(config.accessMode);
|
||||
halConfig->mask = static_cast<uint8_t>(config.mask);
|
||||
}
|
||||
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
|
||||
void Effect::effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config) {
|
||||
effectBufferConfigFromHal(halConfig.inputCfg, &config->inputCfg);
|
||||
effectBufferConfigFromHal(halConfig.outputCfg, &config->outputCfg);
|
||||
@@ -507,11 +563,65 @@ Return<Result> Effect::disable() {
|
||||
return sendCommandReturningStatus(EFFECT_CMD_DISABLE, "DISABLE");
|
||||
}
|
||||
|
||||
Return<Result> Effect::setAudioSource(
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioSource source
|
||||
#else
|
||||
const AudioSource& source
|
||||
#endif
|
||||
) {
|
||||
audio_source_t halSource;
|
||||
if (status_t status = HidlUtils::audioSourceToHal(source, &halSource); status == NO_ERROR) {
|
||||
uint32_t halSourceParam = static_cast<uint32_t>(halSource);
|
||||
return sendCommand(EFFECT_CMD_SET_AUDIO_SOURCE, "SET_AUDIO_SOURCE", sizeof(uint32_t),
|
||||
&halSourceParam);
|
||||
} else {
|
||||
return analyzeStatus(__func__, "audioSourceToHal", sContextConversion, status);
|
||||
}
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
|
||||
Return<Result> Effect::setDevice(AudioDeviceBitfield device) {
|
||||
uint32_t halDevice = static_cast<uint32_t>(device);
|
||||
return sendCommand(EFFECT_CMD_SET_DEVICE, "SET_DEVICE", sizeof(uint32_t), &halDevice);
|
||||
}
|
||||
|
||||
Return<Result> Effect::setInputDevice(AudioDeviceBitfield device) {
|
||||
uint32_t halDevice = static_cast<uint32_t>(device);
|
||||
return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
|
||||
&halDevice);
|
||||
}
|
||||
|
||||
#else // MAJOR_VERSION <= 6
|
||||
|
||||
Return<Result> Effect::setDevice(const DeviceAddress& device) {
|
||||
audio_devices_t halDevice;
|
||||
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
if (status_t status = HidlUtils::deviceAddressToHal(device, &halDevice, halDeviceAddress);
|
||||
status == NO_ERROR) {
|
||||
uint32_t halDeviceParam = static_cast<uint32_t>(halDevice);
|
||||
return sendCommand(EFFECT_CMD_SET_DEVICE, "SET_DEVICE", sizeof(uint32_t), &halDeviceParam);
|
||||
} else {
|
||||
return analyzeStatus(__func__, "deviceAddressToHal", sContextConversion, status);
|
||||
}
|
||||
}
|
||||
|
||||
Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
|
||||
audio_devices_t halDevice;
|
||||
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
if (status_t status = HidlUtils::deviceAddressToHal(device, &halDevice, halDeviceAddress);
|
||||
status == NO_ERROR) {
|
||||
uint32_t halDeviceParam = static_cast<uint32_t>(halDevice);
|
||||
return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
|
||||
&halDeviceParam);
|
||||
} else {
|
||||
return analyzeStatus(__func__, "deviceAddressToHal", sContextConversion, status);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MAJOR_VERSION <= 6
|
||||
|
||||
Return<void> Effect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
uint32_t halDataSize;
|
||||
@@ -546,12 +656,6 @@ Return<Result> Effect::setConfigReverse(
|
||||
inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> Effect::setInputDevice(AudioDeviceBitfield device) {
|
||||
uint32_t halDevice = static_cast<uint32_t>(device);
|
||||
return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
|
||||
&halDevice);
|
||||
}
|
||||
|
||||
Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
|
||||
getConfigImpl(EFFECT_CMD_GET_CONFIG, "GET_CONFIG", _hidl_cb);
|
||||
return Void();
|
||||
@@ -598,12 +702,6 @@ Return<Result> Effect::setAuxChannelsConfig(const EffectAuxChannelsConfig& confi
|
||||
"SET_FEATURE_CONFIG AUX_CHANNELS", halCmd.size(), &halCmd[0]);
|
||||
}
|
||||
|
||||
Return<Result> Effect::setAudioSource(AudioSource source) {
|
||||
uint32_t halSource = static_cast<uint32_t>(source);
|
||||
return sendCommand(EFFECT_CMD_SET_AUDIO_SOURCE, "SET_AUDIO_SOURCE", sizeof(uint32_t),
|
||||
&halSource);
|
||||
}
|
||||
|
||||
Return<Result> Effect::offload(const EffectOffloadParameter& param) {
|
||||
effect_offload_param_t halParam;
|
||||
effectOffloadParamToHal(param, &halParam);
|
||||
|
||||
@@ -47,7 +47,9 @@ using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
#if MAJOR_VERSION <= 6
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioDeviceBitfield;
|
||||
#endif
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::effect::CPP_VERSION;
|
||||
|
||||
@@ -56,7 +58,7 @@ struct Effect : public IEffect {
|
||||
using GetParameterSuccessCallback =
|
||||
std::function<void(uint32_t valueSize, const void* valueData)>;
|
||||
|
||||
explicit Effect(effect_handle_t handle);
|
||||
Effect(bool isInput, effect_handle_t handle);
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> init() override;
|
||||
@@ -66,7 +68,15 @@ struct Effect : public IEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -74,14 +84,12 @@ struct Effect : public IEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -104,6 +112,10 @@ struct Effect : public IEffect {
|
||||
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
|
||||
|
||||
// Utility methods for extending interfaces.
|
||||
static const char* sContextConversion;
|
||||
|
||||
Result analyzeStatus(const char* funcName, const char* subFuncName,
|
||||
const char* contextDescription, status_t status);
|
||||
template <typename T>
|
||||
Return<void> getIntegerParam(uint32_t paramId,
|
||||
std::function<void(Result retval, T paramValue)> cb) {
|
||||
@@ -170,6 +182,7 @@ struct Effect : public IEffect {
|
||||
static const char* sContextCallToCommand;
|
||||
static const char* sContextCallFunction;
|
||||
|
||||
const bool mIsInput;
|
||||
effect_handle_t mHandle;
|
||||
sp<AudioBufferWrapper> mInBuffer;
|
||||
sp<AudioBufferWrapper> mOutBuffer;
|
||||
@@ -186,15 +199,14 @@ struct Effect : public IEffect {
|
||||
static size_t alignedSizeIn(size_t s);
|
||||
template <typename T>
|
||||
std::unique_ptr<uint8_t[]> hidlVecToHal(const hidl_vec<T>& vec, uint32_t* halDataSize);
|
||||
static void effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
|
||||
EffectAuxChannelsConfig* config);
|
||||
void effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
|
||||
EffectAuxChannelsConfig* config);
|
||||
static void effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
|
||||
channel_config_t* halConfig);
|
||||
static void effectBufferConfigFromHal(const buffer_config_t& halConfig,
|
||||
EffectBufferConfig* config);
|
||||
void effectBufferConfigFromHal(const buffer_config_t& halConfig, EffectBufferConfig* config);
|
||||
static void effectBufferConfigToHal(const EffectBufferConfig& config,
|
||||
buffer_config_t* halConfig);
|
||||
static void effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config);
|
||||
void effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config);
|
||||
static void effectConfigToHal(const EffectConfig& config, effect_config_t* halConfig);
|
||||
static void effectOffloadParamToHal(const EffectOffloadParameter& offload,
|
||||
effect_offload_param_t* halOffload);
|
||||
@@ -202,8 +214,6 @@ struct Effect : public IEffect {
|
||||
uint32_t valueSize, const void** valueData);
|
||||
|
||||
Result analyzeCommandStatus(const char* commandName, const char* context, status_t status);
|
||||
Result analyzeStatus(const char* funcName, const char* subFuncName,
|
||||
const char* contextDescription, status_t status);
|
||||
void getConfigImpl(int commandCode, const char* commandName, GetConfigCallback cb);
|
||||
Result getCurrentConfigImpl(uint32_t featureId, uint32_t configSize,
|
||||
GetCurrentConfigSuccessCallback onSuccess);
|
||||
|
||||
@@ -82,7 +82,9 @@ sp<IEffect> EffectsFactory::dispatchEffectInstanceCreation(const effect_descript
|
||||
} else if (memcmp(halUuid, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0) {
|
||||
return new VisualizerEffect(handle);
|
||||
}
|
||||
return new Effect(handle);
|
||||
const bool isInput =
|
||||
(halDescriptor.flags & EFFECT_FLAG_TYPE_PRE_PROC) == EFFECT_FLAG_TYPE_PRE_PROC;
|
||||
return new Effect(isInput, handle);
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow.
|
||||
|
||||
@@ -31,9 +31,7 @@ namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
EnvironmentalReverbEffect::EnvironmentalReverbEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(handle)) {}
|
||||
|
||||
EnvironmentalReverbEffect::~EnvironmentalReverbEffect() {}
|
||||
: mEffect(new Effect(false /*isInput*/, handle)) {}
|
||||
|
||||
void EnvironmentalReverbEffect::propertiesFromHal(
|
||||
const t_reverb_settings& halProperties, IEnvironmentalReverbEffect::AllProperties* properties) {
|
||||
@@ -86,10 +84,32 @@ Return<Result> EnvironmentalReverbEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> EnvironmentalReverbEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> EnvironmentalReverbEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> EnvironmentalReverbEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> EnvironmentalReverbEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> EnvironmentalReverbEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> EnvironmentalReverbEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> EnvironmentalReverbEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -110,10 +130,6 @@ Return<Result> EnvironmentalReverbEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> EnvironmentalReverbEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> EnvironmentalReverbEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -136,10 +152,6 @@ Return<Result> EnvironmentalReverbEffect::setAuxChannelsConfig(
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> EnvironmentalReverbEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> EnvironmentalReverbEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,15 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -65,14 +73,12 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -125,7 +131,7 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~EnvironmentalReverbEffect();
|
||||
virtual ~EnvironmentalReverbEffect() = default;
|
||||
|
||||
void propertiesFromHal(const t_reverb_settings& halProperties,
|
||||
IEnvironmentalReverbEffect::AllProperties* properties);
|
||||
|
||||
@@ -31,9 +31,8 @@ namespace effect {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
EqualizerEffect::EqualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
|
||||
|
||||
EqualizerEffect::~EqualizerEffect() {}
|
||||
EqualizerEffect::EqualizerEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(false /*isInput*/, handle)) {}
|
||||
|
||||
void EqualizerEffect::propertiesFromHal(const t_equalizer_settings& halProperties,
|
||||
IEqualizerEffect::AllProperties* properties) {
|
||||
@@ -80,10 +79,32 @@ Return<Result> EqualizerEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> EqualizerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> EqualizerEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> EqualizerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> EqualizerEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> EqualizerEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> EqualizerEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> EqualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -103,10 +124,6 @@ Return<Result> EqualizerEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> EqualizerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> EqualizerEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -128,10 +145,6 @@ Return<Result> EqualizerEffect::setAuxChannelsConfig(const EffectAuxChannelsConf
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> EqualizerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> EqualizerEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,15 @@ struct EqualizerEffect : public IEqualizerEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -65,14 +73,12 @@ struct EqualizerEffect : public IEqualizerEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -111,7 +117,7 @@ struct EqualizerEffect : public IEqualizerEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~EqualizerEffect();
|
||||
virtual ~EqualizerEffect() = default;
|
||||
|
||||
void propertiesFromHal(const t_equalizer_settings& halProperties,
|
||||
IEqualizerEffect::AllProperties* properties);
|
||||
|
||||
@@ -33,9 +33,7 @@ namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
LoudnessEnhancerEffect::LoudnessEnhancerEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(handle)) {}
|
||||
|
||||
LoudnessEnhancerEffect::~LoudnessEnhancerEffect() {}
|
||||
: mEffect(new Effect(false /*isInput*/, handle)) {}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> LoudnessEnhancerEffect::init() {
|
||||
@@ -60,10 +58,32 @@ Return<Result> LoudnessEnhancerEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> LoudnessEnhancerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> LoudnessEnhancerEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> LoudnessEnhancerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> LoudnessEnhancerEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> LoudnessEnhancerEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> LoudnessEnhancerEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> LoudnessEnhancerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -83,10 +103,6 @@ Return<Result> LoudnessEnhancerEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> LoudnessEnhancerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> LoudnessEnhancerEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -108,10 +124,6 @@ Return<Result> LoudnessEnhancerEffect::setAuxChannelsConfig(const EffectAuxChann
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> LoudnessEnhancerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> LoudnessEnhancerEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,15 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -61,14 +69,12 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -98,7 +104,7 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~LoudnessEnhancerEffect();
|
||||
virtual ~LoudnessEnhancerEffect() = default;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -30,9 +30,7 @@ namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
NoiseSuppressionEffect::NoiseSuppressionEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(handle)) {}
|
||||
|
||||
NoiseSuppressionEffect::~NoiseSuppressionEffect() {}
|
||||
: mEffect(new Effect(true /*isInput*/, handle)) {}
|
||||
|
||||
void NoiseSuppressionEffect::propertiesFromHal(const t_ns_settings& halProperties,
|
||||
INoiseSuppressionEffect::AllProperties* properties) {
|
||||
@@ -69,10 +67,32 @@ Return<Result> NoiseSuppressionEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> NoiseSuppressionEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> NoiseSuppressionEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> NoiseSuppressionEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> NoiseSuppressionEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> NoiseSuppressionEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> NoiseSuppressionEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> NoiseSuppressionEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -92,10 +112,6 @@ Return<Result> NoiseSuppressionEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> NoiseSuppressionEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> NoiseSuppressionEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -117,10 +133,6 @@ Return<Result> NoiseSuppressionEffect::setAuxChannelsConfig(const EffectAuxChann
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> NoiseSuppressionEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> NoiseSuppressionEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,15 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -63,14 +71,12 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -105,7 +111,7 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~NoiseSuppressionEffect();
|
||||
virtual ~NoiseSuppressionEffect() = default;
|
||||
|
||||
void propertiesFromHal(const t_ns_settings& halProperties,
|
||||
INoiseSuppressionEffect::AllProperties* properties);
|
||||
|
||||
@@ -30,9 +30,8 @@ namespace effect {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
PresetReverbEffect::PresetReverbEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
|
||||
|
||||
PresetReverbEffect::~PresetReverbEffect() {}
|
||||
PresetReverbEffect::PresetReverbEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(false /*isInput*/, handle)) {}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> PresetReverbEffect::init() {
|
||||
@@ -57,10 +56,32 @@ Return<Result> PresetReverbEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> PresetReverbEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> PresetReverbEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> PresetReverbEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> PresetReverbEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> PresetReverbEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> PresetReverbEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> PresetReverbEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -80,10 +101,6 @@ Return<Result> PresetReverbEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> PresetReverbEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> PresetReverbEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -105,10 +122,6 @@ Return<Result> PresetReverbEffect::setAuxChannelsConfig(const EffectAuxChannelsC
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> PresetReverbEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> PresetReverbEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,15 @@ struct PresetReverbEffect : public IPresetReverbEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -61,14 +69,12 @@ struct PresetReverbEffect : public IPresetReverbEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -98,7 +104,7 @@ struct PresetReverbEffect : public IPresetReverbEffect {
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~PresetReverbEffect();
|
||||
virtual ~PresetReverbEffect() = default;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#include "VirtualizerEffect.h"
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <HidlUtils.h>
|
||||
#include <android/log.h>
|
||||
#include <system/audio_effects/effect_virtualizer.h>
|
||||
|
||||
@@ -32,19 +34,10 @@ namespace effect {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
VirtualizerEffect::VirtualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
VirtualizerEffect::~VirtualizerEffect() {}
|
||||
|
||||
void VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
|
||||
hidl_vec<SpeakerAngle>& speakerAngles) {
|
||||
speakerAngles.resize(channelCount);
|
||||
for (uint32_t i = 0; i < channelCount; ++i) {
|
||||
speakerAngles[i].mask = AudioChannelBitfield(*halAngles++);
|
||||
speakerAngles[i].azimuth = *halAngles++;
|
||||
speakerAngles[i].elevation = *halAngles++;
|
||||
}
|
||||
}
|
||||
VirtualizerEffect::VirtualizerEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(false /*isInput*/, handle)) {}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> VirtualizerEffect::init() {
|
||||
@@ -69,10 +62,32 @@ Return<Result> VirtualizerEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> VirtualizerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> VirtualizerEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> VirtualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -92,10 +107,6 @@ Return<Result> VirtualizerEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> VirtualizerEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -117,10 +128,6 @@ Return<Result> VirtualizerEffect::setAuxChannelsConfig(const EffectAuxChannelsCo
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
@@ -192,43 +199,117 @@ Return<void> VirtualizerEffect::getStrength(getStrength_cb _hidl_cb) {
|
||||
return mEffect->getIntegerParam(VIRTUALIZER_PARAM_STRENGTH, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> VirtualizerEffect::getVirtualSpeakerAngles(AudioChannelBitfield mask,
|
||||
AudioDevice device,
|
||||
getVirtualSpeakerAngles_cb _hidl_cb) {
|
||||
uint32_t channelCount =
|
||||
audio_channel_count_from_out_mask(static_cast<audio_channel_mask_t>(mask));
|
||||
Return<void> VirtualizerEffect::getVirtualSpeakerAngles(
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioChannelBitfield mask, AudioDevice device, getVirtualSpeakerAngles_cb _hidl_cb) {
|
||||
audio_channel_mask_t halChannelMask = static_cast<audio_channel_mask_t>(mask);
|
||||
audio_devices_t halDeviceType = static_cast<audio_devices_t>(device);
|
||||
#else
|
||||
const AudioChannelMask& mask, const DeviceAddress& device,
|
||||
getVirtualSpeakerAngles_cb _hidl_cb) {
|
||||
audio_channel_mask_t halChannelMask;
|
||||
if (status_t status = HidlUtils::audioChannelMaskToHal(mask, &halChannelMask);
|
||||
status != NO_ERROR) {
|
||||
_hidl_cb(mEffect->analyzeStatus(__func__, "audioChannelMaskToHal",
|
||||
Effect::sContextConversion, status),
|
||||
SpeakerAngles{});
|
||||
return Void();
|
||||
}
|
||||
audio_devices_t halDeviceType;
|
||||
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
if (status_t status = HidlUtils::deviceAddressToHal(device, &halDeviceType, halDeviceAddress);
|
||||
status != NO_ERROR) {
|
||||
_hidl_cb(mEffect->analyzeStatus(__func__, "deviceAddressToHal", Effect::sContextConversion,
|
||||
status),
|
||||
SpeakerAngles{});
|
||||
return Void();
|
||||
}
|
||||
#endif
|
||||
uint32_t channelCount = audio_channel_count_from_out_mask(halChannelMask);
|
||||
size_t halSpeakerAnglesSize = sizeof(int32_t) * 3 * channelCount;
|
||||
uint32_t halParam[3] = {VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES,
|
||||
static_cast<audio_channel_mask_t>(mask),
|
||||
static_cast<audio_devices_t>(device)};
|
||||
hidl_vec<SpeakerAngle> speakerAngles;
|
||||
uint32_t halParam[3] = {VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES, halChannelMask,
|
||||
halDeviceType};
|
||||
SpeakerAngles speakerAngles;
|
||||
status_t status = NO_ERROR;
|
||||
Result retval = mEffect->getParameterImpl(
|
||||
sizeof(halParam), halParam, halSpeakerAnglesSize,
|
||||
[&](uint32_t valueSize, const void* valueData) {
|
||||
if (valueSize > halSpeakerAnglesSize) {
|
||||
valueSize = halSpeakerAnglesSize;
|
||||
} else if (valueSize < halSpeakerAnglesSize) {
|
||||
channelCount = valueSize / (sizeof(int32_t) * 3);
|
||||
}
|
||||
speakerAnglesFromHal(reinterpret_cast<const int32_t*>(valueData), channelCount,
|
||||
speakerAngles);
|
||||
});
|
||||
sizeof(halParam), halParam, halSpeakerAnglesSize,
|
||||
[&](uint32_t valueSize, const void* valueData) {
|
||||
if (valueSize < halSpeakerAnglesSize) {
|
||||
channelCount = valueSize / (sizeof(int32_t) * 3);
|
||||
}
|
||||
status = speakerAnglesFromHal(reinterpret_cast<const int32_t*>(valueData),
|
||||
channelCount, speakerAngles);
|
||||
});
|
||||
if (retval == Result::OK) {
|
||||
retval = mEffect->analyzeStatus(__func__, "speakerAnglesFromHal", "", status);
|
||||
}
|
||||
_hidl_cb(retval, speakerAngles);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::forceVirtualizationMode(AudioDevice device) {
|
||||
return mEffect->setParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE,
|
||||
static_cast<audio_devices_t>(device));
|
||||
}
|
||||
|
||||
Return<void> VirtualizerEffect::getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) {
|
||||
uint32_t halMode = 0;
|
||||
Result retval = mEffect->getParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE, halMode);
|
||||
#if MAJOR_VERSION <= 6
|
||||
_hidl_cb(retval, AudioDevice(halMode));
|
||||
#else
|
||||
DeviceAddress device;
|
||||
(void)HidlUtils::deviceAddressFromHal(static_cast<audio_devices_t>(halMode), nullptr, &device);
|
||||
_hidl_cb(retval, device);
|
||||
#endif
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Result> VirtualizerEffect::forceVirtualizationMode(
|
||||
#if MAJOR_VERSION <= 6
|
||||
AudioDevice device) {
|
||||
audio_devices_t halDeviceType = static_cast<audio_devices_t>(device);
|
||||
#else
|
||||
const DeviceAddress& device) {
|
||||
audio_devices_t halDeviceType;
|
||||
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
|
||||
(void)HidlUtils::deviceAddressToHal(device, &halDeviceType, halDeviceAddress);
|
||||
#endif
|
||||
return mEffect->setParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE, halDeviceType);
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
// static
|
||||
status_t VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
|
||||
hidl_vec<SpeakerAngle>& speakerAngles) {
|
||||
speakerAngles.resize(channelCount);
|
||||
for (uint32_t i = 0; i < channelCount; ++i) {
|
||||
speakerAngles[i].mask = AudioChannelBitfield(*halAngles++);
|
||||
speakerAngles[i].azimuth = *halAngles++;
|
||||
speakerAngles[i].elevation = *halAngles++;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
#else
|
||||
static int compare_channels(const void* lhs, const void* rhs) {
|
||||
return *(int32_t*)lhs - *(int32_t*)rhs;
|
||||
}
|
||||
|
||||
// static
|
||||
status_t VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
|
||||
SpeakerAngles& speakerAngles) {
|
||||
speakerAngles.azimuth.resize(channelCount);
|
||||
speakerAngles.elevation.resize(channelCount);
|
||||
int32_t halAnglesSorted[channelCount * 3];
|
||||
memcpy(halAnglesSorted, halAngles, sizeof(halAnglesSorted));
|
||||
// Ensure that channels are ordered from LSb to MSb.
|
||||
qsort(halAnglesSorted, channelCount, sizeof(int32_t) * 3, compare_channels);
|
||||
audio_channel_mask_t halMask = AUDIO_CHANNEL_NONE;
|
||||
int32_t* halAnglesPtr = halAnglesSorted;
|
||||
for (uint32_t i = 0; i < channelCount; ++i) {
|
||||
halMask = static_cast<audio_channel_mask_t>(halMask | *halAnglesPtr++);
|
||||
speakerAngles.azimuth[i] = *halAnglesPtr++;
|
||||
speakerAngles.elevation[i] = *halAnglesPtr++;
|
||||
}
|
||||
return HidlUtils::audioChannelMaskFromHal(halMask, false /*isInput*/, &speakerAngles.mask);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
} // namespace effect
|
||||
|
||||
@@ -39,7 +39,9 @@ using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
#if MAJOR_VERSION <= 6
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
|
||||
#endif
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::effect::CPP_VERSION;
|
||||
|
||||
@@ -54,7 +56,15 @@ struct VirtualizerEffect : public IVirtualizerEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -62,14 +72,12 @@ struct VirtualizerEffect : public IVirtualizerEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -96,18 +104,27 @@ struct VirtualizerEffect : public IVirtualizerEffect {
|
||||
Return<bool> isStrengthSupported() override;
|
||||
Return<Result> setStrength(uint16_t strength) override;
|
||||
Return<void> getStrength(getStrength_cb _hidl_cb) override;
|
||||
Return<void> getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<void> getVirtualSpeakerAngles(AudioChannelBitfield mask, AudioDevice device,
|
||||
getVirtualSpeakerAngles_cb _hidl_cb) override;
|
||||
Return<Result> forceVirtualizationMode(AudioDevice device) override;
|
||||
Return<void> getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) override;
|
||||
#else
|
||||
Return<void> getVirtualSpeakerAngles(const AudioChannelMask& mask, const DeviceAddress& device,
|
||||
getVirtualSpeakerAngles_cb _hidl_cb) override;
|
||||
Return<Result> forceVirtualizationMode(const DeviceAddress& device) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
private:
|
||||
sp<Effect> mEffect;
|
||||
|
||||
virtual ~VirtualizerEffect();
|
||||
virtual ~VirtualizerEffect() = default;
|
||||
|
||||
void speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
|
||||
hidl_vec<SpeakerAngle>& speakerAngles);
|
||||
#if MAJOR_VERSION <= 6
|
||||
using SpeakerAngles = hidl_vec<SpeakerAngle>;
|
||||
#endif
|
||||
static status_t speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
|
||||
SpeakerAngles& speakerAngles);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
VisualizerEffect::VisualizerEffect(effect_handle_t handle)
|
||||
: mEffect(new Effect(handle)), mCaptureSize(0), mMeasurementMode(MeasurementMode::NONE) {}
|
||||
|
||||
VisualizerEffect::~VisualizerEffect() {}
|
||||
: mEffect(new Effect(false /*isInput*/, handle)),
|
||||
mCaptureSize(0),
|
||||
mMeasurementMode(MeasurementMode::NONE) {}
|
||||
|
||||
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
|
||||
Return<Result> VisualizerEffect::init() {
|
||||
@@ -58,10 +58,32 @@ Return<Result> VisualizerEffect::disable() {
|
||||
return mEffect->disable();
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> VisualizerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> VisualizerEffect::setDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> VisualizerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#else
|
||||
Return<Result> VisualizerEffect::setAudioSource(const AudioSource& source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> VisualizerEffect::setDevice(const DeviceAddress& device) {
|
||||
return mEffect->setDevice(device);
|
||||
}
|
||||
|
||||
Return<Result> VisualizerEffect::setInputDevice(const DeviceAddress& device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
#endif
|
||||
|
||||
Return<void> VisualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) {
|
||||
return mEffect->setAndGetVolume(volumes, _hidl_cb);
|
||||
@@ -81,10 +103,6 @@ Return<Result> VisualizerEffect::setConfigReverse(
|
||||
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
|
||||
}
|
||||
|
||||
Return<Result> VisualizerEffect::setInputDevice(AudioDeviceBitfield device) {
|
||||
return mEffect->setInputDevice(device);
|
||||
}
|
||||
|
||||
Return<void> VisualizerEffect::getConfig(getConfig_cb _hidl_cb) {
|
||||
return mEffect->getConfig(_hidl_cb);
|
||||
}
|
||||
@@ -106,10 +124,6 @@ Return<Result> VisualizerEffect::setAuxChannelsConfig(const EffectAuxChannelsCon
|
||||
return mEffect->setAuxChannelsConfig(config);
|
||||
}
|
||||
|
||||
Return<Result> VisualizerEffect::setAudioSource(AudioSource source) {
|
||||
return mEffect->setAudioSource(source);
|
||||
}
|
||||
|
||||
Return<Result> VisualizerEffect::offload(const EffectOffloadParameter& param) {
|
||||
return mEffect->offload(param);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,15 @@ struct VisualizerEffect : public IVisualizerEffect {
|
||||
Return<Result> reset() override;
|
||||
Return<Result> enable() override;
|
||||
Return<Result> disable() override;
|
||||
#if MAJOR_VERSION <= 6
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> setDevice(AudioDeviceBitfield device) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
#else
|
||||
Return<Result> setAudioSource(const AudioSource& source) override;
|
||||
Return<Result> setDevice(const DeviceAddress& device) override;
|
||||
Return<Result> setInputDevice(const DeviceAddress& device) override;
|
||||
#endif
|
||||
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
|
||||
setAndGetVolume_cb _hidl_cb) override;
|
||||
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
|
||||
@@ -61,14 +69,12 @@ struct VisualizerEffect : public IVisualizerEffect {
|
||||
Return<Result> setConfigReverse(
|
||||
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
|
||||
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
|
||||
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
|
||||
Return<void> getConfig(getConfig_cb _hidl_cb) override;
|
||||
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
|
||||
Return<void> getSupportedAuxChannelsConfigs(
|
||||
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
|
||||
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
|
||||
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
|
||||
Return<Result> setAudioSource(AudioSource source) override;
|
||||
Return<Result> offload(const EffectOffloadParameter& param) override;
|
||||
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
|
||||
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
|
||||
@@ -107,7 +113,7 @@ struct VisualizerEffect : public IVisualizerEffect {
|
||||
uint16_t mCaptureSize;
|
||||
MeasurementMode mMeasurementMode;
|
||||
|
||||
virtual ~VisualizerEffect();
|
||||
virtual ~VisualizerEffect() = default;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -263,7 +263,7 @@ void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
|
||||
static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
|
||||
#else
|
||||
*channelCount = android::audio::policy::configuration::V7_0::getChannelCount(
|
||||
currentConfig.outputCfg.channels);
|
||||
currentConfig.outputCfg.base.channelMask);
|
||||
ASSERT_NE(*channelCount, 0);
|
||||
#endif
|
||||
}
|
||||
@@ -353,8 +353,14 @@ inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
|
||||
}
|
||||
|
||||
inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) {
|
||||
return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
|
||||
lhs.channels == rhs.channels && lhs.format == rhs.format &&
|
||||
return lhs.buffer == rhs.buffer &&
|
||||
#if MAJOR_VERSION <= 6
|
||||
lhs.samplingRateHz == rhs.samplingRateHz && lhs.channels == rhs.channels &&
|
||||
lhs.format == rhs.format &&
|
||||
#else
|
||||
lhs.base.sampleRateHz == rhs.base.sampleRateHz &&
|
||||
lhs.base.channelMask == rhs.base.channelMask && lhs.base.format == rhs.base.format &&
|
||||
#endif
|
||||
lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user