From 4b6169eec67dc9f22c1c2fd24c93b2efd31676b2 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Fri, 23 Feb 2018 15:19:28 -0800 Subject: [PATCH 01/12] Audio V4: Remove system only enum values Some enum values only used by the system were exposed to the vendor for legacy reason. Remove them. Bug: 38184704 Test: compile Change-Id: I78254047a74d08bcdf2d7b285e874dbd497d5407 Merged-In: I78254047a74d08bcdf2d7b285e874dbd497d5407 Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/common/4.0/types.hal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/common/4.0/types.hal b/audio/common/4.0/types.hal index 4efdea3fa4..0adff734d3 100644 --- a/audio/common/4.0/types.hal +++ b/audio/common/4.0/types.hal @@ -104,8 +104,6 @@ enum AudioStreamType : int32_t { TTS = 9, // Transmitted Through Speaker. Plays over speaker // only, silent on other devices ACCESSIBILITY = 10, // For accessibility talk back prompts - REROUTING = 11, // For dynamic policy output mixes - PATCH = 12, // For internal audio flinger tracks. Fixed volume }; @export(name="audio_source_t", value_prefix="AUDIO_SOURCE_") @@ -657,6 +655,8 @@ enum AudioUsage : int32_t { /** Type of audio generated by an application. */ @export(name="audio_content_type_t", value_prefix="AUDIO_CONTENT_TYPE_") enum AudioContentType : uint32_t { + // Do not change these values without updating their counterparts + // in frameworks/base/media/java/android/media/AudioAttributes.java UNKNOWN = 0, SPEECH = 1, MUSIC = 2, From 63410e8da431c9bfaf6a5c495b6da9876ee82280 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Fri, 23 Feb 2018 18:43:39 -0800 Subject: [PATCH 02/12] Audio V4: Do not forward notification detail Those values are only for the framework, thus they should not be available to the vendor. Bug: 38184704 Test: compile Change-Id: I05d3e506a85dbe66d51b7024fa9de45865bcf9db Merged-In: I05d3e506a85dbe66d51b7024fa9de45865bcf9db Cherry-picked from master Signed-off-by: Kevin Rocard --- .../common/all-versions/default/HidlUtils.h | 2 ++ .../all-versions/default/HidlUtils.impl.h | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h index 1654ac6e34..f9a5697418 100644 --- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h +++ b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h @@ -47,6 +47,8 @@ class HidlUtils { struct audio_gain_config* halConfig); static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain); static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain); + static AudioUsage audioUsageFromHal(const audio_usage_t halUsage); + static audio_usage_t audioUsageToHal(const AudioUsage usage); static void audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, AudioOffloadInfo* offload); static void audioOffloadInfoToHal(const AudioOffloadInfo& offload, diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h index 935f307cdc..26ad51824f 100644 --- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h +++ b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h @@ -100,6 +100,22 @@ void HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain halGain->max_ramp_ms = gain.maxRampMs; } +AudioUsage HidlUtils::audioUsageFromHal(const audio_usage_t halUsage) { + switch (halUsage) { + case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST: + case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT: + case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED: + case AUDIO_USAGE_NOTIFICATION_EVENT: + return AudioUsage::NOTIFICATION; + default: + return static_cast(halUsage); + } +} + +audio_usage_t HidlUtils::audioUsageToHal(const AudioUsage usage) { + return static_cast(usage); +} + void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, AudioOffloadInfo* offload) { offload->sampleRateHz = halOffload.sample_rate; @@ -112,7 +128,7 @@ void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, offload->isStreaming = halOffload.is_streaming; offload->bitWidth = halOffload.bit_width; offload->bufferSize = halOffload.offload_buffer_size; - offload->usage = static_cast(halOffload.usage); + offload->usage = audioUsageFromHal(halOffload.usage); } void HidlUtils::audioOffloadInfoToHal(const AudioOffloadInfo& offload, @@ -128,7 +144,7 @@ void HidlUtils::audioOffloadInfoToHal(const AudioOffloadInfo& offload, halOffload->is_streaming = offload.isStreaming; halOffload->bit_width = offload.bitWidth; halOffload->offload_buffer_size = offload.bufferSize; - halOffload->usage = static_cast(offload.usage); + halOffload->usage = audioUsageToHal(offload.usage); } void HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halConfig, From c5af419ef26826aee7014763e5c088c34a049a8e Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Fri, 23 Feb 2018 18:45:58 -0800 Subject: [PATCH 03/12] Audio V4: Add V4 common utils Bug: 38184704 Test: compile Change-Id: I935fe4343ab517f7a8dc65e1b9720097a3ab34da Merged-In: I935fe4343ab517f7a8dc65e1b9720097a3ab34da Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/common/4.0/default/Android.bp | 47 ++++++++++++++++++++++++++ audio/common/4.0/default/HidlUtils.cpp | 21 ++++++++++++ audio/common/4.0/default/HidlUtils.h | 26 ++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 audio/common/4.0/default/Android.bp create mode 100644 audio/common/4.0/default/HidlUtils.cpp create mode 100644 audio/common/4.0/default/HidlUtils.h diff --git a/audio/common/4.0/default/Android.bp b/audio/common/4.0/default/Android.bp new file mode 100644 index 0000000000..57b2e01f3d --- /dev/null +++ b/audio/common/4.0/default/Android.bp @@ -0,0 +1,47 @@ +// +// Copyright (C) 2018 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. + +cc_library_shared { + name: "android.hardware.audio.common@4.0-util", + defaults: ["hidl_defaults"], + vendor_available: true, + vndk: { + enabled: true, + }, + srcs: [ + "HidlUtils.cpp", + ], + + export_include_dirs: ["."], + + static_libs: [ + ], + + shared_libs: [ + "liblog", + "libutils", + "libhidlbase", + "android.hardware.audio.common-util", + "android.hardware.audio.common@4.0", + ], + export_shared_lib_headers: [ + "android.hardware.audio.common-util" + ], + + header_libs: [ + "libaudio_system_headers", + "libhardware_headers", + ], +} diff --git a/audio/common/4.0/default/HidlUtils.cpp b/audio/common/4.0/default/HidlUtils.cpp new file mode 100644 index 0000000000..b66eff975a --- /dev/null +++ b/audio/common/4.0/default/HidlUtils.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2018 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" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/common/4.0/default/HidlUtils.h b/audio/common/4.0/default/HidlUtils.h new file mode 100644 index 0000000000..91e6a9e121 --- /dev/null +++ b/audio/common/4.0/default/HidlUtils.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef android_hardware_audio_V4_0_Hidl_Utils_H_ +#define android_hardware_audio_V4_0_Hidl_Utils_H_ + +#include + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // android_hardware_audio_V4_0_Hidl_Utils_H_ From f0878685d797d107417b2758c1ea39284609cebb Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Mon, 26 Feb 2018 18:45:07 -0800 Subject: [PATCH 04/12] Audio V4: Cast conversion now deduce both types That avoids to repeat the destination type which can change between versions. Bug: 38184704 Test: compile Change-Id: I55c881afe5f6fc511ea01b19c5d46de12fb1e0d2 Merged-In: I55c881afe5f6fc511ea01b19c5d46de12fb1e0d2 Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/common/all-versions/default/Android.bp | 4 ++ .../all-versions/default/HidlUtils.impl.h | 21 ++++--- .../common/all-versions/VersionUtils.h | 61 +++++++++++++++++++ 3 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 audio/common/all-versions/util/include/common/all-versions/VersionUtils.h diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp index 8f6b74c96e..4a27bb76cb 100644 --- a/audio/common/all-versions/default/Android.bp +++ b/audio/common/all-versions/default/Android.bp @@ -33,7 +33,11 @@ cc_library_shared { ], header_libs: [ + "android.hardware.audio.common.util@all-versions", "libaudio_system_headers", "libhardware_headers", ], + export_header_lib_headers: [ + "android.hardware.audio.common.util@all-versions", + ] } diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h index 26ad51824f..d6f8d3e57d 100644 --- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h +++ b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h @@ -18,6 +18,7 @@ #error "AUDIO_HAL_VERSION must be set before including this file." #endif +#include #include using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; @@ -32,6 +33,8 @@ using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioStreamType; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioUsage; +using ::android::hardware::audio::common::utils::mkEnumConverter; + namespace android { namespace hardware { namespace audio { @@ -40,7 +43,7 @@ namespace AUDIO_HAL_VERSION { void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) { config->sampleRateHz = halConfig.sample_rate; - config->channelMask = AudioChannelMask(halConfig.channel_mask); + config->channelMask = mkEnumConverter(halConfig.channel_mask); config->format = AudioFormat(halConfig.format); audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo); config->frameCount = halConfig.frame_count; @@ -58,8 +61,8 @@ void HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t* halC void HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig, AudioGainConfig* config) { config->index = halConfig.index; - config->mode = AudioGainMode(halConfig.mode); - config->channelMask = AudioChannelMask(halConfig.channel_mask); + config->mode = mkEnumConverter(halConfig.mode); + config->channelMask = mkEnumConverter(halConfig.channel_mask); for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) { config->values[i] = halConfig.values[i]; } @@ -79,8 +82,8 @@ void HidlUtils::audioGainConfigToHal(const AudioGainConfig& config, } void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) { - gain->mode = AudioGainMode(halGain.mode); - gain->channelMask = AudioChannelMask(halGain.channel_mask); + gain->mode = mkEnumConverter(halGain.mode); + gain->channelMask = mkEnumConverter(halGain.channel_mask); gain->minValue = halGain.min_value; gain->maxValue = halGain.max_value; gain->defaultValue = halGain.default_value; @@ -119,7 +122,7 @@ audio_usage_t HidlUtils::audioUsageToHal(const AudioUsage usage) { void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, AudioOffloadInfo* offload) { offload->sampleRateHz = halOffload.sample_rate; - offload->channelMask = AudioChannelMask(halOffload.channel_mask); + offload->channelMask = mkEnumConverter(halOffload.channel_mask); offload->format = AudioFormat(halOffload.format); offload->streamType = AudioStreamType(halOffload.stream_type); offload->bitRatePerSecond = halOffload.bit_rate; @@ -152,9 +155,9 @@ void HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halConfig config->id = halConfig.id; config->role = AudioPortRole(halConfig.role); config->type = AudioPortType(halConfig.type); - config->configMask = AudioPortConfigMask(halConfig.config_mask); + config->configMask = mkEnumConverter(halConfig.config_mask); config->sampleRateHz = halConfig.sample_rate; - config->channelMask = AudioChannelMask(halConfig.channel_mask); + config->channelMask = mkEnumConverter(halConfig.channel_mask); config->format = AudioFormat(halConfig.format); audioGainConfigFromHal(halConfig.gain, &config->gain); switch (halConfig.type) { @@ -254,7 +257,7 @@ void HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort* po } port->channelMasks.resize(halPort.num_channel_masks); for (size_t i = 0; i < halPort.num_channel_masks; ++i) { - port->channelMasks[i] = AudioChannelMask(halPort.channel_masks[i]); + port->channelMasks[i] = mkEnumConverter(halPort.channel_masks[i]); } port->formats.resize(halPort.num_formats); for (size_t i = 0; i < halPort.num_formats; ++i) { diff --git a/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h new file mode 100644 index 0000000000..a998b0675c --- /dev/null +++ b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef android_hardware_audio_common_VersionUtils_H_ +#define android_hardware_audio_common_VersionUtils_H_ + +#include +#include + +namespace android { +namespace hardware { +namespace audio { +namespace common { +namespace utils { + +/** Similar to static_cast but also casts to hidl_bitfield depending on + * return type inference (emulated through user-define conversion). + */ +template +class EnumConverter { + public: + static_assert(std::is_enum::value || std::is_enum::value, + "Source or destination should be an enum"); + + explicit EnumConverter(Source source) : mSource(source) {} + + operator Destination() const { return static_cast(mSource); } + + template ::value>> + operator ::android::hardware::hidl_bitfield() { + return static_cast>(mSource); + } + + private: + const Source mSource; +}; +template +auto mkEnumConverter(Source source) { + return EnumConverter{source}; +} + +} // namespace utils +} // namespace common +} // namespace audio +} // namespace hardware +} // namespace android + +#endif // android_hardware_audio_common_VersionUtils_H_ From 2b275704bc174199687d11bd5b6ed6e1f0dcaaea Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Tue, 27 Feb 2018 10:56:32 -0800 Subject: [PATCH 05/12] Fix potential missing '\0' when wrapping to legacy The HAL API for port name is a C++ string of arbitrary length. Nevertheless the legacy API name had a maximum length. Thus when wrapping from the new to legacy, the string was truncated but no '\0' was added. Bug: 38184704 Test: compile Change-Id: I482363809718281e022041c2d5042e5800c5a617 Merged-In: I482363809718281e022041c2d5042e5800c5a617 Cherry-picked from master Signed-off-by: Kevin Rocard --- .../include/common/all-versions/default/HidlUtils.impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h index d6f8d3e57d..8ab73501bc 100644 --- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h +++ b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h @@ -296,8 +296,8 @@ void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort halPort->id = port.id; halPort->role = static_cast(port.role); halPort->type = static_cast(port.type); - memcpy(halPort->name, port.name.c_str(), - std::min(port.name.size(), static_cast(AUDIO_PORT_MAX_NAME_LEN))); + strncpy(halPort->name, port.name.c_str(), AUDIO_PORT_MAX_NAME_LEN); + halPort->name[AUDIO_PORT_MAX_NAME_LEN - 1] = '\0'; halPort->num_sample_rates = std::min(port.sampleRates.size(), static_cast(AUDIO_PORT_MAX_SAMPLING_RATES)); for (size_t i = 0; i < halPort->num_sample_rates; ++i) { From e605e033619977f98a57b6ac4b38145079ea3d69 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Wed, 28 Feb 2018 15:15:07 -0800 Subject: [PATCH 06/12] Audio V4: Use string to identify audio Device The name of an audio device is an opaque string that the framework does not interpret (there are exceptions, see documentation) and only uses as an ID to link the audio_policy_configuration.xml and the audio device factory. Previously it was an enum which meant that the vendors could not implement the interface more than a set number of time and that generic meaningless (secondary, auxiliary) names had to be introduced. Bug: 38184704 Test: compile Change-Id: I9f3ac1928de8116974257951e016108c5820eded Merged-In: I9f3ac1928de8116974257951e016108c5820eded Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/4.0/IDevicesFactory.hal | 45 +++++++++---------- .../4.0/config/audio_policy_configuration.xsd | 31 +------------ 2 files changed, 21 insertions(+), 55 deletions(-) diff --git a/audio/4.0/IDevicesFactory.hal b/audio/4.0/IDevicesFactory.hal index c552c6ddd2..987fd68e5c 100644 --- a/audio/4.0/IDevicesFactory.hal +++ b/audio/4.0/IDevicesFactory.hal @@ -19,41 +19,36 @@ package android.hardware.audio@4.0; import android.hardware.audio.common@4.0; import IDevice; +/** This factory allows a HAL implementation to be split in multiple independent + * devices (called module in the pre-treble API). + * Note that this division is arbitrary and implementation are free + * to only have a Primary. + * The framework will query the devices according to audio_policy_configuration.xml + * + * Each device name is arbitrary, provided by the vendor's audio_policy_configuration.xml + * and only used to identify a device in this factory. + * The framework must not interpret the name, treating it as a vendor opaque data + * with the following exceptions: + * - the "primary" device must always be present and is the device used by the telephony framework. + * - the "r_submix" device that must be present to support policyMixes (Eg: Android projected). + * Note that this Device is included by default in a build derived from AOSP. + * + * Note that on AOSP Oreo (including MR1) the "a2dp" module is not using this API + * but is loaded directly from the system partition using the legacy API + * due to limitations with the Bluetooth framework. + */ interface IDevicesFactory { - /** Allows a HAL implementation to be split in multiple independent - * devices (called module in the pre-treble API). - * Note that this division is arbitrary and implementation are free - * to only have a Primary. - * The framework will query the devices according to audio_policy_configuration.xml - * - * Each Device value is interchangeable with any other and the framework - * does not differentiate between values with the following exceptions: - * - the Primary device must always be present - * - the R_SUBMIX that is used to forward audio of REMOTE_SUBMIX DEVICES - */ - enum Device : int32_t { - PRIMARY, - A2DP, - USB, - R_SUBMIX, - STUB, - CODEC_OFFLOAD, - SECONDARY, - AUXILIARY, - /** Multi Stream Decoder */ - MSD - }; /** * Opens an audio device. To close the device, it is necessary to release * references to the returned device object. * - * @param device device type. + * @param device device name. * @return retval operation completion status. Returns INVALID_ARGUMENTS * if there is no corresponding hardware module found, * NOT_INITIALIZED if an error occured while opening the hardware * module. * @return result the interface for the created device. */ - openDevice(Device device) generates (Result retval, IDevice result); + openDevice(string device) generates (Result retval, IDevice result); }; diff --git a/audio/4.0/config/audio_policy_configuration.xsd b/audio/4.0/config/audio_policy_configuration.xsd index 924fb4715b..e5b444994a 100644 --- a/audio/4.0/config/audio_policy_configuration.xsd +++ b/audio/4.0/config/audio_policy_configuration.xsd @@ -66,35 +66,6 @@ - - - - - - - - - - - - - - - - - Vendor eXtension names must be in the vx namespace. - Vendor are encouraged to namespace their module names. - Example for an hypothetical Google virtual reality HAL: - - - - - - - - - @@ -133,7 +104,7 @@ - + From f1c1f6e7ac7f9ac2d2a8e804450402340e8b7fca Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Wed, 28 Feb 2018 21:46:26 -0800 Subject: [PATCH 07/12] Audio V4: Update .hal doc to removal of audioSource As multiple tracks can be connected to the same stream, the audio source list can be found in metadata. Bug: 38184704 Test: none Change-Id: I63e75fd4049fbe469b78cacf0adf44e9597cb422 Merged-In: I63e75fd4049fbe469b78cacf0adf44e9597cb422 Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/4.0/IDevice.hal | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/4.0/IDevice.hal b/audio/4.0/IDevice.hal index 7eb03c8d95..1bb5abaa61 100644 --- a/audio/4.0/IDevice.hal +++ b/audio/4.0/IDevice.hal @@ -132,7 +132,6 @@ interface IDevice { * @param device device type and (if needed) address. * @param config stream configuration. * @param flags additional flags. - * @param source source specification. * @param sinkMetadata Description of the audio that is suggested by the client. * May be used by implementations to configure hardware effects. * @return retval operation completion status. From af7f78daa6517f49f9c54de05dedb1f691ca883f Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Thu, 1 Mar 2018 15:08:07 -0800 Subject: [PATCH 08/12] Audio V4: Implement the shim effect 4.0 -> legacy All the new files added are a copy of the 2.0 ones, with just the version 2 that was changed to 4. Due to the rollback on the retrocompatiblity breakage, the split of implementation is not strictly needed any more. This makes the current split in .impl.h and double include unnecessary complicated. This will need to be factorized in a future patch. Bug: 38184704 Test: compile Change-Id: If412eb55ebf6afc773593547af9395a09b6825c2 Merged-In: If412eb55ebf6afc773593547af9395a09b6825c2 Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/common/2.0/default/VersionUtils.h | 39 +++++++++++++++ audio/common/4.0/default/VersionUtils.h | 39 +++++++++++++++ .../default/AcousticEchoCancelerEffect.cpp | 23 +++++++++ .../4.0/default/AcousticEchoCancelerEffect.h | 28 +++++++++++ audio/effect/4.0/default/Android.bp | 50 +++++++++++++++++++ .../effect/4.0/default/AudioBufferManager.cpp | 21 ++++++++ audio/effect/4.0/default/AudioBufferManager.h | 26 ++++++++++ .../default/AutomaticGainControlEffect.cpp | 23 +++++++++ .../4.0/default/AutomaticGainControlEffect.h | 28 +++++++++++ audio/effect/4.0/default/BassBoostEffect.cpp | 23 +++++++++ audio/effect/4.0/default/BassBoostEffect.h | 30 +++++++++++ audio/effect/4.0/default/Conversions.cpp | 24 +++++++++ audio/effect/4.0/default/Conversions.h | 26 ++++++++++ audio/effect/4.0/default/DownmixEffect.cpp | 23 +++++++++ audio/effect/4.0/default/DownmixEffect.h | 28 +++++++++++ audio/effect/4.0/default/Effect.cpp | 28 +++++++++++ audio/effect/4.0/default/Effect.h | 28 +++++++++++ audio/effect/4.0/default/EffectsFactory.cpp | 39 +++++++++++++++ audio/effect/4.0/default/EffectsFactory.h | 29 +++++++++++ .../4.0/default/EnvironmentalReverbEffect.cpp | 24 +++++++++ .../4.0/default/EnvironmentalReverbEffect.h | 30 +++++++++++ audio/effect/4.0/default/EqualizerEffect.cpp | 23 +++++++++ audio/effect/4.0/default/EqualizerEffect.h | 28 +++++++++++ .../4.0/default/LoudnessEnhancerEffect.cpp | 23 +++++++++ .../4.0/default/LoudnessEnhancerEffect.h | 28 +++++++++++ .../4.0/default/NoiseSuppressionEffect.cpp | 23 +++++++++ .../4.0/default/NoiseSuppressionEffect.h | 28 +++++++++++ .../effect/4.0/default/PresetReverbEffect.cpp | 23 +++++++++ audio/effect/4.0/default/PresetReverbEffect.h | 28 +++++++++++ .../effect/4.0/default/VirtualizerEffect.cpp | 23 +++++++++ audio/effect/4.0/default/VirtualizerEffect.h | 28 +++++++++++ audio/effect/4.0/default/VisualizerEffect.cpp | 23 +++++++++ audio/effect/4.0/default/VisualizerEffect.h | 28 +++++++++++ .../default/AcousticEchoCancelerEffect.h | 6 ++- .../default/AcousticEchoCancelerEffect.impl.h | 6 ++- .../default/AutomaticGainControlEffect.h | 6 ++- .../default/AutomaticGainControlEffect.impl.h | 6 ++- .../all-versions/default/BassBoostEffect.h | 6 ++- .../default/BassBoostEffect.impl.h | 6 ++- .../all-versions/default/DownmixEffect.h | 6 ++- .../all-versions/default/DownmixEffect.impl.h | 6 ++- .../effect/all-versions/default/Effect.h | 7 ++- .../effect/all-versions/default/Effect.impl.h | 15 +++--- .../all-versions/default/EffectsFactory.h | 2 +- .../default/EnvironmentalReverbEffect.h | 6 ++- .../default/EnvironmentalReverbEffect.impl.h | 6 ++- .../all-versions/default/EqualizerEffect.h | 6 ++- .../default/EqualizerEffect.impl.h | 6 ++- .../default/LoudnessEnhancerEffect.h | 6 ++- .../default/LoudnessEnhancerEffect.impl.h | 6 ++- .../default/NoiseSuppressionEffect.h | 6 ++- .../default/NoiseSuppressionEffect.impl.h | 6 ++- .../all-versions/default/PresetReverbEffect.h | 6 ++- .../default/PresetReverbEffect.impl.h | 6 ++- .../all-versions/default/VirtualizerEffect.h | 9 ++-- .../default/VirtualizerEffect.impl.h | 11 ++-- .../all-versions/default/VisualizerEffect.h | 6 ++- .../default/VisualizerEffect.impl.h | 6 ++- 58 files changed, 1023 insertions(+), 56 deletions(-) create mode 100644 audio/common/2.0/default/VersionUtils.h create mode 100644 audio/common/4.0/default/VersionUtils.h create mode 100644 audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp create mode 100644 audio/effect/4.0/default/AcousticEchoCancelerEffect.h create mode 100644 audio/effect/4.0/default/Android.bp create mode 100644 audio/effect/4.0/default/AudioBufferManager.cpp create mode 100644 audio/effect/4.0/default/AudioBufferManager.h create mode 100644 audio/effect/4.0/default/AutomaticGainControlEffect.cpp create mode 100644 audio/effect/4.0/default/AutomaticGainControlEffect.h create mode 100644 audio/effect/4.0/default/BassBoostEffect.cpp create mode 100644 audio/effect/4.0/default/BassBoostEffect.h create mode 100644 audio/effect/4.0/default/Conversions.cpp create mode 100644 audio/effect/4.0/default/Conversions.h create mode 100644 audio/effect/4.0/default/DownmixEffect.cpp create mode 100644 audio/effect/4.0/default/DownmixEffect.h create mode 100644 audio/effect/4.0/default/Effect.cpp create mode 100644 audio/effect/4.0/default/Effect.h create mode 100644 audio/effect/4.0/default/EffectsFactory.cpp create mode 100644 audio/effect/4.0/default/EffectsFactory.h create mode 100644 audio/effect/4.0/default/EnvironmentalReverbEffect.cpp create mode 100644 audio/effect/4.0/default/EnvironmentalReverbEffect.h create mode 100644 audio/effect/4.0/default/EqualizerEffect.cpp create mode 100644 audio/effect/4.0/default/EqualizerEffect.h create mode 100644 audio/effect/4.0/default/LoudnessEnhancerEffect.cpp create mode 100644 audio/effect/4.0/default/LoudnessEnhancerEffect.h create mode 100644 audio/effect/4.0/default/NoiseSuppressionEffect.cpp create mode 100644 audio/effect/4.0/default/NoiseSuppressionEffect.h create mode 100644 audio/effect/4.0/default/PresetReverbEffect.cpp create mode 100644 audio/effect/4.0/default/PresetReverbEffect.h create mode 100644 audio/effect/4.0/default/VirtualizerEffect.cpp create mode 100644 audio/effect/4.0/default/VirtualizerEffect.h create mode 100644 audio/effect/4.0/default/VisualizerEffect.cpp create mode 100644 audio/effect/4.0/default/VisualizerEffect.h diff --git a/audio/common/2.0/default/VersionUtils.h b/audio/common/2.0/default/VersionUtils.h new file mode 100644 index 0000000000..fef468080e --- /dev/null +++ b/audio/common/2.0/default/VersionUtils.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H + +#include + +namespace android { +namespace hardware { +namespace audio { +namespace common { +namespace V2_0 { +namespace implementation { + +typedef common::V2_0::AudioDevice AudioDeviceBitfield; +typedef common::V2_0::AudioChannelMask AudioChannelBitfield; + +} // namespace implementation +} // namespace V2_0 +} // namespace common +} // namespace audio +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H diff --git a/audio/common/4.0/default/VersionUtils.h b/audio/common/4.0/default/VersionUtils.h new file mode 100644 index 0000000000..515c792222 --- /dev/null +++ b/audio/common/4.0/default/VersionUtils.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H + +#include + +namespace android { +namespace hardware { +namespace audio { +namespace common { +namespace V4_0 { +namespace implementation { + +typedef hidl_bitfield AudioDeviceBitfield; +typedef hidl_bitfield AudioChannelBitfield; + +} // namespace implementation +} // namespace V4_0 +} // namespace common +} // namespace audio +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H diff --git a/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp b/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp new file mode 100644 index 0000000000..242740e582 --- /dev/null +++ b/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "AEC_Effect_HAL" + +#include "AcousticEchoCancelerEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/AcousticEchoCancelerEffect.h b/audio/effect/4.0/default/AcousticEchoCancelerEffect.h new file mode 100644 index 0000000000..0ac0a1e0df --- /dev/null +++ b/audio/effect/4.0/default/AcousticEchoCancelerEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H diff --git a/audio/effect/4.0/default/Android.bp b/audio/effect/4.0/default/Android.bp new file mode 100644 index 0000000000..dcb2269a9b --- /dev/null +++ b/audio/effect/4.0/default/Android.bp @@ -0,0 +1,50 @@ +cc_library_shared { + name: "android.hardware.audio.effect@4.0-impl", + defaults: ["hidl_defaults"], + vendor: true, + relative_install_path: "hw", + srcs: [ + "AcousticEchoCancelerEffect.cpp", + "AudioBufferManager.cpp", + "AutomaticGainControlEffect.cpp", + "BassBoostEffect.cpp", + "Conversions.cpp", + "DownmixEffect.cpp", + "Effect.cpp", + "EffectsFactory.cpp", + "EnvironmentalReverbEffect.cpp", + "EqualizerEffect.cpp", + "LoudnessEnhancerEffect.cpp", + "NoiseSuppressionEffect.cpp", + "PresetReverbEffect.cpp", + "VirtualizerEffect.cpp", + "VisualizerEffect.cpp", + ], + + shared_libs: [ + "libbase", + "libcutils", + "libeffects", + "libfmq", + "libhidlbase", + "libhidlmemory", + "libhidltransport", + "liblog", + "libutils", + "android.hardware.audio.common-util", + "android.hardware.audio.common@4.0", + "android.hardware.audio.common@4.0-util", + "android.hardware.audio.effect@4.0", + "android.hidl.memory@1.0", + ], + + header_libs: [ + "android.hardware.audio.common.util@all-versions", + "android.hardware.audio.effect@all-versions-impl", + "libaudio_system_headers", + "libaudioclient_headers", + "libeffects_headers", + "libhardware_headers", + "libmedia_headers", + ], +} diff --git a/audio/effect/4.0/default/AudioBufferManager.cpp b/audio/effect/4.0/default/AudioBufferManager.cpp new file mode 100644 index 0000000000..2d75f3fdbb --- /dev/null +++ b/audio/effect/4.0/default/AudioBufferManager.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2018 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 "AudioBufferManager.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/AudioBufferManager.h b/audio/effect/4.0/default/AudioBufferManager.h new file mode 100644 index 0000000000..1f151e6b99 --- /dev/null +++ b/audio/effect/4.0/default/AudioBufferManager.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_ +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_ + +#include + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_ diff --git a/audio/effect/4.0/default/AutomaticGainControlEffect.cpp b/audio/effect/4.0/default/AutomaticGainControlEffect.cpp new file mode 100644 index 0000000000..9d21c8ae6b --- /dev/null +++ b/audio/effect/4.0/default/AutomaticGainControlEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "AGC_Effect_HAL" + +#include "AutomaticGainControlEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/AutomaticGainControlEffect.h b/audio/effect/4.0/default/AutomaticGainControlEffect.h new file mode 100644 index 0000000000..7f12007f8f --- /dev/null +++ b/audio/effect/4.0/default/AutomaticGainControlEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H diff --git a/audio/effect/4.0/default/BassBoostEffect.cpp b/audio/effect/4.0/default/BassBoostEffect.cpp new file mode 100644 index 0000000000..74a626b79e --- /dev/null +++ b/audio/effect/4.0/default/BassBoostEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "BassBoost_HAL" + +#include "BassBoostEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/BassBoostEffect.h b/audio/effect/4.0/default/BassBoostEffect.h new file mode 100644 index 0000000000..206a75fab4 --- /dev/null +++ b/audio/effect/4.0/default/BassBoostEffect.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H + +#include + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H diff --git a/audio/effect/4.0/default/Conversions.cpp b/audio/effect/4.0/default/Conversions.cpp new file mode 100644 index 0000000000..91285ae6b8 --- /dev/null +++ b/audio/effect/4.0/default/Conversions.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018 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 "Conversions.h" +#include "HidlUtils.h" + +using ::android::hardware::audio::common::V4_0::HidlUtils; + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/Conversions.h b/audio/effect/4.0/default/Conversions.h new file mode 100644 index 0000000000..50e380fe2e --- /dev/null +++ b/audio/effect/4.0/default/Conversions.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_ +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_ + +#include + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_ diff --git a/audio/effect/4.0/default/DownmixEffect.cpp b/audio/effect/4.0/default/DownmixEffect.cpp new file mode 100644 index 0000000000..07fcab2f1c --- /dev/null +++ b/audio/effect/4.0/default/DownmixEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "Downmix_HAL" + +#include "DownmixEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/DownmixEffect.h b/audio/effect/4.0/default/DownmixEffect.h new file mode 100644 index 0000000000..5ae820b76f --- /dev/null +++ b/audio/effect/4.0/default/DownmixEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H diff --git a/audio/effect/4.0/default/Effect.cpp b/audio/effect/4.0/default/Effect.cpp new file mode 100644 index 0000000000..707044bff0 --- /dev/null +++ b/audio/effect/4.0/default/Effect.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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 + +#define LOG_TAG "EffectHAL" +#define ATRACE_TAG ATRACE_TAG_AUDIO + +#include "Conversions.h" +#include "Effect.h" +#include "common/all-versions/default/EffectMap.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/Effect.h b/audio/effect/4.0/default/Effect.h new file mode 100644 index 0000000000..9ca79c4596 --- /dev/null +++ b/audio/effect/4.0/default/Effect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H + +#include + +#include "AudioBufferManager.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H diff --git a/audio/effect/4.0/default/EffectsFactory.cpp b/audio/effect/4.0/default/EffectsFactory.cpp new file mode 100644 index 0000000000..ee0413df8f --- /dev/null +++ b/audio/effect/4.0/default/EffectsFactory.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "EffectFactoryHAL" +#include "EffectsFactory.h" +#include "AcousticEchoCancelerEffect.h" +#include "AutomaticGainControlEffect.h" +#include "BassBoostEffect.h" +#include "Conversions.h" +#include "DownmixEffect.h" +#include "Effect.h" +#include "EnvironmentalReverbEffect.h" +#include "EqualizerEffect.h" +#include "HidlUtils.h" +#include "LoudnessEnhancerEffect.h" +#include "NoiseSuppressionEffect.h" +#include "PresetReverbEffect.h" +#include "VirtualizerEffect.h" +#include "VisualizerEffect.h" +#include "common/all-versions/default/EffectMap.h" + +using ::android::hardware::audio::common::V4_0::HidlUtils; + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/EffectsFactory.h b/audio/effect/4.0/default/EffectsFactory.h new file mode 100644 index 0000000000..48e4b4cb9f --- /dev/null +++ b/audio/effect/4.0/default/EffectsFactory.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H + +#include + +#include + +#include +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H diff --git a/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp b/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp new file mode 100644 index 0000000000..cc3102d1f8 --- /dev/null +++ b/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "EnvReverb_HAL" +#include + +#include "EnvironmentalReverbEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/EnvironmentalReverbEffect.h b/audio/effect/4.0/default/EnvironmentalReverbEffect.h new file mode 100644 index 0000000000..c0fb25c02c --- /dev/null +++ b/audio/effect/4.0/default/EnvironmentalReverbEffect.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H + +#include + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H diff --git a/audio/effect/4.0/default/EqualizerEffect.cpp b/audio/effect/4.0/default/EqualizerEffect.cpp new file mode 100644 index 0000000000..d0a40bc3cd --- /dev/null +++ b/audio/effect/4.0/default/EqualizerEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "Equalizer_HAL" + +#include "EqualizerEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/EqualizerEffect.h b/audio/effect/4.0/default/EqualizerEffect.h new file mode 100644 index 0000000000..7c9463b01e --- /dev/null +++ b/audio/effect/4.0/default/EqualizerEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H diff --git a/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp b/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp new file mode 100644 index 0000000000..e3c5184225 --- /dev/null +++ b/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "LoudnessEnhancer_HAL" + +#include "LoudnessEnhancerEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/LoudnessEnhancerEffect.h b/audio/effect/4.0/default/LoudnessEnhancerEffect.h new file mode 100644 index 0000000000..64fa26add8 --- /dev/null +++ b/audio/effect/4.0/default/LoudnessEnhancerEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H diff --git a/audio/effect/4.0/default/NoiseSuppressionEffect.cpp b/audio/effect/4.0/default/NoiseSuppressionEffect.cpp new file mode 100644 index 0000000000..e83a8e3373 --- /dev/null +++ b/audio/effect/4.0/default/NoiseSuppressionEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "NS_Effect_HAL" + +#include "NoiseSuppressionEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/NoiseSuppressionEffect.h b/audio/effect/4.0/default/NoiseSuppressionEffect.h new file mode 100644 index 0000000000..36d45afaf7 --- /dev/null +++ b/audio/effect/4.0/default/NoiseSuppressionEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H diff --git a/audio/effect/4.0/default/PresetReverbEffect.cpp b/audio/effect/4.0/default/PresetReverbEffect.cpp new file mode 100644 index 0000000000..0c23be73af --- /dev/null +++ b/audio/effect/4.0/default/PresetReverbEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "PresetReverb_HAL" + +#include "PresetReverbEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/PresetReverbEffect.h b/audio/effect/4.0/default/PresetReverbEffect.h new file mode 100644 index 0000000000..3eeae0a04b --- /dev/null +++ b/audio/effect/4.0/default/PresetReverbEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H diff --git a/audio/effect/4.0/default/VirtualizerEffect.cpp b/audio/effect/4.0/default/VirtualizerEffect.cpp new file mode 100644 index 0000000000..f50e8adb7b --- /dev/null +++ b/audio/effect/4.0/default/VirtualizerEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "Virtualizer_HAL" + +#include "VirtualizerEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/VirtualizerEffect.h b/audio/effect/4.0/default/VirtualizerEffect.h new file mode 100644 index 0000000000..8e7114e569 --- /dev/null +++ b/audio/effect/4.0/default/VirtualizerEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H diff --git a/audio/effect/4.0/default/VisualizerEffect.cpp b/audio/effect/4.0/default/VisualizerEffect.cpp new file mode 100644 index 0000000000..8d4f100ced --- /dev/null +++ b/audio/effect/4.0/default/VisualizerEffect.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "Visualizer_HAL" + +#include "VisualizerEffect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/VisualizerEffect.h b/audio/effect/4.0/default/VisualizerEffect.h new file mode 100644 index 0000000000..6b5ab9c393 --- /dev/null +++ b/audio/effect/4.0/default/VisualizerEffect.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H + +#include + +#include "Effect.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h index b63f2fb937..852cb3fd15 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -46,7 +48,7 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -54,7 +56,7 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h index bee3607854..8ad80a22a0 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h @@ -19,6 +19,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -54,7 +56,7 @@ Return AcousticEchoCancelerEffect::disable() { return mEffect->disable(); } -Return AcousticEchoCancelerEffect::setDevice(AudioDevice device) { +Return AcousticEchoCancelerEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -78,7 +80,7 @@ Return AcousticEchoCancelerEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return AcousticEchoCancelerEffect::setInputDevice(AudioDevice device) { +Return AcousticEchoCancelerEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h index 941f45da3c..5ac43eb9bc 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h @@ -22,6 +22,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -48,7 +50,7 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -56,7 +58,7 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h index af05d9b780..e2e751e86b 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h @@ -18,6 +18,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -67,7 +69,7 @@ Return AutomaticGainControlEffect::disable() { return mEffect->disable(); } -Return AutomaticGainControlEffect::setDevice(AudioDevice device) { +Return AutomaticGainControlEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -91,7 +93,7 @@ Return AutomaticGainControlEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return AutomaticGainControlEffect::setInputDevice(AudioDevice device) { +Return AutomaticGainControlEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h index 00926217b5..29173ddebe 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -46,7 +48,7 @@ struct BassBoostEffect : public IBassBoostEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -54,7 +56,7 @@ struct BassBoostEffect : public IBassBoostEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h index 1fc8d1b428..7bcb4a3497 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h @@ -19,6 +19,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -53,7 +55,7 @@ Return BassBoostEffect::disable() { return mEffect->disable(); } -Return BassBoostEffect::setDevice(AudioDevice device) { +Return BassBoostEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -76,7 +78,7 @@ Return BassBoostEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return BassBoostEffect::setInputDevice(AudioDevice device) { +Return BassBoostEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h index e461ca80b7..3e3aa78477 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -46,7 +48,7 @@ struct DownmixEffect : public IDownmixEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -54,7 +56,7 @@ struct DownmixEffect : public IDownmixEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h index 98710f89dc..abef10ea09 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h @@ -19,6 +19,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -53,7 +55,7 @@ Return DownmixEffect::disable() { return mEffect->disable(); } -Return DownmixEffect::setDevice(AudioDevice device) { +Return DownmixEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -76,7 +78,7 @@ Return DownmixEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return DownmixEffect::setInputDevice(AudioDevice device) { +Return DownmixEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h index 81b0b24425..b546e0eb32 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h @@ -28,6 +28,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -39,6 +41,7 @@ using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioDeviceBitfield; using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; @@ -69,7 +72,7 @@ struct Effect : public IEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -77,7 +80,7 @@ struct Effect : public IEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h index d3761464be..61c9805663 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h @@ -24,6 +24,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -33,6 +35,7 @@ namespace implementation { using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield; using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::MessageQueueFlagBits; namespace { @@ -174,8 +177,8 @@ std::unique_ptr Effect::hidlVecToHal(const hidl_vec& vec, uint32_t // static void Effect::effectAuxChannelsConfigFromHal(const channel_config_t& halConfig, EffectAuxChannelsConfig* config) { - config->mainChannels = AudioChannelMask(halConfig.main_channels); - config->auxChannels = AudioChannelMask(halConfig.aux_channels); + config->mainChannels = AudioChannelBitfield(halConfig.main_channels); + config->auxChannels = AudioChannelBitfield(halConfig.aux_channels); } // static @@ -191,10 +194,10 @@ void Effect::effectBufferConfigFromHal(const buffer_config_t& halConfig, config->buffer.id = 0; config->buffer.frameCount = 0; config->samplingRateHz = halConfig.samplingRate; - config->channels = AudioChannelMask(halConfig.channels); + config->channels = AudioChannelBitfield(halConfig.channels); config->format = AudioFormat(halConfig.format); config->accessMode = EffectBufferAccess(halConfig.accessMode); - config->mask = EffectConfigParameters(halConfig.mask); + config->mask = static_castmask)>(halConfig.mask); } // static @@ -500,7 +503,7 @@ Return Effect::disable() { return sendCommandReturningStatus(EFFECT_CMD_DISABLE, "DISABLE"); } -Return Effect::setDevice(AudioDevice device) { +Return Effect::setDevice(AudioDeviceBitfield device) { uint32_t halDevice = static_cast(device); return sendCommand(EFFECT_CMD_SET_DEVICE, "SET_DEVICE", sizeof(uint32_t), &halDevice); } @@ -539,7 +542,7 @@ Return Effect::setConfigReverse( inputBufferProvider, outputBufferProvider); } -Return Effect::setInputDevice(AudioDevice device) { +Return Effect::setInputDevice(AudioDeviceBitfield device) { uint32_t halDevice = static_cast(device); return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t), &halDevice); diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h b/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h index e586abb807..313c8c2df6 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h @@ -46,7 +46,7 @@ struct EffectsFactory : public IEffectsFactory { Return getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) override; Return createEffect(const Uuid& uid, int32_t session, int32_t ioHandle, createEffect_cb _hidl_cb) override; - Return debugDump(const hidl_handle& fd) override; + Return debugDump(const hidl_handle& fd); private: static sp dispatchEffectInstanceCreation(const effect_descriptor_t& halDescriptor, diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h index 8351e5517a..d2f8cc3a84 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h @@ -22,6 +22,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -58,7 +60,7 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -66,7 +68,7 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h index 9090b8ab78..39a4092e8c 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h @@ -18,6 +18,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -81,7 +83,7 @@ Return EnvironmentalReverbEffect::disable() { return mEffect->disable(); } -Return EnvironmentalReverbEffect::setDevice(AudioDevice device) { +Return EnvironmentalReverbEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -105,7 +107,7 @@ Return EnvironmentalReverbEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return EnvironmentalReverbEffect::setInputDevice(AudioDevice device) { +Return EnvironmentalReverbEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h index c2b8ef8b52..de520521fa 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h @@ -24,6 +24,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -60,7 +62,7 @@ struct EqualizerEffect : public IEqualizerEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -68,7 +70,7 @@ struct EqualizerEffect : public IEqualizerEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h index 78485e48fd..db6bed8d2e 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -76,7 +78,7 @@ Return EqualizerEffect::disable() { return mEffect->disable(); } -Return EqualizerEffect::setDevice(AudioDevice device) { +Return EqualizerEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -99,7 +101,7 @@ Return EqualizerEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return EqualizerEffect::setInputDevice(AudioDevice device) { +Return EqualizerEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h index e4f1bd5e93..b59b077e76 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -56,7 +58,7 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -64,7 +66,7 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h index 3f4f379a27..88210e954b 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h @@ -21,6 +21,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -56,7 +58,7 @@ Return LoudnessEnhancerEffect::disable() { return mEffect->disable(); } -Return LoudnessEnhancerEffect::setDevice(AudioDevice device) { +Return LoudnessEnhancerEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -79,7 +81,7 @@ Return LoudnessEnhancerEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return LoudnessEnhancerEffect::setInputDevice(AudioDevice device) { +Return LoudnessEnhancerEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h index 7b64ba015a..af1635b717 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h @@ -22,6 +22,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -58,7 +60,7 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -66,7 +68,7 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h index e5fc454a44..f32399c51c 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h @@ -18,6 +18,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -65,7 +67,7 @@ Return NoiseSuppressionEffect::disable() { return mEffect->disable(); } -Return NoiseSuppressionEffect::setDevice(AudioDevice device) { +Return NoiseSuppressionEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -88,7 +90,7 @@ Return NoiseSuppressionEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return NoiseSuppressionEffect::setInputDevice(AudioDevice device) { +Return NoiseSuppressionEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h index 3114acd8d7..1a91ab49b2 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -56,7 +58,7 @@ struct PresetReverbEffect : public IPresetReverbEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -64,7 +66,7 @@ struct PresetReverbEffect : public IPresetReverbEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h index 32198d50e5..eab68fb703 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h @@ -19,6 +19,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -53,7 +55,7 @@ Return PresetReverbEffect::disable() { return mEffect->disable(); } -Return PresetReverbEffect::setDevice(AudioDevice device) { +Return PresetReverbEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -76,7 +78,7 @@ Return PresetReverbEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return PresetReverbEffect::setInputDevice(AudioDevice device) { +Return PresetReverbEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h index 371589488f..c0d5a0034d 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -31,6 +33,7 @@ using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield; using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; @@ -57,7 +60,7 @@ struct VirtualizerEffect : public IVirtualizerEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -65,7 +68,7 @@ struct VirtualizerEffect : public IVirtualizerEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( @@ -98,7 +101,7 @@ struct VirtualizerEffect : public IVirtualizerEffect { Return isStrengthSupported() override; Return setStrength(uint16_t strength) override; Return getStrength(getStrength_cb _hidl_cb) override; - Return getVirtualSpeakerAngles(AudioChannelMask mask, AudioDevice device, + Return getVirtualSpeakerAngles(AudioChannelBitfield mask, AudioDevice device, getVirtualSpeakerAngles_cb _hidl_cb) override; Return forceVirtualizationMode(AudioDevice device) override; Return getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) override; diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h index 6fb8005590..23b09a89dd 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h @@ -21,6 +21,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -36,7 +38,7 @@ void VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t hidl_vec& speakerAngles) { speakerAngles.resize(channelCount); for (uint32_t i = 0; i < channelCount; ++i) { - speakerAngles[i].mask = AudioChannelMask(*halAngles++); + speakerAngles[i].mask = AudioChannelBitfield(*halAngles++); speakerAngles[i].azimuth = *halAngles++; speakerAngles[i].elevation = *halAngles++; } @@ -65,7 +67,7 @@ Return VirtualizerEffect::disable() { return mEffect->disable(); } -Return VirtualizerEffect::setDevice(AudioDevice device) { +Return VirtualizerEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -88,7 +90,7 @@ Return VirtualizerEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return VirtualizerEffect::setInputDevice(AudioDevice device) { +Return VirtualizerEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } @@ -184,7 +186,8 @@ Return VirtualizerEffect::getStrength(getStrength_cb _hidl_cb) { return mEffect->getIntegerParam(VIRTUALIZER_PARAM_STRENGTH, _hidl_cb); } -Return VirtualizerEffect::getVirtualSpeakerAngles(AudioChannelMask mask, AudioDevice device, +Return VirtualizerEffect::getVirtualSpeakerAngles(AudioChannelBitfield mask, + AudioDevice device, getVirtualSpeakerAngles_cb _hidl_cb) { uint32_t channelCount = audio_channel_count_from_out_mask(static_cast(mask)); diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h b/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h index 80502210cf..114d3b7ae5 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h @@ -20,6 +20,8 @@ #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -56,7 +58,7 @@ struct VisualizerEffect : public IVisualizerEffect { Return reset() override; Return enable() override; Return disable() override; - Return setDevice(AudioDevice device) override; + Return setDevice(AudioDeviceBitfield device) override; Return setAndGetVolume(const hidl_vec& volumes, setAndGetVolume_cb _hidl_cb) override; Return volumeChangeNotification(const hidl_vec& volumes) override; @@ -64,7 +66,7 @@ struct VisualizerEffect : public IVisualizerEffect { Return setConfigReverse( const EffectConfig& config, const sp& inputBufferProvider, const sp& outputBufferProvider) override; - Return setInputDevice(AudioDevice device) override; + Return setInputDevice(AudioDeviceBitfield device) override; Return getConfig(getConfig_cb _hidl_cb) override; Return getConfigReverse(getConfigReverse_cb _hidl_cb) override; Return getSupportedAuxChannelsConfigs( diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h b/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h index 035145368b..9f2195b5cb 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h +++ b/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h @@ -19,6 +19,8 @@ #include #include +#include "VersionUtils.h" + namespace android { namespace hardware { namespace audio { @@ -54,7 +56,7 @@ Return VisualizerEffect::disable() { return mEffect->disable(); } -Return VisualizerEffect::setDevice(AudioDevice device) { +Return VisualizerEffect::setDevice(AudioDeviceBitfield device) { return mEffect->setDevice(device); } @@ -77,7 +79,7 @@ Return VisualizerEffect::setConfigReverse( return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); } -Return VisualizerEffect::setInputDevice(AudioDevice device) { +Return VisualizerEffect::setInputDevice(AudioDeviceBitfield device) { return mEffect->setInputDevice(device); } From 269603006338ef4b4327c413d3ea9d89d93aa06e Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Thu, 1 Mar 2018 18:32:43 -0800 Subject: [PATCH 09/12] Audio V4: Move service entry point to common The HAL audio service entry point is not version dependant and is common to core and effect. Bug: 38184704 Test: compile Change-Id: I143cf28490afc978791ccd7e8aeee2106cbb2ebd Merged-In: I143cf28490afc978791ccd7e8aeee2106cbb2ebd Cherry-picked from master Signed-off-by: Kevin Rocard --- .../default => common/all-versions/default/service}/Android.mk | 0 .../default/service}/android.hardware.audio@2.0-service.rc | 0 .../default => common/all-versions/default/service}/service.cpp | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename audio/{2.0/default => common/all-versions/default/service}/Android.mk (100%) rename audio/{2.0/default => common/all-versions/default/service}/android.hardware.audio@2.0-service.rc (100%) rename audio/{2.0/default => common/all-versions/default/service}/service.cpp (100%) diff --git a/audio/2.0/default/Android.mk b/audio/common/all-versions/default/service/Android.mk similarity index 100% rename from audio/2.0/default/Android.mk rename to audio/common/all-versions/default/service/Android.mk diff --git a/audio/2.0/default/android.hardware.audio@2.0-service.rc b/audio/common/all-versions/default/service/android.hardware.audio@2.0-service.rc similarity index 100% rename from audio/2.0/default/android.hardware.audio@2.0-service.rc rename to audio/common/all-versions/default/service/android.hardware.audio@2.0-service.rc diff --git a/audio/2.0/default/service.cpp b/audio/common/all-versions/default/service/service.cpp similarity index 100% rename from audio/2.0/default/service.cpp rename to audio/common/all-versions/default/service/service.cpp From 91aa1af99a71301178219bd1a97d20c0158c4866 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Fri, 2 Mar 2018 13:27:14 -0800 Subject: [PATCH 10/12] Audio V4: Add its own function to open the primary device The primary device has its own type and a fixed name and is not optional. By having its own getter, the client does not have to downcast it. Bug: 38184704 Test: compile Change-Id: I7b22eb0e12bddabfe966a20fbeab37d974306b12 Merged-In: I7b22eb0e12bddabfe966a20fbeab37d974306b12 Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/4.0/IDevicesFactory.hal | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/audio/4.0/IDevicesFactory.hal b/audio/4.0/IDevicesFactory.hal index 987fd68e5c..489294e5cd 100644 --- a/audio/4.0/IDevicesFactory.hal +++ b/audio/4.0/IDevicesFactory.hal @@ -18,6 +18,7 @@ package android.hardware.audio@4.0; import android.hardware.audio.common@4.0; import IDevice; +import IPrimaryDevice; /** This factory allows a HAL implementation to be split in multiple independent * devices (called module in the pre-treble API). @@ -28,8 +29,7 @@ import IDevice; * Each device name is arbitrary, provided by the vendor's audio_policy_configuration.xml * and only used to identify a device in this factory. * The framework must not interpret the name, treating it as a vendor opaque data - * with the following exceptions: - * - the "primary" device must always be present and is the device used by the telephony framework. + * with the following exception: * - the "r_submix" device that must be present to support policyMixes (Eg: Android projected). * Note that this Device is included by default in a build derived from AOSP. * @@ -51,4 +51,20 @@ interface IDevicesFactory { * @return result the interface for the created device. */ openDevice(string device) generates (Result retval, IDevice result); + + /** + * Opens the Primary audio device that must be present. + * This function is not optional and must return successfully the primary device. + * + * This device must have the name "primary". + * + * The telephony stack uses this device to control the audio during a voice call. + * + * @return retval operation completion status. Must be SUCCESS. + * For debuging, return INVALID_ARGUMENTS if there is no corresponding + * hardware module found, NOT_INITIALIZED if an error occurred + * while opening the hardware module. + * @return result the interface for the created device. + */ + openPrimaryDevice() generates (Result retval, IPrimaryDevice result); }; From 5ec293316e7ea1f768161695a113e50b0ea41d45 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Thu, 1 Mar 2018 15:08:07 -0800 Subject: [PATCH 11/12] Audio V4: Implement the shim core 4.0 -> legacy All the new files added are a copy of the 2.0 ones, with just the version 2 that was changed to 4. Due to the rollback on the retrocompatiblity breakage, the split of implementation is not strictly needed any more. This makes the current split in .impl.h and double include unnecessary complicated. This will need to be factorized in a future patch. Bug: 38184704 Test: compile Change-Id: I0d699ade7558ed68125b300f8522e2767ae1ee37 Merged-In: I0d699ade7558ed68125b300f8522e2767ae1ee37 Cherry-picked from master Signed-off-by: Kevin Rocard --- audio/common/2.0/default/VersionUtils.h | 2 + audio/common/4.0/default/VersionUtils.h | 4 +- audio/core/2.0/default/Android.bp | 4 + audio/core/4.0/default/Android.bp | 53 ++++++ audio/core/4.0/default/Conversions.cpp | 21 +++ audio/core/4.0/default/Device.cpp | 28 +++ audio/core/4.0/default/DevicesFactory.cpp | 25 +++ audio/core/4.0/default/ParametersUtil.cpp | 21 +++ audio/core/4.0/default/PrimaryDevice.cpp | 24 +++ audio/core/4.0/default/Stream.cpp | 25 +++ audio/core/4.0/default/StreamIn.cpp | 24 +++ audio/core/4.0/default/StreamOut.cpp | 24 +++ .../include/core/4.0/default/Conversions.h | 26 +++ .../default/include/core/4.0/default/Device.h | 28 +++ .../include/core/4.0/default/DevicesFactory.h | 26 +++ .../include/core/4.0/default/ParametersUtil.h | 26 +++ .../include/core/4.0/default/PrimaryDevice.h | 28 +++ .../default/include/core/4.0/default/Stream.h | 28 +++ .../include/core/4.0/default/StreamIn.h | 29 ++++ .../include/core/4.0/default/StreamOut.h | 29 ++++ audio/core/all-versions/default/Android.bp | 1 - .../core/all-versions/default/Device.h | 47 +++++- .../core/all-versions/default/Device.impl.h | 69 +++++++- .../all-versions/default/DevicesFactory.h | 12 +- .../default/DevicesFactory.impl.h | 73 ++++---- .../all-versions/default/ParametersUtil.h | 11 +- .../default/ParametersUtil.impl.h | 29 +++- .../core/all-versions/default/PrimaryDevice.h | 44 ++++- .../all-versions/default/PrimaryDevice.impl.h | 80 ++++++++- .../core/all-versions/default/Stream.h | 33 +++- .../core/all-versions/default/Stream.impl.h | 159 ++++++++++++------ .../core/all-versions/default/StreamIn.h | 34 +++- .../core/all-versions/default/StreamIn.impl.h | 72 ++++++-- .../core/all-versions/default/StreamOut.h | 34 +++- .../all-versions/default/StreamOut.impl.h | 71 ++++++-- 35 files changed, 1084 insertions(+), 160 deletions(-) create mode 100644 audio/core/4.0/default/Android.bp create mode 100644 audio/core/4.0/default/Conversions.cpp create mode 100644 audio/core/4.0/default/Device.cpp create mode 100644 audio/core/4.0/default/DevicesFactory.cpp create mode 100644 audio/core/4.0/default/ParametersUtil.cpp create mode 100644 audio/core/4.0/default/PrimaryDevice.cpp create mode 100644 audio/core/4.0/default/Stream.cpp create mode 100644 audio/core/4.0/default/StreamIn.cpp create mode 100644 audio/core/4.0/default/StreamOut.cpp create mode 100644 audio/core/4.0/default/include/core/4.0/default/Conversions.h create mode 100644 audio/core/4.0/default/include/core/4.0/default/Device.h create mode 100644 audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h create mode 100644 audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h create mode 100644 audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h create mode 100644 audio/core/4.0/default/include/core/4.0/default/Stream.h create mode 100644 audio/core/4.0/default/include/core/4.0/default/StreamIn.h create mode 100644 audio/core/4.0/default/include/core/4.0/default/StreamOut.h diff --git a/audio/common/2.0/default/VersionUtils.h b/audio/common/2.0/default/VersionUtils.h index fef468080e..60d1f9cb6d 100644 --- a/audio/common/2.0/default/VersionUtils.h +++ b/audio/common/2.0/default/VersionUtils.h @@ -28,6 +28,8 @@ namespace implementation { typedef common::V2_0::AudioDevice AudioDeviceBitfield; typedef common::V2_0::AudioChannelMask AudioChannelBitfield; +typedef common::V2_0::AudioOutputFlag AudioOutputFlagBitfield; +typedef common::V2_0::AudioInputFlag AudioInputFlagBitfield; } // namespace implementation } // namespace V2_0 diff --git a/audio/common/4.0/default/VersionUtils.h b/audio/common/4.0/default/VersionUtils.h index 515c792222..b7f2aec8f9 100644 --- a/audio/common/4.0/default/VersionUtils.h +++ b/audio/common/4.0/default/VersionUtils.h @@ -17,7 +17,7 @@ #ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H #define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H -#include +#include namespace android { namespace hardware { @@ -28,6 +28,8 @@ namespace implementation { typedef hidl_bitfield AudioDeviceBitfield; typedef hidl_bitfield AudioChannelBitfield; +typedef hidl_bitfield AudioOutputFlagBitfield; +typedef hidl_bitfield AudioInputFlagBitfield; } // namespace implementation } // namespace V4_0 diff --git a/audio/core/2.0/default/Android.bp b/audio/core/2.0/default/Android.bp index 98478860c2..625df74a88 100644 --- a/audio/core/2.0/default/Android.bp +++ b/audio/core/2.0/default/Android.bp @@ -14,6 +14,10 @@ cc_library_shared { "StreamOut.cpp", ], + cflags: [ + "-DAUDIO_HAL_VERSION_2_0", + ], + defaults: ["hidl_defaults"], export_include_dirs: ["include"], diff --git a/audio/core/4.0/default/Android.bp b/audio/core/4.0/default/Android.bp new file mode 100644 index 0000000000..8e415459be --- /dev/null +++ b/audio/core/4.0/default/Android.bp @@ -0,0 +1,53 @@ +cc_library_shared { + name: "android.hardware.audio@4.0-impl", + relative_install_path: "hw", + proprietary: true, + vendor: true, + srcs: [ + "Conversions.cpp", + "Device.cpp", + "DevicesFactory.cpp", + "ParametersUtil.cpp", + "PrimaryDevice.cpp", + "Stream.cpp", + "StreamIn.cpp", + "StreamOut.cpp", + ], + + cflags: [ + "-DAUDIO_HAL_VERSION_4_0", + ], + + defaults: ["hidl_defaults"], + + export_include_dirs: ["include"], + + shared_libs: [ + "libbase", + "libcutils", + "libfmq", + "libhardware", + "libhidlbase", + "libhidltransport", + "liblog", + "libutils", + "android.hardware.audio@4.0", + "android.hardware.audio.common@4.0", + "android.hardware.audio.common@4.0-util", + "android.hardware.audio.common-util", + ], + + header_libs: [ + "android.hardware.audio.common.util@all-versions", + "android.hardware.audio.core@all-versions-impl", + "libaudioclient_headers", + "libaudio_system_headers", + "libhardware_headers", + "libmedia_headers", + ], + + whole_static_libs: [ + "libmedia_helper", + ], + +} diff --git a/audio/core/4.0/default/Conversions.cpp b/audio/core/4.0/default/Conversions.cpp new file mode 100644 index 0000000000..4f1874412c --- /dev/null +++ b/audio/core/4.0/default/Conversions.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2017 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 "core/4.0/default/Conversions.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/Device.cpp b/audio/core/4.0/default/Device.cpp new file mode 100644 index 0000000000..26f9ab4a70 --- /dev/null +++ b/audio/core/4.0/default/Device.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "DeviceHAL" + +#include "core/4.0/default/Device.h" +#include +#include "core/4.0/default/Conversions.h" +#include "core/4.0/default/StreamIn.h" +#include "core/4.0/default/StreamOut.h" +#include "core/all-versions/default/Util.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/DevicesFactory.cpp b/audio/core/4.0/default/DevicesFactory.cpp new file mode 100644 index 0000000000..cb8a3c3e97 --- /dev/null +++ b/audio/core/4.0/default/DevicesFactory.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "DevicesFactoryHAL" + +#include "core/4.0/default/DevicesFactory.h" +#include "core/4.0/default/Device.h" +#include "core/4.0/default/PrimaryDevice.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/ParametersUtil.cpp b/audio/core/4.0/default/ParametersUtil.cpp new file mode 100644 index 0000000000..5c1b1c4b18 --- /dev/null +++ b/audio/core/4.0/default/ParametersUtil.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2017 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 "core/4.0/default/ParametersUtil.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/PrimaryDevice.cpp b/audio/core/4.0/default/PrimaryDevice.cpp new file mode 100644 index 0000000000..0294b4d0d4 --- /dev/null +++ b/audio/core/4.0/default/PrimaryDevice.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "PrimaryDeviceHAL" + +#include "core/4.0/default/PrimaryDevice.h" +#include "core/all-versions/default/Util.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/Stream.cpp b/audio/core/4.0/default/Stream.cpp new file mode 100644 index 0000000000..30b34544d6 --- /dev/null +++ b/audio/core/4.0/default/Stream.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "StreamHAL" + +#include "core/4.0/default/Stream.h" +#include "common/all-versions/default/EffectMap.h" +#include "core/4.0/default/Conversions.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/StreamIn.cpp b/audio/core/4.0/default/StreamIn.cpp new file mode 100644 index 0000000000..18719b5da2 --- /dev/null +++ b/audio/core/4.0/default/StreamIn.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "StreamInHAL" + +#include "core/4.0/default/StreamIn.h" +#include "core/all-versions/default/Util.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/StreamOut.cpp b/audio/core/4.0/default/StreamOut.cpp new file mode 100644 index 0000000000..11c8fde663 --- /dev/null +++ b/audio/core/4.0/default/StreamOut.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "StreamOutHAL" + +#include "core/4.0/default/StreamOut.h" +#include "core/all-versions/default/Util.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/include/core/4.0/default/Conversions.h b/audio/core/4.0/default/include/core/4.0/default/Conversions.h new file mode 100644 index 0000000000..32c2f887ee --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/Conversions.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_ +#define ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_ + +#include + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_ diff --git a/audio/core/4.0/default/include/core/4.0/default/Device.h b/audio/core/4.0/default/include/core/4.0/default/Device.h new file mode 100644 index 0000000000..770d606720 --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/Device.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H +#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H + +#include + +#include "ParametersUtil.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H diff --git a/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h b/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h new file mode 100644 index 0000000000..200e59d96f --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H +#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H + +#include + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H diff --git a/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h b/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h new file mode 100644 index 0000000000..fa31ee9dd3 --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_ +#define ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_ + +#include + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_ diff --git a/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h b/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h new file mode 100644 index 0000000000..e7f846b622 --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H +#define ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H + +#include + +#include "Device.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H diff --git a/audio/core/4.0/default/include/core/4.0/default/Stream.h b/audio/core/4.0/default/include/core/4.0/default/Stream.h new file mode 100644 index 0000000000..afad80fe53 --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/Stream.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H +#define ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H + +#include + +#include "ParametersUtil.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H diff --git a/audio/core/4.0/default/include/core/4.0/default/StreamIn.h b/audio/core/4.0/default/include/core/4.0/default/StreamIn.h new file mode 100644 index 0000000000..151f03fc2b --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/StreamIn.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H +#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H + +#include + +#include "Device.h" +#include "Stream.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H diff --git a/audio/core/4.0/default/include/core/4.0/default/StreamOut.h b/audio/core/4.0/default/include/core/4.0/default/StreamOut.h new file mode 100644 index 0000000000..dbf3bd16ce --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/StreamOut.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H +#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H + +#include + +#include "Device.h" +#include "Stream.h" + +#define AUDIO_HAL_VERSION V4_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H diff --git a/audio/core/all-versions/default/Android.bp b/audio/core/all-versions/default/Android.bp index 214b8d5b26..bb02863ba6 100644 --- a/audio/core/all-versions/default/Android.bp +++ b/audio/core/all-versions/default/Android.bp @@ -1,7 +1,6 @@ cc_library_headers { name: "android.hardware.audio.core@all-versions-impl", relative_install_path: "hw", - proprietary: true, vendor: true, defaults: ["hidl_defaults"], diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Device.h b/audio/core/all-versions/default/include/core/all-versions/default/Device.h index 224823c8aa..eb53b482b2 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Device.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/Device.h @@ -25,6 +25,8 @@ #include +#include + namespace android { namespace hardware { namespace audio { @@ -39,6 +41,9 @@ using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPatchHandle; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioInputFlagBitfield; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation:: + AudioOutputFlagBitfield; using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice; using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn; @@ -51,6 +56,11 @@ using ::android::hardware::hidl_vec; using ::android::hardware::hidl_string; using ::android::sp; +#ifdef AUDIO_HAL_VERSION_4_0 +using ::android::hardware::audio::AUDIO_HAL_VERSION::SourceMetadata; +using ::android::hardware::audio::AUDIO_HAL_VERSION::SinkMetadata; +#endif + struct Device : public IDevice, public ParametersUtil { explicit Device(audio_hw_device_t* device); @@ -64,12 +74,26 @@ struct Device : public IDevice, public ParametersUtil { Return getMasterMute(getMasterMute_cb _hidl_cb) override; Return getInputBufferSize(const AudioConfig& config, getInputBufferSize_cb _hidl_cb) override; + + // V2 openInputStream is called by V4 input stream thus present in both versions + Return openInputStream(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, AudioInputFlagBitfield flags, + AudioSource source, openInputStream_cb _hidl_cb); +#ifdef AUDIO_HAL_VERSION_2_0 Return openOutputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioOutputFlag flags, + const AudioConfig& config, AudioOutputFlagBitfield flags, + openOutputStream_cb _hidl_cb) override; +#elif defined(AUDIO_HAL_VERSION_4_0) + Return openOutputStream(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, AudioOutputFlagBitfield flags, + const SourceMetadata& sourceMetadata, openOutputStream_cb _hidl_cb) override; Return openInputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioInputFlag flags, - AudioSource source, openInputStream_cb _hidl_cb) override; + const AudioConfig& config, AudioInputFlagBitfield flags, + const SinkMetadata& sinkMetadata, + openInputStream_cb _hidl_cb) override; +#endif + Return supportsAudioPatches() override; Return createAudioPatch(const hidl_vec& sources, const hidl_vec& sinks, @@ -77,12 +101,27 @@ struct Device : public IDevice, public ParametersUtil { Return releaseAudioPatch(int32_t patch) override; Return getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override; Return setAudioPortConfig(const AudioPortConfig& config) override; - Return getHwAvSync() override; + Return setScreenState(bool turnedOn) override; + +#ifdef AUDIO_HAL_VERSION_2_0 + Return getHwAvSync() override; Return getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) override; Return setParameters(const hidl_vec& parameters) override; Return debugDump(const hidl_handle& fd) override; +#elif defined(AUDIO_HAL_VERSION_4_0) + Return getHwAvSync(getHwAvSync_cb _hidl_cb) override; + Return getParameters(const hidl_vec& context, + const hidl_vec& keys, + getParameters_cb _hidl_cb) override; + Return setParameters(const hidl_vec& context, + const hidl_vec& parameters) override; + Return getMicrophones(getMicrophones_cb _hidl_cb) override; + Return setConnectedState(const DeviceAddress& address, bool connected) override; +#endif + + Return debug(const hidl_handle& fd, const hidl_vec& options) override; // Utility methods for extending interfaces. Result analyzeStatus(const char* funcName, int status); diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h index b2950825ba..fb4b686c43 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h @@ -147,7 +147,10 @@ Return Device::getInputBufferSize(const AudioConfig& config, getInputBuffe } Return Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioOutputFlag flags, + const AudioConfig& config, AudioOutputFlagBitfield flags, +#ifdef AUDIO_HAL_VERSION_4_0 + const SourceMetadata& /* sourceMetadata */, +#endif openOutputStream_cb _hidl_cb) { audio_config_t halConfig; HidlUtils::audioConfigToHal(config, &halConfig); @@ -174,7 +177,7 @@ Return Device::openOutputStream(int32_t ioHandle, const DeviceAddress& dev } Return Device::openInputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioInputFlag flags, + const AudioConfig& config, AudioInputFlagBitfield flags, AudioSource source, openInputStream_cb _hidl_cb) { audio_config_t halConfig; HidlUtils::audioConfigToHal(config, &halConfig); @@ -201,6 +204,24 @@ Return Device::openInputStream(int32_t ioHandle, const DeviceAddress& devi return Void(); } +#ifdef AUDIO_HAL_VERSION_4_0 +Return Device::openInputStream(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, AudioInputFlagBitfield flags, + const SinkMetadata& sinkMetadata, + openInputStream_cb _hidl_cb) { + if (sinkMetadata.tracks.size() == 0) { + // This should never happen, the framework must not create as stream + // if there is no client + ALOGE("openInputStream called without tracks connected"); + _hidl_cb(Result::INVALID_ARGUMENTS, nullptr, AudioConfig()); + return Void(); + } + // Pick the first one as the main until the legacy API is update + AudioSource source = sinkMetadata.tracks[0].source; + return openInputStream(ioHandle, device, config, flags, source, _hidl_cb); +} +#endif + Return Device::supportsAudioPatches() { return version() >= AUDIO_DEVICE_API_VERSION_3_0; } @@ -256,32 +277,72 @@ Return Device::setAudioPortConfig(const AudioPortConfig& config) { return Result::NOT_SUPPORTED; } +#ifdef AUDIO_HAL_VERSION_2_0 Return Device::getHwAvSync() { int halHwAvSync; Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync); return retval == Result::OK ? halHwAvSync : AUDIO_HW_SYNC_INVALID; } +#elif defined(AUDIO_HAL_VERSION_4_0) +Return Device::getHwAvSync(getHwAvSync_cb _hidl_cb) { + int halHwAvSync; + Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync); + _hidl_cb(retval, halHwAvSync); + return Void(); +} +#endif Return Device::setScreenState(bool turnedOn) { return setParam(AudioParameter::keyScreenState, turnedOn); } +#ifdef AUDIO_HAL_VERSION_2_0 Return Device::getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) { - getParametersImpl(keys, _hidl_cb); + getParametersImpl({}, keys, _hidl_cb); return Void(); } Return Device::setParameters(const hidl_vec& parameters) { - return setParametersImpl(parameters); + return setParametersImpl({} /* context */, parameters); } +#elif defined(AUDIO_HAL_VERSION_4_0) +Return Device::getParameters(const hidl_vec& context, + const hidl_vec& keys, getParameters_cb _hidl_cb) { + getParametersImpl(context, keys, _hidl_cb); + return Void(); +} +Return Device::setParameters(const hidl_vec& context, + const hidl_vec& parameters) { + return setParametersImpl(context, parameters); +} +#endif +#ifdef AUDIO_HAL_VERSION_2_0 Return Device::debugDump(const hidl_handle& fd) { + return debug(fd, {}); +} +#endif + +Return Device::debug(const hidl_handle& fd, const hidl_vec& /* options */) { if (fd.getNativeHandle() != nullptr && fd->numFds == 1) { analyzeStatus("dump", mDevice->dump(mDevice, fd->data[0])); } return Void(); } +#ifdef AUDIO_HAL_VERSION_4_0 +Return Device::getMicrophones(getMicrophones_cb _hidl_cb) { + // TODO return device microphones + _hidl_cb(Result::NOT_SUPPORTED, {}); + return Void(); +} + +Return Device::setConnectedState(const DeviceAddress& address, bool connected) { + auto key = connected ? AudioParameter::keyStreamConnect : AudioParameter::keyStreamDisconnect; + return setParam(key, address); +} +#endif + } // namespace implementation } // namespace AUDIO_HAL_VERSION } // namespace audio diff --git a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h b/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h index 769adaa1e9..1509ad170c 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h @@ -37,11 +37,19 @@ using ::android::hardware::hidl_string; using ::android::sp; struct DevicesFactory : public IDevicesFactory { - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevicesFactory follow. +#ifdef AUDIO_HAL_VERSION_2_0 Return openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) override; +#endif +#ifdef AUDIO_HAL_VERSION_4_0 + Return openDevice(const hidl_string& device, openDevice_cb _hidl_cb) override; + Return openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override; +#endif private: - static const char* deviceToString(IDevicesFactory::Device device); + template + Return openDevice(const char* moduleName, Callback _hidl_cb); + Return openDevice(const char* moduleName, openDevice_cb _hidl_cb); + static int loadAudioInterface(const char* if_name, audio_hw_device_t** dev); }; diff --git a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h index 014b4d8043..43e5d6eaed 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h @@ -26,21 +26,54 @@ namespace audio { namespace AUDIO_HAL_VERSION { namespace implementation { -// static -const char* DevicesFactory::deviceToString(IDevicesFactory::Device device) { +#ifdef AUDIO_HAL_VERSION_2_0 +Return DevicesFactory::openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) { switch (device) { case IDevicesFactory::Device::PRIMARY: - return AUDIO_HARDWARE_MODULE_ID_PRIMARY; + return openDevice(AUDIO_HARDWARE_MODULE_ID_PRIMARY, _hidl_cb); case IDevicesFactory::Device::A2DP: - return AUDIO_HARDWARE_MODULE_ID_A2DP; + return openDevice(AUDIO_HARDWARE_MODULE_ID_A2DP, _hidl_cb); case IDevicesFactory::Device::USB: - return AUDIO_HARDWARE_MODULE_ID_USB; + return openDevice(AUDIO_HARDWARE_MODULE_ID_USB, _hidl_cb); case IDevicesFactory::Device::R_SUBMIX: - return AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX; + return openDevice(AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX, _hidl_cb); case IDevicesFactory::Device::STUB: - return AUDIO_HARDWARE_MODULE_ID_STUB; + return openDevice(AUDIO_HARDWARE_MODULE_ID_STUB, _hidl_cb); } - return nullptr; + _hidl_cb(Result::INVALID_ARGUMENTS, nullptr); + return Void(); +} +#endif +#ifdef AUDIO_HAL_VERSION_4_0 +Return DevicesFactory::openDevice(const hidl_string& moduleName, openDevice_cb _hidl_cb) { + if (moduleName == AUDIO_HARDWARE_MODULE_ID_PRIMARY) { + return openDevice(moduleName.c_str(), _hidl_cb); + } + return openDevice(moduleName.c_str(), _hidl_cb); +} +Return DevicesFactory::openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) { + return openDevice(AUDIO_HARDWARE_MODULE_ID_PRIMARY, _hidl_cb); +} +#endif + +Return DevicesFactory::openDevice(const char* moduleName, openDevice_cb _hidl_cb) { + return openDevice(moduleName, _hidl_cb); +} + +template +Return DevicesFactory::openDevice(const char* moduleName, Callback _hidl_cb) { + audio_hw_device_t* halDevice; + Result retval(Result::INVALID_ARGUMENTS); + sp result; + int halStatus = loadAudioInterface(moduleName, &halDevice); + if (halStatus == OK) { + result = new DeviceShim(halDevice); + retval = Result::OK; + } else if (halStatus == -EINVAL) { + retval = Result::NOT_INITIALIZED; + } + _hidl_cb(retval, result); + return Void(); } // static @@ -73,30 +106,6 @@ out: return rc; } -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevicesFactory follow. -Return DevicesFactory::openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) { - audio_hw_device_t* halDevice; - Result retval(Result::INVALID_ARGUMENTS); - sp result; - const char* moduleName = deviceToString(device); - if (moduleName != nullptr) { - int halStatus = loadAudioInterface(moduleName, &halDevice); - if (halStatus == OK) { - if (device == IDevicesFactory::Device::PRIMARY) { - result = new PrimaryDevice(halDevice); - } else { - result = new ::android::hardware::audio::AUDIO_HAL_VERSION::implementation::Device( - halDevice); - } - retval = Result::OK; - } else if (halStatus == -EINVAL) { - retval = Result::NOT_INITIALIZED; - } - } - _hidl_cb(retval, result); - return Void(); -} - IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* /* name */) { return new DevicesFactory(); } diff --git a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h b/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h index df5adeefc1..a27ac25d43 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h @@ -28,6 +28,7 @@ namespace audio { namespace AUDIO_HAL_VERSION { namespace implementation { +using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; using ::android::hardware::hidl_string; @@ -37,16 +38,18 @@ class ParametersUtil { public: Result getParam(const char* name, bool* value); Result getParam(const char* name, int* value); - Result getParam(const char* name, String8* value); + Result getParam(const char* name, String8* value, AudioParameter context = {}); void getParametersImpl( - const hidl_vec& keys, + const hidl_vec& context, const hidl_vec& keys, std::function& parameters)> cb); std::unique_ptr getParams(const AudioParameter& keys); Result setParam(const char* name, bool value); Result setParam(const char* name, int value); - Result setParam(const char* name, const char* value); - Result setParametersImpl(const hidl_vec& parameters); + Result setParam(const char* name, float value); + Result setParametersImpl(const hidl_vec& context, + const hidl_vec& parameters); Result setParams(const AudioParameter& param); + Result setParam(const char* name, const DeviceAddress& address); protected: virtual ~ParametersUtil() {} diff --git a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h index a858a488eb..3907284048 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h @@ -15,6 +15,8 @@ */ #include +#include +#include namespace android { namespace hardware { @@ -62,18 +64,20 @@ Result ParametersUtil::getParam(const char* name, int* value) { return getHalStatusToResult(params->getInt(halName, *value)); } -Result ParametersUtil::getParam(const char* name, String8* value) { +Result ParametersUtil::getParam(const char* name, String8* value, AudioParameter context) { const String8 halName(name); - AudioParameter keys; - keys.addKey(halName); - std::unique_ptr params = getParams(keys); + context.addKey(halName); + std::unique_ptr params = getParams(context); return getHalStatusToResult(params->get(halName, *value)); } void ParametersUtil::getParametersImpl( - const hidl_vec& keys, + const hidl_vec& context, const hidl_vec& keys, std::function& parameters)> cb) { AudioParameter halKeys; + for (auto& pair : context) { + halKeys.add(String8(pair.key.c_str()), String8(pair.value.c_str())); + } for (size_t i = 0; i < keys.size(); ++i) { halKeys.addKey(String8(keys[i].c_str())); } @@ -120,19 +124,28 @@ Result ParametersUtil::setParam(const char* name, int value) { return setParams(param); } -Result ParametersUtil::setParam(const char* name, const char* value) { +Result ParametersUtil::setParam(const char* name, float value) { AudioParameter param; - param.add(String8(name), String8(value)); + param.addFloat(String8(name), value); return setParams(param); } -Result ParametersUtil::setParametersImpl(const hidl_vec& parameters) { +Result ParametersUtil::setParametersImpl(const hidl_vec& context, + const hidl_vec& parameters) { AudioParameter params; + for (auto& pair : context) { + params.add(String8(pair.key.c_str()), String8(pair.value.c_str())); + } for (size_t i = 0; i < parameters.size(); ++i) { params.add(String8(parameters[i].key.c_str()), String8(parameters[i].value.c_str())); } 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)); + return setParams(params); +} Result ParametersUtil::setParams(const AudioParameter& param) { int halStatus = halSetParameters(param.toString().string()); diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h index 240b2212a2..42996d703e 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h @@ -59,12 +59,24 @@ struct PrimaryDevice : public IPrimaryDevice { Return getMasterMute(getMasterMute_cb _hidl_cb) override; Return getInputBufferSize(const AudioConfig& config, getInputBufferSize_cb _hidl_cb) override; + Return openOutputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioOutputFlag flags, + const AudioConfig& config, AudioOutputFlagBitfield flags, +#ifdef AUDIO_HAL_VERSION_4_0 + const SourceMetadata& sourceMetadata, +#endif openOutputStream_cb _hidl_cb) override; + Return openInputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioInputFlag flags, - AudioSource source, openInputStream_cb _hidl_cb) override; + const AudioConfig& config, AudioInputFlagBitfield flags, + AudioSource source, openInputStream_cb _hidl_cb); +#ifdef AUDIO_HAL_VERSION_4_0 + Return openInputStream(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, AudioInputFlagBitfield flags, + const SinkMetadata& sinkMetadata, + openInputStream_cb _hidl_cb) override; +#endif + Return supportsAudioPatches() override; Return createAudioPatch(const hidl_vec& sources, const hidl_vec& sinks, @@ -72,12 +84,27 @@ struct PrimaryDevice : public IPrimaryDevice { Return releaseAudioPatch(int32_t patch) override; Return getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override; Return setAudioPortConfig(const AudioPortConfig& config) override; - Return getHwAvSync() override; + Return setScreenState(bool turnedOn) override; + +#ifdef AUDIO_HAL_VERSION_2_0 + Return getHwAvSync() override; Return getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) override; Return setParameters(const hidl_vec& parameters) override; Return debugDump(const hidl_handle& fd) override; +#elif defined(AUDIO_HAL_VERSION_4_0) + Return getHwAvSync(getHwAvSync_cb _hidl_cb) override; + Return getParameters(const hidl_vec& context, + const hidl_vec& keys, + getParameters_cb _hidl_cb) override; + Return setParameters(const hidl_vec& context, + const hidl_vec& parameters) override; + Return getMicrophones(getMicrophones_cb _hidl_cb) override; + Return setConnectedState(const DeviceAddress& address, bool connected) override; +#endif + + Return debug(const hidl_handle& fd, const hidl_vec& options) override; // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice follow. Return setVoiceVolume(float volume) override; @@ -91,6 +118,15 @@ struct PrimaryDevice : public IPrimaryDevice { Return getHacEnabled(getHacEnabled_cb _hidl_cb) override; Return setHacEnabled(bool enabled) override; +#ifdef AUDIO_HAL_VERSION_4_0 + Return setBtScoHeadsetDebugName(const hidl_string& name) override; + Return getBtHfpEnabled(getBtHfpEnabled_cb _hidl_cb) override; + Return setBtHfpEnabled(bool enabled) override; + Return setBtHfpSampleRate(uint32_t sampleRateHz) override; + Return setBtHfpVolume(float volume) override; + Return updateRotation(IPrimaryDevice::Rotation rotation) override; +#endif + private: sp mDevice; diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h index 3ce047ac07..f00cac4ee1 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h @@ -60,17 +60,35 @@ Return PrimaryDevice::getInputBufferSize(const AudioConfig& config, return mDevice->getInputBufferSize(config, _hidl_cb); } +#ifdef AUDIO_HAL_VERSION_2_0 Return PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioOutputFlag flags, + const AudioConfig& config, + AudioOutputFlagBitfield flags, openOutputStream_cb _hidl_cb) { return mDevice->openOutputStream(ioHandle, device, config, flags, _hidl_cb); } Return PrimaryDevice::openInputStream(int32_t ioHandle, const DeviceAddress& device, - const AudioConfig& config, AudioInputFlag flags, + const AudioConfig& config, AudioInputFlagBitfield flags, AudioSource source, openInputStream_cb _hidl_cb) { return mDevice->openInputStream(ioHandle, device, config, flags, source, _hidl_cb); } +#elif defined(AUDIO_HAL_VERSION_4_0) +Return PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, + AudioOutputFlagBitfield flags, + const SourceMetadata& sourceMetadata, + openOutputStream_cb _hidl_cb) { + return mDevice->openOutputStream(ioHandle, device, config, flags, sourceMetadata, _hidl_cb); +} + +Return PrimaryDevice::openInputStream(int32_t ioHandle, const DeviceAddress& device, + const AudioConfig& config, AudioInputFlagBitfield flags, + const SinkMetadata& sinkMetadata, + openInputStream_cb _hidl_cb) { + return mDevice->openInputStream(ioHandle, device, config, flags, sinkMetadata, _hidl_cb); +} +#endif Return PrimaryDevice::supportsAudioPatches() { return mDevice->supportsAudioPatches(); @@ -94,14 +112,15 @@ Return PrimaryDevice::setAudioPortConfig(const AudioPortConfig& config) return mDevice->setAudioPortConfig(config); } -Return PrimaryDevice::getHwAvSync() { - return mDevice->getHwAvSync(); -} - Return PrimaryDevice::setScreenState(bool turnedOn) { return mDevice->setScreenState(turnedOn); } +#ifdef AUDIO_HAL_VERSION_2_0 +Return PrimaryDevice::getHwAvSync() { + return mDevice->getHwAvSync(); +} + Return PrimaryDevice::getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) { return mDevice->getParameters(keys, _hidl_cb); @@ -114,6 +133,26 @@ Return PrimaryDevice::setParameters(const hidl_vec& para Return PrimaryDevice::debugDump(const hidl_handle& fd) { return mDevice->debugDump(fd); } +#elif defined(AUDIO_HAL_VERSION_4_0) +Return PrimaryDevice::getHwAvSync(getHwAvSync_cb _hidl_cb) { + return mDevice->getHwAvSync(_hidl_cb); +} +Return PrimaryDevice::getParameters(const hidl_vec& context, + const hidl_vec& keys, + getParameters_cb _hidl_cb) { + return mDevice->getParameters(context, keys, _hidl_cb); +} +Return PrimaryDevice::setParameters(const hidl_vec& context, + const hidl_vec& parameters) { + return mDevice->setParameters(context, parameters); +} +Return PrimaryDevice::getMicrophones(getMicrophones_cb _hidl_cb) { + return mDevice->getMicrophones(_hidl_cb); +} +Return PrimaryDevice::setConnectedState(const DeviceAddress& address, bool connected) { + return mDevice->setConnectedState(address, connected); +} +#endif // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice follow. Return PrimaryDevice::setVoiceVolume(float volume) { @@ -188,6 +227,35 @@ Return PrimaryDevice::setHacEnabled(bool enabled) { return mDevice->setParam(AUDIO_PARAMETER_KEY_HAC, enabled); } +#ifdef AUDIO_HAL_VERSION_4_0 +Return PrimaryDevice::setBtScoHeadsetDebugName(const hidl_string& name) { + return mDevice->setParam(AUDIO_PARAMETER_KEY_BT_SCO_HEADSET_NAME, name.c_str()); +} +Return PrimaryDevice::getBtHfpEnabled(getBtHfpEnabled_cb _hidl_cb) { + bool enabled; + Result retval = mDevice->getParam(AUDIO_PARAMETER_KEY_HFP_ENABLE, &enabled); + _hidl_cb(retval, enabled); + return Void(); +} +Return PrimaryDevice::setBtHfpEnabled(bool enabled) { + return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_ENABLE, enabled); +} +Return PrimaryDevice::setBtHfpSampleRate(uint32_t sampleRateHz) { + return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE, int(sampleRateHz)); +} +Return PrimaryDevice::setBtHfpVolume(float volume) { + return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_VOLUME, volume); +} +Return PrimaryDevice::updateRotation(IPrimaryDevice::Rotation rotation) { + // legacy API expects the rotation in degree + return mDevice->setParam(AUDIO_PARAMETER_KEY_ROTATION, int(rotation) * 90); +} +#endif + +Return PrimaryDevice::debug(const hidl_handle& fd, const hidl_vec& options) { + return mDevice->debug(fd, options); +} + } // namespace implementation } // namespace AUDIO_HAL_VERSION } // namespace audio diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h b/audio/core/all-versions/default/include/core/all-versions/default/Stream.h index 4196dec7df..6f79429c61 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/Stream.h @@ -23,6 +23,8 @@ #include +#include + namespace android { namespace hardware { namespace audio { @@ -32,6 +34,7 @@ namespace implementation { using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield; using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; using ::android::hardware::audio::AUDIO_HAL_VERSION::IStream; using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; @@ -57,11 +60,15 @@ struct Stream : public IStream, public ParametersUtil { Return getFrameCount() override; Return getBufferSize() override; Return getSampleRate() override; +#ifdef AUDIO_HAL_VERSION_2_0 Return getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override; - Return setSampleRate(uint32_t sampleRateHz) override; - Return getChannelMask() override; Return getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override; - Return setChannelMask(AudioChannelMask mask) override; +#endif + Return getSupportedSampleRates(AudioFormat format, getSupportedSampleRates_cb _hidl_cb); + Return getSupportedChannelMasks(AudioFormat format, getSupportedChannelMasks_cb _hidl_cb); + Return setSampleRate(uint32_t sampleRateHz) override; + Return getChannelMask() override; + Return setChannelMask(AudioChannelBitfield mask) override; Return getFormat() override; Return getSupportedFormats(getSupportedFormats_cb _hidl_cb) override; Return setFormat(AudioFormat format) override; @@ -69,20 +76,34 @@ struct Stream : public IStream, public ParametersUtil { Return addEffect(uint64_t effectId) override; Return removeEffect(uint64_t effectId) override; Return standby() override; +#ifdef AUDIO_HAL_VERSION_2_0 Return getDevice() override; Return setDevice(const DeviceAddress& address) override; - Return setConnectedState(const DeviceAddress& address, bool connected) override; - Return setHwAvSync(uint32_t hwAvSync) override; Return getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) override; Return setParameters(const hidl_vec& parameters) override; - Return debugDump(const hidl_handle& fd) override; + Return setConnectedState(const DeviceAddress& address, bool connected) override; +#elif defined(AUDIO_HAL_VERSION_4_0) + Return getDevices(getDevices_cb _hidl_cb) override; + Return setDevices(const hidl_vec& devices) override; + Return getParameters(const hidl_vec& context, + const hidl_vec& keys, + getParameters_cb _hidl_cb) override; + Return setParameters(const hidl_vec& context, + const hidl_vec& parameters) override; +#endif + Return setHwAvSync(uint32_t hwAvSync) override; Return start() override; Return stop() override; Return createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override; Return getMmapPosition(getMmapPosition_cb _hidl_cb) override; Return close() override; + Return debug(const hidl_handle& fd, const hidl_vec& options) override; +#ifdef AUDIO_HAL_VERSION_2_0 + Return debugDump(const hidl_handle& fd) override; +#endif + // Utility methods for extending interfaces. static Result analyzeStatus(const char* funcName, int status); static Result analyzeStatus(const char* funcName, int status, diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h index 92cff72642..fa0ef45bec 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h @@ -100,9 +100,22 @@ Return Stream::getSampleRate() { return mStream->get_sample_rate(mStream); } +#ifdef AUDIO_HAL_VERSION_2_0 Return Stream::getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) { + return getSupportedSampleRates(getFormat(), _hidl_cb); +} +Return Stream::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { + return getSupportedChannelMasks(getFormat(), _hidl_cb); +} +#endif + +Return Stream::getSupportedSampleRates(AudioFormat format, + getSupportedSampleRates_cb _hidl_cb) { + AudioParameter context; + context.addInt(String8(AUDIO_PARAMETER_STREAM_FORMAT), int(format)); String8 halListValue; - Result result = getParam(AudioParameter::keyStreamSupportedSamplingRates, &halListValue); + Result result = + getParam(AudioParameter::keyStreamSupportedSamplingRates, &halListValue, context); hidl_vec sampleRates; SortedVector halSampleRates; if (result == Result::OK) { @@ -110,7 +123,36 @@ Return Stream::getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb samplingRatesFromString(halListValue.string(), AudioParameter::valueListSeparator); sampleRates.setToExternal(halSampleRates.editArray(), halSampleRates.size()); } +#ifdef AUDIO_HAL_VERSION_2_0 _hidl_cb(sampleRates); +#endif +#ifdef AUDIO_HAL_VERSION_4_0 + _hidl_cb(result, sampleRates); +#endif + return Void(); +} + +Return Stream::getSupportedChannelMasks(AudioFormat format, + getSupportedChannelMasks_cb _hidl_cb) { + AudioParameter context; + context.addInt(String8(AUDIO_PARAMETER_STREAM_FORMAT), int(format)); + String8 halListValue; + Result result = getParam(AudioParameter::keyStreamSupportedChannels, &halListValue, context); + hidl_vec channelMasks; + SortedVector halChannelMasks; + if (result == Result::OK) { + halChannelMasks = + channelMasksFromString(halListValue.string(), AudioParameter::valueListSeparator); + channelMasks.resize(halChannelMasks.size()); + for (size_t i = 0; i < halChannelMasks.size(); ++i) { + channelMasks[i] = AudioChannelBitfield(halChannelMasks[i]); + } + } +#ifdef AUDIO_HAL_VERSION_2_0 + _hidl_cb(channelMasks); +#elif defined(AUDIO_HAL_VERSION_4_0) + _hidl_cb(result, channelMasks); +#endif return Void(); } @@ -118,28 +160,11 @@ Return Stream::setSampleRate(uint32_t sampleRateHz) { return setParam(AudioParameter::keySamplingRate, static_cast(sampleRateHz)); } -Return Stream::getChannelMask() { - return AudioChannelMask(mStream->get_channels(mStream)); +Return Stream::getChannelMask() { + return AudioChannelBitfield(mStream->get_channels(mStream)); } -Return Stream::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { - String8 halListValue; - Result result = getParam(AudioParameter::keyStreamSupportedChannels, &halListValue); - hidl_vec channelMasks; - SortedVector halChannelMasks; - if (result == Result::OK) { - halChannelMasks = - channelMasksFromString(halListValue.string(), AudioParameter::valueListSeparator); - channelMasks.resize(halChannelMasks.size()); - for (size_t i = 0; i < halChannelMasks.size(); ++i) { - channelMasks[i] = AudioChannelMask(halChannelMasks[i]); - } - } - _hidl_cb(channelMasks); - return Void(); -} - -Return Stream::setChannelMask(AudioChannelMask mask) { +Return Stream::setChannelMask(AudioChannelBitfield mask) { return setParam(AudioParameter::keyChannels, static_cast(mask)); } @@ -171,7 +196,7 @@ Return Stream::getAudioProperties(getAudioProperties_cb _hidl_cb) { uint32_t halSampleRate = mStream->get_sample_rate(mStream); audio_channel_mask_t halMask = mStream->get_channels(mStream); audio_format_t halFormat = mStream->get_format(mStream); - _hidl_cb(halSampleRate, AudioChannelMask(halMask), AudioFormat(halFormat)); + _hidl_cb(halSampleRate, AudioChannelBitfield(halMask), AudioFormat(halFormat)); return Void(); } @@ -200,48 +225,73 @@ Return Stream::standby() { return analyzeStatus("standby", mStream->standby(mStream)); } +Return Stream::setHwAvSync(uint32_t hwAvSync) { + return setParam(AudioParameter::keyStreamHwAvSync, static_cast(hwAvSync)); +} + +#ifdef AUDIO_HAL_VERSION_2_0 Return Stream::getDevice() { - int device; + int device = 0; Result retval = getParam(AudioParameter::keyRouting, &device); return retval == Result::OK ? static_cast(device) : AudioDevice::NONE; } Return Stream::setDevice(const DeviceAddress& address) { - char* halDeviceAddress = audio_device_address_to_parameter( - static_cast(address.device), deviceAddressToHal(address).c_str()); - AudioParameter params((String8(halDeviceAddress))); - free(halDeviceAddress); - params.addInt(String8(AudioParameter::keyRouting), - static_cast(address.device)); - return setParams(params); + return setParam(AudioParameter::keyRouting, address); +} + +Return Stream::getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) { + getParametersImpl({} /* context */, keys, _hidl_cb); + return Void(); +} + +Return Stream::setParameters(const hidl_vec& parameters) { + return setParametersImpl({} /* context */, parameters); } Return Stream::setConnectedState(const DeviceAddress& address, bool connected) { return setParam( connected ? AudioParameter::keyStreamConnect : AudioParameter::keyStreamDisconnect, - deviceAddressToHal(address).c_str()); + address); } - -Return Stream::setHwAvSync(uint32_t hwAvSync) { - return setParam(AudioParameter::keyStreamHwAvSync, static_cast(hwAvSync)); -} - -Return Stream::getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) { - getParametersImpl(keys, _hidl_cb); - return Void(); -} - -Return Stream::setParameters(const hidl_vec& parameters) { - return setParametersImpl(parameters); -} - -Return Stream::debugDump(const hidl_handle& fd) { - if (fd.getNativeHandle() != nullptr && fd->numFds == 1) { - analyzeStatus("dump", mStream->dump(mStream, fd->data[0])); +#elif defined(AUDIO_HAL_VERSION_4_0) +Return Stream::getDevices(getDevices_cb _hidl_cb) { + int device = 0; + Result retval = getParam(AudioParameter::keyRouting, &device); + hidl_vec devices; + if (retval == Result::OK) { + devices.resize(1); + devices[0].device = static_cast(device); } + _hidl_cb(retval, devices); return Void(); } +Return Stream::setDevices(const hidl_vec& devices) { + // FIXME: can the legacy API set multiple device with address ? + if (devices.size() > 1) { + return Result::NOT_SUPPORTED; + } + DeviceAddress address; + if (devices.size() == 1) { + address = devices[0]; + } else { + address.device = AudioDevice::NONE; + } + return setParam(AudioParameter::keyRouting, address); +} +Return Stream::getParameters(const hidl_vec& context, + const hidl_vec& keys, getParameters_cb _hidl_cb) { + getParametersImpl(context, keys, _hidl_cb); + return Void(); +} + +Return Stream::setParameters(const hidl_vec& context, + const hidl_vec& parameters) { + return setParametersImpl(context, parameters); +} +#endif + Return Stream::start() { return Result::NOT_SUPPORTED; } @@ -269,6 +319,19 @@ Return Stream::close() { return Result::NOT_SUPPORTED; } +Return Stream::debug(const hidl_handle& fd, const hidl_vec& /* options */) { + if (fd.getNativeHandle() != nullptr && fd->numFds == 1) { + analyzeStatus("dump", mStream->dump(mStream, fd->data[0])); + } + return Void(); +} + +#ifdef AUDIO_HAL_VERSION_2_0 +Return Stream::debugDump(const hidl_handle& fd) { + return debug(fd, {} /* options */); +} +#endif + } // namespace implementation } // namespace AUDIO_HAL_VERSION } // namespace audio diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h b/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h index 7380dae108..f226e63f70 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h @@ -58,11 +58,15 @@ struct StreamIn : public IStreamIn { Return getFrameCount() override; Return getBufferSize() override; Return getSampleRate() override; +#ifdef AUDIO_HAL_VERSION_2_0 Return getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override; - Return setSampleRate(uint32_t sampleRateHz) override; - Return getChannelMask() override; Return getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override; - Return setChannelMask(AudioChannelMask mask) override; +#endif + Return getSupportedSampleRates(AudioFormat format, getSupportedSampleRates_cb _hidl_cb); + Return getSupportedChannelMasks(AudioFormat format, getSupportedChannelMasks_cb _hidl_cb); + Return setSampleRate(uint32_t sampleRateHz) override; + Return getChannelMask() override; + Return setChannelMask(AudioChannelBitfield mask) override; Return getFormat() override; Return getSupportedFormats(getSupportedFormats_cb _hidl_cb) override; Return setFormat(AudioFormat format) override; @@ -70,16 +74,30 @@ struct StreamIn : public IStreamIn { Return addEffect(uint64_t effectId) override; Return removeEffect(uint64_t effectId) override; Return standby() override; +#ifdef AUDIO_HAL_VERSION_2_0 Return getDevice() override; Return setDevice(const DeviceAddress& address) override; - Return setConnectedState(const DeviceAddress& address, bool connected) override; - Return setHwAvSync(uint32_t hwAvSync) override; Return getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) override; Return setParameters(const hidl_vec& parameters) override; - Return debugDump(const hidl_handle& fd) override; + Return setConnectedState(const DeviceAddress& address, bool connected) override; +#elif defined(AUDIO_HAL_VERSION_4_0) + Return getDevices(getDevices_cb _hidl_cb) override; + Return setDevices(const hidl_vec& devices) override; + Return getParameters(const hidl_vec& context, + const hidl_vec& keys, + getParameters_cb _hidl_cb) override; + Return setParameters(const hidl_vec& context, + const hidl_vec& parameters) override; +#endif + Return setHwAvSync(uint32_t hwAvSync) override; Return close() override; + Return debug(const hidl_handle& fd, const hidl_vec& options) override; +#ifdef AUDIO_HAL_VERSION_2_0 + Return debugDump(const hidl_handle& fd) override; +#endif + // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn follow. Return getAudioSource(getAudioSource_cb _hidl_cb) override; Return setGain(float gain) override; @@ -91,6 +109,10 @@ struct StreamIn : public IStreamIn { Return stop() override; Return createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override; Return getMmapPosition(getMmapPosition_cb _hidl_cb) override; +#ifdef AUDIO_HAL_VERSION_4_0 + Return updateSinkMetadata(const SinkMetadata& sinkMetadata) override; + Return getActiveMicrophones(getActiveMicrophones_cb _hidl_cb) override; +#endif static Result getCapturePositionImpl(audio_stream_in_t* stream, uint64_t* frames, uint64_t* time); diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h index abee225dc7..dcd3df19e6 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h @@ -179,23 +179,33 @@ Return StreamIn::getSampleRate() { return mStreamCommon->getSampleRate(); } +#ifdef AUDIO_HAL_VERSION_2_0 +Return StreamIn::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { + return mStreamCommon->getSupportedChannelMasks(_hidl_cb); +} Return StreamIn::getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) { return mStreamCommon->getSupportedSampleRates(_hidl_cb); } +#endif + +Return StreamIn::getSupportedChannelMasks(AudioFormat format, + getSupportedChannelMasks_cb _hidl_cb) { + return mStreamCommon->getSupportedChannelMasks(format, _hidl_cb); +} +Return StreamIn::getSupportedSampleRates(AudioFormat format, + getSupportedSampleRates_cb _hidl_cb) { + return mStreamCommon->getSupportedSampleRates(format, _hidl_cb); +} Return StreamIn::setSampleRate(uint32_t sampleRateHz) { return mStreamCommon->setSampleRate(sampleRateHz); } -Return StreamIn::getChannelMask() { +Return StreamIn::getChannelMask() { return mStreamCommon->getChannelMask(); } -Return StreamIn::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { - return mStreamCommon->getSupportedChannelMasks(_hidl_cb); -} - -Return StreamIn::setChannelMask(AudioChannelMask mask) { +Return StreamIn::setChannelMask(AudioChannelBitfield mask) { return mStreamCommon->setChannelMask(mask); } @@ -227,6 +237,15 @@ Return StreamIn::standby() { return mStreamCommon->standby(); } +Return StreamIn::setHwAvSync(uint32_t hwAvSync) { + return mStreamCommon->setHwAvSync(hwAvSync); +} + +#ifdef AUDIO_HAL_VERSION_2_0 +Return StreamIn::setConnectedState(const DeviceAddress& address, bool connected) { + return mStreamCommon->setConnectedState(address, connected); +} + Return StreamIn::getDevice() { return mStreamCommon->getDevice(); } @@ -235,14 +254,6 @@ Return StreamIn::setDevice(const DeviceAddress& address) { return mStreamCommon->setDevice(address); } -Return StreamIn::setConnectedState(const DeviceAddress& address, bool connected) { - return mStreamCommon->setConnectedState(address, connected); -} - -Return StreamIn::setHwAvSync(uint32_t hwAvSync) { - return mStreamCommon->setHwAvSync(hwAvSync); -} - Return StreamIn::getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) { return mStreamCommon->getParameters(keys, _hidl_cb); } @@ -254,6 +265,24 @@ Return StreamIn::setParameters(const hidl_vec& parameter Return StreamIn::debugDump(const hidl_handle& fd) { return mStreamCommon->debugDump(fd); } +#elif defined(AUDIO_HAL_VERSION_4_0) +Return StreamIn::getDevices(getDevices_cb _hidl_cb) { + return mStreamCommon->getDevices(_hidl_cb); +} + +Return StreamIn::setDevices(const hidl_vec& devices) { + return mStreamCommon->setDevices(devices); +} +Return StreamIn::getParameters(const hidl_vec& context, + const hidl_vec& keys, getParameters_cb _hidl_cb) { + return mStreamCommon->getParameters(context, keys, _hidl_cb); +} + +Return StreamIn::setParameters(const hidl_vec& context, + const hidl_vec& parameters) { + return mStreamCommon->setParameters(context, parameters); +} +#endif Return StreamIn::start() { return mStreamMmap->start(); @@ -415,6 +444,21 @@ Return StreamIn::getCapturePosition(getCapturePosition_cb _hidl_cb) { return Void(); } +Return StreamIn::debug(const hidl_handle& fd, const hidl_vec& options) { + return mStreamCommon->debug(fd, options); +} + +#ifdef AUDIO_HAL_VERSION_4_0 +Return StreamIn::updateSinkMetadata(const SinkMetadata& /*sinkMetadata*/) { + return Void(); // TODO: propagate to legacy +} + +Return StreamIn::getActiveMicrophones(getActiveMicrophones_cb _hidl_cb) { + _hidl_cb(Result::NOT_SUPPORTED, {}); // TODO: retrieve from legacy + return Void(); +} +#endif + } // namespace implementation } // namespace AUDIO_HAL_VERSION } // namespace audio diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h b/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h index 4cfe2e33f1..134d7b9bbe 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h @@ -60,11 +60,15 @@ struct StreamOut : public IStreamOut { Return getFrameCount() override; Return getBufferSize() override; Return getSampleRate() override; +#ifdef AUDIO_HAL_VERSION_2_0 Return getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override; - Return setSampleRate(uint32_t sampleRateHz) override; - Return getChannelMask() override; Return getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override; - Return setChannelMask(AudioChannelMask mask) override; +#endif + Return getSupportedSampleRates(AudioFormat format, getSupportedSampleRates_cb _hidl_cb); + Return getSupportedChannelMasks(AudioFormat format, getSupportedChannelMasks_cb _hidl_cb); + Return setSampleRate(uint32_t sampleRateHz) override; + Return getChannelMask() override; + Return setChannelMask(AudioChannelBitfield mask) override; Return getFormat() override; Return getSupportedFormats(getSupportedFormats_cb _hidl_cb) override; Return setFormat(AudioFormat format) override; @@ -72,16 +76,30 @@ struct StreamOut : public IStreamOut { Return addEffect(uint64_t effectId) override; Return removeEffect(uint64_t effectId) override; Return standby() override; +#ifdef AUDIO_HAL_VERSION_2_0 Return getDevice() override; Return setDevice(const DeviceAddress& address) override; - Return setConnectedState(const DeviceAddress& address, bool connected) override; - Return setHwAvSync(uint32_t hwAvSync) override; Return getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) override; Return setParameters(const hidl_vec& parameters) override; - Return debugDump(const hidl_handle& fd) override; + Return setConnectedState(const DeviceAddress& address, bool connected) override; +#elif defined(AUDIO_HAL_VERSION_4_0) + Return getDevices(getDevices_cb _hidl_cb) override; + Return setDevices(const hidl_vec& devices) override; + Return getParameters(const hidl_vec& context, + const hidl_vec& keys, + getParameters_cb _hidl_cb) override; + Return setParameters(const hidl_vec& context, + const hidl_vec& parameters) override; +#endif + Return setHwAvSync(uint32_t hwAvSync) override; Return close() override; + Return debug(const hidl_handle& fd, const hidl_vec& options) override; +#ifdef AUDIO_HAL_VERSION_2_0 + Return debugDump(const hidl_handle& fd) override; +#endif + // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut follow. Return getLatency() override; Return setVolume(float left, float right) override; @@ -102,6 +120,10 @@ struct StreamOut : public IStreamOut { Return stop() override; Return createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override; Return getMmapPosition(getMmapPosition_cb _hidl_cb) override; +#ifdef AUDIO_HAL_VERSION_4_0 + Return updateSourceMetadata(const SourceMetadata& sourceMetadata) override; + Return selectPresentation(int32_t presentationId, int32_t programId) override; +#endif static Result getPresentationPositionImpl(audio_stream_out_t* stream, uint64_t* frames, TimeSpec* timeStamp); diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h index bdbeb38288..605b824196 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h @@ -183,23 +183,33 @@ Return StreamOut::getSampleRate() { return mStreamCommon->getSampleRate(); } +#ifdef AUDIO_HAL_VERSION_2_0 +Return StreamOut::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { + return mStreamCommon->getSupportedChannelMasks(_hidl_cb); +} Return StreamOut::getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) { return mStreamCommon->getSupportedSampleRates(_hidl_cb); } +#endif + +Return StreamOut::getSupportedChannelMasks(AudioFormat format, + getSupportedChannelMasks_cb _hidl_cb) { + return mStreamCommon->getSupportedChannelMasks(format, _hidl_cb); +} +Return StreamOut::getSupportedSampleRates(AudioFormat format, + getSupportedSampleRates_cb _hidl_cb) { + return mStreamCommon->getSupportedSampleRates(format, _hidl_cb); +} Return StreamOut::setSampleRate(uint32_t sampleRateHz) { return mStreamCommon->setSampleRate(sampleRateHz); } -Return StreamOut::getChannelMask() { +Return StreamOut::getChannelMask() { return mStreamCommon->getChannelMask(); } -Return StreamOut::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { - return mStreamCommon->getSupportedChannelMasks(_hidl_cb); -} - -Return StreamOut::setChannelMask(AudioChannelMask mask) { +Return StreamOut::setChannelMask(AudioChannelBitfield mask) { return mStreamCommon->setChannelMask(mask); } @@ -231,6 +241,15 @@ Return StreamOut::standby() { return mStreamCommon->standby(); } +Return StreamOut::setHwAvSync(uint32_t hwAvSync) { + return mStreamCommon->setHwAvSync(hwAvSync); +} + +#ifdef AUDIO_HAL_VERSION_2_0 +Return StreamOut::setConnectedState(const DeviceAddress& address, bool connected) { + return mStreamCommon->setConnectedState(address, connected); +} + Return StreamOut::getDevice() { return mStreamCommon->getDevice(); } @@ -239,14 +258,6 @@ Return StreamOut::setDevice(const DeviceAddress& address) { return mStreamCommon->setDevice(address); } -Return StreamOut::setConnectedState(const DeviceAddress& address, bool connected) { - return mStreamCommon->setConnectedState(address, connected); -} - -Return StreamOut::setHwAvSync(uint32_t hwAvSync) { - return mStreamCommon->setHwAvSync(hwAvSync); -} - Return StreamOut::getParameters(const hidl_vec& keys, getParameters_cb _hidl_cb) { return mStreamCommon->getParameters(keys, _hidl_cb); @@ -259,6 +270,25 @@ Return StreamOut::setParameters(const hidl_vec& paramete Return StreamOut::debugDump(const hidl_handle& fd) { return mStreamCommon->debugDump(fd); } +#elif defined(AUDIO_HAL_VERSION_4_0) +Return StreamOut::getDevices(getDevices_cb _hidl_cb) { + return mStreamCommon->getDevices(_hidl_cb); +} + +Return StreamOut::setDevices(const hidl_vec& devices) { + return mStreamCommon->setDevices(devices); +} +Return StreamOut::getParameters(const hidl_vec& context, + const hidl_vec& keys, + getParameters_cb _hidl_cb) { + return mStreamCommon->getParameters(context, keys, _hidl_cb); +} + +Return StreamOut::setParameters(const hidl_vec& context, + const hidl_vec& parameters) { + return mStreamCommon->setParameters(context, parameters); +} +#endif Return StreamOut::close() { if (mIsClosed) return Result::INVALID_STATE; @@ -512,6 +542,19 @@ Return StreamOut::getMmapPosition(getMmapPosition_cb _hidl_cb) { return mStreamMmap->getMmapPosition(_hidl_cb); } +Return StreamOut::debug(const hidl_handle& fd, const hidl_vec& options) { + return mStreamCommon->debug(fd, options); +} + +#ifdef AUDIO_HAL_VERSION_4_0 +Return StreamOut::updateSourceMetadata(const SourceMetadata& /*sourceMetadata*/) { + return Void(); // TODO: propagate to legacy +} +Return StreamOut::selectPresentation(int32_t /*presentationId*/, int32_t /*programId*/) { + return Result::NOT_SUPPORTED; // TODO: propagate to legacy +} +#endif + } // namespace implementation } // namespace AUDIO_HAL_VERSION } // namespace audio From bee7f4eb1e74c0ca0cff2c745c13935d9e77a9e5 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Thu, 1 Mar 2018 18:56:58 -0800 Subject: [PATCH 12/12] Audio V4: Declare support for 4.0 interface Declare that the audio HAL service supports 4.0 as well as 2.0 interface. Formatting done by clang-format. Test: compile Bug: 38184704 Change-Id: Iee842b141e1218f4f3779187339bde40680ec78a Merged-In: Iee842b141e1218f4f3779187339bde40680ec78a Cherry-picked from master Signed-off-by: Kevin Rocard --- .../all-versions/default/service/Android.mk | 3 ++ .../all-versions/default/service/service.cpp | 37 ++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/audio/common/all-versions/default/service/Android.mk b/audio/common/all-versions/default/service/Android.mk index edf1761b7f..f502dfd430 100644 --- a/audio/common/all-versions/default/service/Android.mk +++ b/audio/common/all-versions/default/service/Android.mk @@ -38,8 +38,11 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libhardware \ android.hardware.audio@2.0 \ + android.hardware.audio@4.0 \ android.hardware.audio.common@2.0 \ + android.hardware.audio.common@4.0 \ android.hardware.audio.effect@2.0 \ + android.hardware.audio.effect@4.0 \ android.hardware.soundtrigger@2.0 \ android.hardware.soundtrigger@2.1 diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp index d554481291..f6e4353598 100644 --- a/audio/common/all-versions/default/service/service.cpp +++ b/audio/common/all-versions/default/service/service.cpp @@ -17,23 +17,16 @@ #define LOG_TAG "audiohalservice" #include +#include #include +#include #include #include #include #include #include -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::hardware::registerPassthroughServiceImplementation; - -using android::hardware::audio::effect::V2_0::IEffectsFactory; -using android::hardware::audio::V2_0::IDevicesFactory; -using V2_0_ISoundTriggerHw = android::hardware::soundtrigger::V2_0::ISoundTriggerHw; -using V2_1_ISoundTriggerHw = android::hardware::soundtrigger::V2_1::ISoundTriggerHw; -using android::hardware::registerPassthroughServiceImplementation; - +using namespace android::hardware; using android::OK; int main(int /* argc */, char* /* argv */ []) { @@ -41,16 +34,18 @@ int main(int /* argc */, char* /* argv */ []) { // start a threadpool for vndbinder interactions android::ProcessState::self()->startThreadPool(); configureRpcThreadpool(16, true /*callerWillJoin*/); - android::status_t status; - status = registerPassthroughServiceImplementation(); - LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status); - status = registerPassthroughServiceImplementation(); - LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status); - // Soundtrigger might be not present. - status = registerPassthroughServiceImplementation(); - ALOGW_IF(status != OK, "Registering soundtrigger V2.1 service was unsuccessful: %d", status); - status = registerPassthroughServiceImplementation(); - ALOGW_IF(status != OK, "Registering soundtrigger V2.0 service was unsuccessful: %d", status); + + bool fail = registerPassthroughServiceImplementation() != OK && + registerPassthroughServiceImplementation() != OK; + LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0"); + + fail = registerPassthroughServiceImplementation() != OK && + registerPassthroughServiceImplementation() != OK, + LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0"); + + fail = registerPassthroughServiceImplementation() != OK && + registerPassthroughServiceImplementation() != OK, + ALOGW_IF(fail, "Could not register soundtrigger API 2.0 nor 2.1"); + joinRpcThreadpool(); - return status; }