From 649142becc2e03ba09490cad133740cc1271ed84 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Wed, 13 Dec 2017 18:58:39 -0800 Subject: Audio V4: Move common files before refactor This will make diff much more clear and allow git to follow the files. Bug: 38184704 Test: compile Change-Id: I41ccb41c334aa56d3935be333e6227dd99773766 Signed-off-by: Kevin Rocard --- audio/README | 47 ++++ audio/common/2.0/default/Android.bp | 41 --- audio/common/2.0/default/EffectMap.cpp | 57 ---- audio/common/2.0/default/EffectMap.h | 46 ---- audio/common/2.0/default/HidlUtils.cpp | 336 ------------------------ audio/common/2.0/default/HidlUtils.h | 67 ----- audio/common/2.0/default/OWNERS | 3 - audio/common/README | 1 + audio/common/all-versions/README | 1 + audio/common/all-versions/default/Android.bp | 41 +++ audio/common/all-versions/default/EffectMap.cpp | 57 ++++ audio/common/all-versions/default/EffectMap.h | 46 ++++ audio/common/all-versions/default/HidlUtils.cpp | 336 ++++++++++++++++++++++++ audio/common/all-versions/default/HidlUtils.h | 67 +++++ audio/common/all-versions/default/OWNERS | 3 + 15 files changed, 599 insertions(+), 550 deletions(-) create mode 100644 audio/README delete mode 100644 audio/common/2.0/default/Android.bp delete mode 100644 audio/common/2.0/default/EffectMap.cpp delete mode 100644 audio/common/2.0/default/EffectMap.h delete mode 100644 audio/common/2.0/default/HidlUtils.cpp delete mode 100644 audio/common/2.0/default/HidlUtils.h delete mode 100644 audio/common/2.0/default/OWNERS create mode 100644 audio/common/README create mode 100644 audio/common/all-versions/README create mode 100644 audio/common/all-versions/default/Android.bp create mode 100644 audio/common/all-versions/default/EffectMap.cpp create mode 100644 audio/common/all-versions/default/EffectMap.h create mode 100644 audio/common/all-versions/default/HidlUtils.cpp create mode 100644 audio/common/all-versions/default/HidlUtils.h create mode 100644 audio/common/all-versions/default/OWNERS (limited to 'audio') diff --git a/audio/README b/audio/README new file mode 100644 index 000000000..b40bad094 --- /dev/null +++ b/audio/README @@ -0,0 +1,47 @@ +Directory structure of the audio HIDL related code. + +audio +|-- 2.0 <== legacy 2.0 device HIDL (.hal) can not be moved to fit +| the directory structure because already published +| +|-- common <== code common to audio device and effect API +| |-- 2.0 +| | |-- default <== code that wraps the legacy API +| | `-- vts <== vts of 2.0 device and effect API common code +| |-- 4.0 +| | |-- default +| | `-- vts +| |-- ... <== The future versions should continue this structure +| | |-- default +| | `-- vts +| `-- all_versions <== code common to all version of both device and effect API +| |-- default +| `-- vts <== vts of device and effect API common version independent code +| +|-- device <== code relative to the device API +| |-- 2.0 <== 2.0 device API code (except .hal, see audio/2.0) +| | |-- default +| | `-- vts +| |-- 4.0 +| | |-- default <== default implementation of the device 4.0 api +| | `-- vts <== vts code of the 4.0 API +| |-- ... +| | |-- default +| | `-- vts +| `-- all_versions +| |-- default +| `-- vts <== vts of device API common version independent code +| +`-- effect <== idem for the effect API + |-- 2.0 + | |-- default + | `-- vts + |-- 4.0 + | |-- default + | `-- vts + |-- ... + | |-- default + | `-- vts + `-- all_versions + |-- default + `-- vts diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp deleted file mode 100644 index 82b38c087..000000000 --- a/audio/common/2.0/default/Android.bp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (C) 2016 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@2.0-util", - defaults: ["hidl_defaults"], - vendor_available: true, - vndk: { - enabled: true, - }, - srcs: [ - "EffectMap.cpp", - "HidlUtils.cpp", - ], - - export_include_dirs: ["."], - - shared_libs: [ - "liblog", - "libutils", - "libhidlbase", - "android.hardware.audio.common@2.0", - ], - - header_libs: [ - "libaudio_system_headers", - "libhardware_headers", - ], -} diff --git a/audio/common/2.0/default/EffectMap.cpp b/audio/common/2.0/default/EffectMap.cpp deleted file mode 100644 index 703b91cfe..000000000 --- a/audio/common/2.0/default/EffectMap.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2016 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 - -#include "EffectMap.h" - -namespace android { - -ANDROID_SINGLETON_STATIC_INSTANCE(EffectMap); - -// static -const uint64_t EffectMap::INVALID_ID = 0; - -// static -uint64_t EffectMap::makeUniqueId() { - static std::atomic counter{INVALID_ID + 1}; - return counter++; -} - -uint64_t EffectMap::add(effect_handle_t handle) { - uint64_t newId = makeUniqueId(); - std::lock_guard lock(mLock); - mEffects.add(newId, handle); - return newId; -} - -effect_handle_t EffectMap::get(const uint64_t& id) { - std::lock_guard lock(mLock); - ssize_t idx = mEffects.indexOfKey(id); - return idx >= 0 ? mEffects[idx] : NULL; -} - -void EffectMap::remove(effect_handle_t handle) { - std::lock_guard lock(mLock); - for (size_t i = 0; i < mEffects.size(); ++i) { - if (mEffects[i] == handle) { - mEffects.removeItemsAt(i); - break; - } - } -} - -} // namespace android diff --git a/audio/common/2.0/default/EffectMap.h b/audio/common/2.0/default/EffectMap.h deleted file mode 100644 index 355b63528..000000000 --- a/audio/common/2.0/default/EffectMap.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2016 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_V2_0_EffectMap_H_ -#define android_hardware_audio_V2_0_EffectMap_H_ - -#include - -#include -#include -#include - -namespace android { - -// This class needs to be in 'android' ns because Singleton macros require that. -class EffectMap : public Singleton { - public: - static const uint64_t INVALID_ID; - - uint64_t add(effect_handle_t handle); - effect_handle_t get(const uint64_t& id); - void remove(effect_handle_t handle); - - private: - static uint64_t makeUniqueId(); - - std::mutex mLock; - KeyedVector mEffects; -}; - -} // namespace android - -#endif // android_hardware_audio_V2_0_EffectMap_H_ diff --git a/audio/common/2.0/default/HidlUtils.cpp b/audio/common/2.0/default/HidlUtils.cpp deleted file mode 100644 index a74fb8940..000000000 --- a/audio/common/2.0/default/HidlUtils.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright (C) 2016 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 - -#include "HidlUtils.h" - -using ::android::hardware::audio::common::V2_0::AudioChannelMask; -using ::android::hardware::audio::common::V2_0::AudioDevice; -using ::android::hardware::audio::common::V2_0::AudioFormat; -using ::android::hardware::audio::common::V2_0::AudioGainMode; -using ::android::hardware::audio::common::V2_0::AudioMixLatencyClass; -using ::android::hardware::audio::common::V2_0::AudioPortConfigMask; -using ::android::hardware::audio::common::V2_0::AudioPortRole; -using ::android::hardware::audio::common::V2_0::AudioPortType; -using ::android::hardware::audio::common::V2_0::AudioSource; -using ::android::hardware::audio::common::V2_0::AudioStreamType; -using ::android::hardware::audio::common::V2_0::AudioUsage; - -namespace android { - -void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) { - config->sampleRateHz = halConfig.sample_rate; - config->channelMask = AudioChannelMask(halConfig.channel_mask); - config->format = AudioFormat(halConfig.format); - audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo); - config->frameCount = halConfig.frame_count; -} - -void HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig) { - memset(halConfig, 0, sizeof(audio_config_t)); - halConfig->sample_rate = config.sampleRateHz; - halConfig->channel_mask = static_cast(config.channelMask); - halConfig->format = static_cast(config.format); - audioOffloadInfoToHal(config.offloadInfo, &halConfig->offload_info); - halConfig->frame_count = config.frameCount; -} - -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); - for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) { - config->values[i] = halConfig.values[i]; - } - config->rampDurationMs = halConfig.ramp_duration_ms; -} - -void HidlUtils::audioGainConfigToHal(const AudioGainConfig& config, - struct audio_gain_config* halConfig) { - halConfig->index = config.index; - halConfig->mode = static_cast(config.mode); - halConfig->channel_mask = static_cast(config.channelMask); - memset(halConfig->values, 0, sizeof(halConfig->values)); - for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) { - halConfig->values[i] = config.values[i]; - } - halConfig->ramp_duration_ms = config.rampDurationMs; -} - -void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) { - gain->mode = AudioGainMode(halGain.mode); - gain->channelMask = AudioChannelMask(halGain.channel_mask); - gain->minValue = halGain.min_value; - gain->maxValue = halGain.max_value; - gain->defaultValue = halGain.default_value; - gain->stepValue = halGain.step_value; - gain->minRampMs = halGain.min_ramp_ms; - gain->maxRampMs = halGain.max_ramp_ms; -} - -void HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) { - halGain->mode = static_cast(gain.mode); - halGain->channel_mask = static_cast(gain.channelMask); - halGain->min_value = gain.minValue; - halGain->max_value = gain.maxValue; - halGain->default_value = gain.defaultValue; - halGain->step_value = gain.stepValue; - halGain->min_ramp_ms = gain.minRampMs; - halGain->max_ramp_ms = gain.maxRampMs; -} - -void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, - AudioOffloadInfo* offload) { - offload->sampleRateHz = halOffload.sample_rate; - offload->channelMask = AudioChannelMask(halOffload.channel_mask); - offload->format = AudioFormat(halOffload.format); - offload->streamType = AudioStreamType(halOffload.stream_type); - offload->bitRatePerSecond = halOffload.bit_rate; - offload->durationMicroseconds = halOffload.duration_us; - offload->hasVideo = halOffload.has_video; - offload->isStreaming = halOffload.is_streaming; - offload->bitWidth = halOffload.bit_width; - offload->bufferSize = halOffload.offload_buffer_size; - offload->usage = static_cast(halOffload.usage); -} - -void HidlUtils::audioOffloadInfoToHal(const AudioOffloadInfo& offload, - audio_offload_info_t* halOffload) { - *halOffload = AUDIO_INFO_INITIALIZER; - halOffload->sample_rate = offload.sampleRateHz; - halOffload->channel_mask = static_cast(offload.channelMask); - halOffload->format = static_cast(offload.format); - halOffload->stream_type = static_cast(offload.streamType); - halOffload->bit_rate = offload.bitRatePerSecond; - halOffload->duration_us = offload.durationMicroseconds; - halOffload->has_video = offload.hasVideo; - halOffload->is_streaming = offload.isStreaming; - halOffload->bit_width = offload.bitWidth; - halOffload->offload_buffer_size = offload.bufferSize; - halOffload->usage = static_cast(offload.usage); -} - -void HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halConfig, - AudioPortConfig* config) { - config->id = halConfig.id; - config->role = AudioPortRole(halConfig.role); - config->type = AudioPortType(halConfig.type); - config->configMask = AudioPortConfigMask(halConfig.config_mask); - config->sampleRateHz = halConfig.sample_rate; - config->channelMask = AudioChannelMask(halConfig.channel_mask); - config->format = AudioFormat(halConfig.format); - audioGainConfigFromHal(halConfig.gain, &config->gain); - switch (halConfig.type) { - case AUDIO_PORT_TYPE_NONE: - break; - case AUDIO_PORT_TYPE_DEVICE: { - config->ext.device.hwModule = halConfig.ext.device.hw_module; - config->ext.device.type = AudioDevice(halConfig.ext.device.type); - memcpy(config->ext.device.address.data(), halConfig.ext.device.address, - AUDIO_DEVICE_MAX_ADDRESS_LEN); - break; - } - case AUDIO_PORT_TYPE_MIX: { - config->ext.mix.hwModule = halConfig.ext.mix.hw_module; - config->ext.mix.ioHandle = halConfig.ext.mix.handle; - if (halConfig.role == AUDIO_PORT_ROLE_SOURCE) { - config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source); - } else if (halConfig.role == AUDIO_PORT_ROLE_SINK) { - config->ext.mix.useCase.stream = AudioStreamType(halConfig.ext.mix.usecase.stream); - } - break; - } - case AUDIO_PORT_TYPE_SESSION: { - config->ext.session.session = halConfig.ext.session.session; - break; - } - } -} - -void HidlUtils::audioPortConfigToHal(const AudioPortConfig& config, - struct audio_port_config* halConfig) { - memset(halConfig, 0, sizeof(audio_port_config)); - halConfig->id = config.id; - halConfig->role = static_cast(config.role); - halConfig->type = static_cast(config.type); - halConfig->config_mask = static_cast(config.configMask); - halConfig->sample_rate = config.sampleRateHz; - halConfig->channel_mask = static_cast(config.channelMask); - halConfig->format = static_cast(config.format); - audioGainConfigToHal(config.gain, &halConfig->gain); - switch (config.type) { - case AudioPortType::NONE: - break; - case AudioPortType::DEVICE: { - halConfig->ext.device.hw_module = config.ext.device.hwModule; - halConfig->ext.device.type = static_cast(config.ext.device.type); - memcpy(halConfig->ext.device.address, config.ext.device.address.data(), - AUDIO_DEVICE_MAX_ADDRESS_LEN); - break; - } - case AudioPortType::MIX: { - halConfig->ext.mix.hw_module = config.ext.mix.hwModule; - halConfig->ext.mix.handle = config.ext.mix.ioHandle; - if (config.role == AudioPortRole::SOURCE) { - halConfig->ext.mix.usecase.source = - static_cast(config.ext.mix.useCase.source); - } else if (config.role == AudioPortRole::SINK) { - halConfig->ext.mix.usecase.stream = - static_cast(config.ext.mix.useCase.stream); - } - break; - } - case AudioPortType::SESSION: { - halConfig->ext.session.session = - static_cast(config.ext.session.session); - break; - } - } -} - -void HidlUtils::audioPortConfigsFromHal(unsigned int numHalConfigs, - const struct audio_port_config* halConfigs, - hidl_vec* configs) { - configs->resize(numHalConfigs); - for (unsigned int i = 0; i < numHalConfigs; ++i) { - audioPortConfigFromHal(halConfigs[i], &(*configs)[i]); - } -} - -std::unique_ptr HidlUtils::audioPortConfigsToHal( - const hidl_vec& configs) { - std::unique_ptr halConfigs(new audio_port_config[configs.size()]); - for (size_t i = 0; i < configs.size(); ++i) { - audioPortConfigToHal(configs[i], &halConfigs[i]); - } - return halConfigs; -} - -void HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort* port) { - port->id = halPort.id; - port->role = AudioPortRole(halPort.role); - port->type = AudioPortType(halPort.type); - port->name.setToExternal(halPort.name, strlen(halPort.name)); - port->sampleRates.resize(halPort.num_sample_rates); - for (size_t i = 0; i < halPort.num_sample_rates; ++i) { - port->sampleRates[i] = halPort.sample_rates[i]; - } - 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->formats.resize(halPort.num_formats); - for (size_t i = 0; i < halPort.num_formats; ++i) { - port->formats[i] = AudioFormat(halPort.formats[i]); - } - port->gains.resize(halPort.num_gains); - for (size_t i = 0; i < halPort.num_gains; ++i) { - audioGainFromHal(halPort.gains[i], &port->gains[i]); - } - audioPortConfigFromHal(halPort.active_config, &port->activeConfig); - switch (halPort.type) { - case AUDIO_PORT_TYPE_NONE: - break; - case AUDIO_PORT_TYPE_DEVICE: { - port->ext.device.hwModule = halPort.ext.device.hw_module; - port->ext.device.type = AudioDevice(halPort.ext.device.type); - memcpy(port->ext.device.address.data(), halPort.ext.device.address, - AUDIO_DEVICE_MAX_ADDRESS_LEN); - break; - } - case AUDIO_PORT_TYPE_MIX: { - port->ext.mix.hwModule = halPort.ext.mix.hw_module; - port->ext.mix.ioHandle = halPort.ext.mix.handle; - port->ext.mix.latencyClass = AudioMixLatencyClass(halPort.ext.mix.latency_class); - break; - } - case AUDIO_PORT_TYPE_SESSION: { - port->ext.session.session = halPort.ext.session.session; - break; - } - } -} - -void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort) { - memset(halPort, 0, sizeof(audio_port)); - 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))); - 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) { - halPort->sample_rates[i] = port.sampleRates[i]; - } - halPort->num_channel_masks = - std::min(port.channelMasks.size(), static_cast(AUDIO_PORT_MAX_CHANNEL_MASKS)); - for (size_t i = 0; i < halPort->num_channel_masks; ++i) { - halPort->channel_masks[i] = static_cast(port.channelMasks[i]); - } - halPort->num_formats = - std::min(port.formats.size(), static_cast(AUDIO_PORT_MAX_FORMATS)); - for (size_t i = 0; i < halPort->num_formats; ++i) { - halPort->formats[i] = static_cast(port.formats[i]); - } - halPort->num_gains = std::min(port.gains.size(), static_cast(AUDIO_PORT_MAX_GAINS)); - for (size_t i = 0; i < halPort->num_gains; ++i) { - audioGainToHal(port.gains[i], &halPort->gains[i]); - } - audioPortConfigToHal(port.activeConfig, &halPort->active_config); - switch (port.type) { - case AudioPortType::NONE: - break; - case AudioPortType::DEVICE: { - halPort->ext.device.hw_module = port.ext.device.hwModule; - halPort->ext.device.type = static_cast(port.ext.device.type); - memcpy(halPort->ext.device.address, port.ext.device.address.data(), - AUDIO_DEVICE_MAX_ADDRESS_LEN); - break; - } - case AudioPortType::MIX: { - halPort->ext.mix.hw_module = port.ext.mix.hwModule; - halPort->ext.mix.handle = port.ext.mix.ioHandle; - halPort->ext.mix.latency_class = - static_cast(port.ext.mix.latencyClass); - break; - } - case AudioPortType::SESSION: { - halPort->ext.session.session = static_cast(port.ext.session.session); - break; - } - } -} - -void HidlUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) { - uuid->timeLow = halUuid.timeLow; - uuid->timeMid = halUuid.timeMid; - uuid->versionAndTimeHigh = halUuid.timeHiAndVersion; - uuid->variantAndClockSeqHigh = halUuid.clockSeq; - memcpy(uuid->node.data(), halUuid.node, uuid->node.size()); -} - -void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) { - halUuid->timeLow = uuid.timeLow; - halUuid->timeMid = uuid.timeMid; - halUuid->timeHiAndVersion = uuid.versionAndTimeHigh; - halUuid->clockSeq = uuid.variantAndClockSeqHigh; - memcpy(halUuid->node, uuid.node.data(), uuid.node.size()); -} - -} // namespace android diff --git a/audio/common/2.0/default/HidlUtils.h b/audio/common/2.0/default/HidlUtils.h deleted file mode 100644 index 09ed288fe..000000000 --- a/audio/common/2.0/default/HidlUtils.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2016 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_V2_0_Hidl_Utils_H_ -#define android_hardware_audio_V2_0_Hidl_Utils_H_ - -#include - -#include -#include - -using ::android::hardware::audio::common::V2_0::AudioConfig; -using ::android::hardware::audio::common::V2_0::AudioGain; -using ::android::hardware::audio::common::V2_0::AudioGainConfig; -using ::android::hardware::audio::common::V2_0::AudioOffloadInfo; -using ::android::hardware::audio::common::V2_0::AudioPort; -using ::android::hardware::audio::common::V2_0::AudioPortConfig; -using ::android::hardware::audio::common::V2_0::Uuid; -using ::android::hardware::hidl_vec; - -namespace android { - -class HidlUtils { - public: - static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config); - static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig); - static void audioGainConfigFromHal(const struct audio_gain_config& halConfig, - AudioGainConfig* config); - static void audioGainConfigToHal(const AudioGainConfig& config, - 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 void audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, - AudioOffloadInfo* offload); - static void audioOffloadInfoToHal(const AudioOffloadInfo& offload, - audio_offload_info_t* halOffload); - static void audioPortConfigFromHal(const struct audio_port_config& halConfig, - AudioPortConfig* config); - static void audioPortConfigToHal(const AudioPortConfig& config, - struct audio_port_config* halConfig); - static void audioPortConfigsFromHal(unsigned int numHalConfigs, - const struct audio_port_config* halConfigs, - hidl_vec* configs); - static std::unique_ptr audioPortConfigsToHal( - const hidl_vec& configs); - static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port); - static void audioPortToHal(const AudioPort& port, struct audio_port* halPort); - static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid); - static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid); -}; - -} // namespace android - -#endif // android_hardware_audio_V2_0_Hidl_Utils_H_ diff --git a/audio/common/2.0/default/OWNERS b/audio/common/2.0/default/OWNERS deleted file mode 100644 index 6fdc97ca2..000000000 --- a/audio/common/2.0/default/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com diff --git a/audio/common/README b/audio/common/README new file mode 100644 index 000000000..88cea46da --- /dev/null +++ b/audio/common/README @@ -0,0 +1 @@ +This folder contains code common to audio device and effect API diff --git a/audio/common/all-versions/README b/audio/common/all-versions/README new file mode 100644 index 000000000..d8df02290 --- /dev/null +++ b/audio/common/all-versions/README @@ -0,0 +1 @@ +This folder contains code common to all versions of the audio API diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp new file mode 100644 index 000000000..82b38c087 --- /dev/null +++ b/audio/common/all-versions/default/Android.bp @@ -0,0 +1,41 @@ +// +// Copyright (C) 2016 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@2.0-util", + defaults: ["hidl_defaults"], + vendor_available: true, + vndk: { + enabled: true, + }, + srcs: [ + "EffectMap.cpp", + "HidlUtils.cpp", + ], + + export_include_dirs: ["."], + + shared_libs: [ + "liblog", + "libutils", + "libhidlbase", + "android.hardware.audio.common@2.0", + ], + + header_libs: [ + "libaudio_system_headers", + "libhardware_headers", + ], +} diff --git a/audio/common/all-versions/default/EffectMap.cpp b/audio/common/all-versions/default/EffectMap.cpp new file mode 100644 index 000000000..703b91cfe --- /dev/null +++ b/audio/common/all-versions/default/EffectMap.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2016 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 + +#include "EffectMap.h" + +namespace android { + +ANDROID_SINGLETON_STATIC_INSTANCE(EffectMap); + +// static +const uint64_t EffectMap::INVALID_ID = 0; + +// static +uint64_t EffectMap::makeUniqueId() { + static std::atomic counter{INVALID_ID + 1}; + return counter++; +} + +uint64_t EffectMap::add(effect_handle_t handle) { + uint64_t newId = makeUniqueId(); + std::lock_guard lock(mLock); + mEffects.add(newId, handle); + return newId; +} + +effect_handle_t EffectMap::get(const uint64_t& id) { + std::lock_guard lock(mLock); + ssize_t idx = mEffects.indexOfKey(id); + return idx >= 0 ? mEffects[idx] : NULL; +} + +void EffectMap::remove(effect_handle_t handle) { + std::lock_guard lock(mLock); + for (size_t i = 0; i < mEffects.size(); ++i) { + if (mEffects[i] == handle) { + mEffects.removeItemsAt(i); + break; + } + } +} + +} // namespace android diff --git a/audio/common/all-versions/default/EffectMap.h b/audio/common/all-versions/default/EffectMap.h new file mode 100644 index 000000000..355b63528 --- /dev/null +++ b/audio/common/all-versions/default/EffectMap.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2016 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_V2_0_EffectMap_H_ +#define android_hardware_audio_V2_0_EffectMap_H_ + +#include + +#include +#include +#include + +namespace android { + +// This class needs to be in 'android' ns because Singleton macros require that. +class EffectMap : public Singleton { + public: + static const uint64_t INVALID_ID; + + uint64_t add(effect_handle_t handle); + effect_handle_t get(const uint64_t& id); + void remove(effect_handle_t handle); + + private: + static uint64_t makeUniqueId(); + + std::mutex mLock; + KeyedVector mEffects; +}; + +} // namespace android + +#endif // android_hardware_audio_V2_0_EffectMap_H_ diff --git a/audio/common/all-versions/default/HidlUtils.cpp b/audio/common/all-versions/default/HidlUtils.cpp new file mode 100644 index 000000000..a74fb8940 --- /dev/null +++ b/audio/common/all-versions/default/HidlUtils.cpp @@ -0,0 +1,336 @@ +/* + * Copyright (C) 2016 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 + +#include "HidlUtils.h" + +using ::android::hardware::audio::common::V2_0::AudioChannelMask; +using ::android::hardware::audio::common::V2_0::AudioDevice; +using ::android::hardware::audio::common::V2_0::AudioFormat; +using ::android::hardware::audio::common::V2_0::AudioGainMode; +using ::android::hardware::audio::common::V2_0::AudioMixLatencyClass; +using ::android::hardware::audio::common::V2_0::AudioPortConfigMask; +using ::android::hardware::audio::common::V2_0::AudioPortRole; +using ::android::hardware::audio::common::V2_0::AudioPortType; +using ::android::hardware::audio::common::V2_0::AudioSource; +using ::android::hardware::audio::common::V2_0::AudioStreamType; +using ::android::hardware::audio::common::V2_0::AudioUsage; + +namespace android { + +void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) { + config->sampleRateHz = halConfig.sample_rate; + config->channelMask = AudioChannelMask(halConfig.channel_mask); + config->format = AudioFormat(halConfig.format); + audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo); + config->frameCount = halConfig.frame_count; +} + +void HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig) { + memset(halConfig, 0, sizeof(audio_config_t)); + halConfig->sample_rate = config.sampleRateHz; + halConfig->channel_mask = static_cast(config.channelMask); + halConfig->format = static_cast(config.format); + audioOffloadInfoToHal(config.offloadInfo, &halConfig->offload_info); + halConfig->frame_count = config.frameCount; +} + +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); + for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) { + config->values[i] = halConfig.values[i]; + } + config->rampDurationMs = halConfig.ramp_duration_ms; +} + +void HidlUtils::audioGainConfigToHal(const AudioGainConfig& config, + struct audio_gain_config* halConfig) { + halConfig->index = config.index; + halConfig->mode = static_cast(config.mode); + halConfig->channel_mask = static_cast(config.channelMask); + memset(halConfig->values, 0, sizeof(halConfig->values)); + for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) { + halConfig->values[i] = config.values[i]; + } + halConfig->ramp_duration_ms = config.rampDurationMs; +} + +void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) { + gain->mode = AudioGainMode(halGain.mode); + gain->channelMask = AudioChannelMask(halGain.channel_mask); + gain->minValue = halGain.min_value; + gain->maxValue = halGain.max_value; + gain->defaultValue = halGain.default_value; + gain->stepValue = halGain.step_value; + gain->minRampMs = halGain.min_ramp_ms; + gain->maxRampMs = halGain.max_ramp_ms; +} + +void HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) { + halGain->mode = static_cast(gain.mode); + halGain->channel_mask = static_cast(gain.channelMask); + halGain->min_value = gain.minValue; + halGain->max_value = gain.maxValue; + halGain->default_value = gain.defaultValue; + halGain->step_value = gain.stepValue; + halGain->min_ramp_ms = gain.minRampMs; + halGain->max_ramp_ms = gain.maxRampMs; +} + +void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, + AudioOffloadInfo* offload) { + offload->sampleRateHz = halOffload.sample_rate; + offload->channelMask = AudioChannelMask(halOffload.channel_mask); + offload->format = AudioFormat(halOffload.format); + offload->streamType = AudioStreamType(halOffload.stream_type); + offload->bitRatePerSecond = halOffload.bit_rate; + offload->durationMicroseconds = halOffload.duration_us; + offload->hasVideo = halOffload.has_video; + offload->isStreaming = halOffload.is_streaming; + offload->bitWidth = halOffload.bit_width; + offload->bufferSize = halOffload.offload_buffer_size; + offload->usage = static_cast(halOffload.usage); +} + +void HidlUtils::audioOffloadInfoToHal(const AudioOffloadInfo& offload, + audio_offload_info_t* halOffload) { + *halOffload = AUDIO_INFO_INITIALIZER; + halOffload->sample_rate = offload.sampleRateHz; + halOffload->channel_mask = static_cast(offload.channelMask); + halOffload->format = static_cast(offload.format); + halOffload->stream_type = static_cast(offload.streamType); + halOffload->bit_rate = offload.bitRatePerSecond; + halOffload->duration_us = offload.durationMicroseconds; + halOffload->has_video = offload.hasVideo; + halOffload->is_streaming = offload.isStreaming; + halOffload->bit_width = offload.bitWidth; + halOffload->offload_buffer_size = offload.bufferSize; + halOffload->usage = static_cast(offload.usage); +} + +void HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halConfig, + AudioPortConfig* config) { + config->id = halConfig.id; + config->role = AudioPortRole(halConfig.role); + config->type = AudioPortType(halConfig.type); + config->configMask = AudioPortConfigMask(halConfig.config_mask); + config->sampleRateHz = halConfig.sample_rate; + config->channelMask = AudioChannelMask(halConfig.channel_mask); + config->format = AudioFormat(halConfig.format); + audioGainConfigFromHal(halConfig.gain, &config->gain); + switch (halConfig.type) { + case AUDIO_PORT_TYPE_NONE: + break; + case AUDIO_PORT_TYPE_DEVICE: { + config->ext.device.hwModule = halConfig.ext.device.hw_module; + config->ext.device.type = AudioDevice(halConfig.ext.device.type); + memcpy(config->ext.device.address.data(), halConfig.ext.device.address, + AUDIO_DEVICE_MAX_ADDRESS_LEN); + break; + } + case AUDIO_PORT_TYPE_MIX: { + config->ext.mix.hwModule = halConfig.ext.mix.hw_module; + config->ext.mix.ioHandle = halConfig.ext.mix.handle; + if (halConfig.role == AUDIO_PORT_ROLE_SOURCE) { + config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source); + } else if (halConfig.role == AUDIO_PORT_ROLE_SINK) { + config->ext.mix.useCase.stream = AudioStreamType(halConfig.ext.mix.usecase.stream); + } + break; + } + case AUDIO_PORT_TYPE_SESSION: { + config->ext.session.session = halConfig.ext.session.session; + break; + } + } +} + +void HidlUtils::audioPortConfigToHal(const AudioPortConfig& config, + struct audio_port_config* halConfig) { + memset(halConfig, 0, sizeof(audio_port_config)); + halConfig->id = config.id; + halConfig->role = static_cast(config.role); + halConfig->type = static_cast(config.type); + halConfig->config_mask = static_cast(config.configMask); + halConfig->sample_rate = config.sampleRateHz; + halConfig->channel_mask = static_cast(config.channelMask); + halConfig->format = static_cast(config.format); + audioGainConfigToHal(config.gain, &halConfig->gain); + switch (config.type) { + case AudioPortType::NONE: + break; + case AudioPortType::DEVICE: { + halConfig->ext.device.hw_module = config.ext.device.hwModule; + halConfig->ext.device.type = static_cast(config.ext.device.type); + memcpy(halConfig->ext.device.address, config.ext.device.address.data(), + AUDIO_DEVICE_MAX_ADDRESS_LEN); + break; + } + case AudioPortType::MIX: { + halConfig->ext.mix.hw_module = config.ext.mix.hwModule; + halConfig->ext.mix.handle = config.ext.mix.ioHandle; + if (config.role == AudioPortRole::SOURCE) { + halConfig->ext.mix.usecase.source = + static_cast(config.ext.mix.useCase.source); + } else if (config.role == AudioPortRole::SINK) { + halConfig->ext.mix.usecase.stream = + static_cast(config.ext.mix.useCase.stream); + } + break; + } + case AudioPortType::SESSION: { + halConfig->ext.session.session = + static_cast(config.ext.session.session); + break; + } + } +} + +void HidlUtils::audioPortConfigsFromHal(unsigned int numHalConfigs, + const struct audio_port_config* halConfigs, + hidl_vec* configs) { + configs->resize(numHalConfigs); + for (unsigned int i = 0; i < numHalConfigs; ++i) { + audioPortConfigFromHal(halConfigs[i], &(*configs)[i]); + } +} + +std::unique_ptr HidlUtils::audioPortConfigsToHal( + const hidl_vec& configs) { + std::unique_ptr halConfigs(new audio_port_config[configs.size()]); + for (size_t i = 0; i < configs.size(); ++i) { + audioPortConfigToHal(configs[i], &halConfigs[i]); + } + return halConfigs; +} + +void HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort* port) { + port->id = halPort.id; + port->role = AudioPortRole(halPort.role); + port->type = AudioPortType(halPort.type); + port->name.setToExternal(halPort.name, strlen(halPort.name)); + port->sampleRates.resize(halPort.num_sample_rates); + for (size_t i = 0; i < halPort.num_sample_rates; ++i) { + port->sampleRates[i] = halPort.sample_rates[i]; + } + 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->formats.resize(halPort.num_formats); + for (size_t i = 0; i < halPort.num_formats; ++i) { + port->formats[i] = AudioFormat(halPort.formats[i]); + } + port->gains.resize(halPort.num_gains); + for (size_t i = 0; i < halPort.num_gains; ++i) { + audioGainFromHal(halPort.gains[i], &port->gains[i]); + } + audioPortConfigFromHal(halPort.active_config, &port->activeConfig); + switch (halPort.type) { + case AUDIO_PORT_TYPE_NONE: + break; + case AUDIO_PORT_TYPE_DEVICE: { + port->ext.device.hwModule = halPort.ext.device.hw_module; + port->ext.device.type = AudioDevice(halPort.ext.device.type); + memcpy(port->ext.device.address.data(), halPort.ext.device.address, + AUDIO_DEVICE_MAX_ADDRESS_LEN); + break; + } + case AUDIO_PORT_TYPE_MIX: { + port->ext.mix.hwModule = halPort.ext.mix.hw_module; + port->ext.mix.ioHandle = halPort.ext.mix.handle; + port->ext.mix.latencyClass = AudioMixLatencyClass(halPort.ext.mix.latency_class); + break; + } + case AUDIO_PORT_TYPE_SESSION: { + port->ext.session.session = halPort.ext.session.session; + break; + } + } +} + +void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort) { + memset(halPort, 0, sizeof(audio_port)); + 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))); + 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) { + halPort->sample_rates[i] = port.sampleRates[i]; + } + halPort->num_channel_masks = + std::min(port.channelMasks.size(), static_cast(AUDIO_PORT_MAX_CHANNEL_MASKS)); + for (size_t i = 0; i < halPort->num_channel_masks; ++i) { + halPort->channel_masks[i] = static_cast(port.channelMasks[i]); + } + halPort->num_formats = + std::min(port.formats.size(), static_cast(AUDIO_PORT_MAX_FORMATS)); + for (size_t i = 0; i < halPort->num_formats; ++i) { + halPort->formats[i] = static_cast(port.formats[i]); + } + halPort->num_gains = std::min(port.gains.size(), static_cast(AUDIO_PORT_MAX_GAINS)); + for (size_t i = 0; i < halPort->num_gains; ++i) { + audioGainToHal(port.gains[i], &halPort->gains[i]); + } + audioPortConfigToHal(port.activeConfig, &halPort->active_config); + switch (port.type) { + case AudioPortType::NONE: + break; + case AudioPortType::DEVICE: { + halPort->ext.device.hw_module = port.ext.device.hwModule; + halPort->ext.device.type = static_cast(port.ext.device.type); + memcpy(halPort->ext.device.address, port.ext.device.address.data(), + AUDIO_DEVICE_MAX_ADDRESS_LEN); + break; + } + case AudioPortType::MIX: { + halPort->ext.mix.hw_module = port.ext.mix.hwModule; + halPort->ext.mix.handle = port.ext.mix.ioHandle; + halPort->ext.mix.latency_class = + static_cast(port.ext.mix.latencyClass); + break; + } + case AudioPortType::SESSION: { + halPort->ext.session.session = static_cast(port.ext.session.session); + break; + } + } +} + +void HidlUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) { + uuid->timeLow = halUuid.timeLow; + uuid->timeMid = halUuid.timeMid; + uuid->versionAndTimeHigh = halUuid.timeHiAndVersion; + uuid->variantAndClockSeqHigh = halUuid.clockSeq; + memcpy(uuid->node.data(), halUuid.node, uuid->node.size()); +} + +void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) { + halUuid->timeLow = uuid.timeLow; + halUuid->timeMid = uuid.timeMid; + halUuid->timeHiAndVersion = uuid.versionAndTimeHigh; + halUuid->clockSeq = uuid.variantAndClockSeqHigh; + memcpy(halUuid->node, uuid.node.data(), uuid.node.size()); +} + +} // namespace android diff --git a/audio/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/HidlUtils.h new file mode 100644 index 000000000..09ed288fe --- /dev/null +++ b/audio/common/all-versions/default/HidlUtils.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2016 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_V2_0_Hidl_Utils_H_ +#define android_hardware_audio_V2_0_Hidl_Utils_H_ + +#include + +#include +#include + +using ::android::hardware::audio::common::V2_0::AudioConfig; +using ::android::hardware::audio::common::V2_0::AudioGain; +using ::android::hardware::audio::common::V2_0::AudioGainConfig; +using ::android::hardware::audio::common::V2_0::AudioOffloadInfo; +using ::android::hardware::audio::common::V2_0::AudioPort; +using ::android::hardware::audio::common::V2_0::AudioPortConfig; +using ::android::hardware::audio::common::V2_0::Uuid; +using ::android::hardware::hidl_vec; + +namespace android { + +class HidlUtils { + public: + static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config); + static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig); + static void audioGainConfigFromHal(const struct audio_gain_config& halConfig, + AudioGainConfig* config); + static void audioGainConfigToHal(const AudioGainConfig& config, + 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 void audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, + AudioOffloadInfo* offload); + static void audioOffloadInfoToHal(const AudioOffloadInfo& offload, + audio_offload_info_t* halOffload); + static void audioPortConfigFromHal(const struct audio_port_config& halConfig, + AudioPortConfig* config); + static void audioPortConfigToHal(const AudioPortConfig& config, + struct audio_port_config* halConfig); + static void audioPortConfigsFromHal(unsigned int numHalConfigs, + const struct audio_port_config* halConfigs, + hidl_vec* configs); + static std::unique_ptr audioPortConfigsToHal( + const hidl_vec& configs); + static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port); + static void audioPortToHal(const AudioPort& port, struct audio_port* halPort); + static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid); + static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid); +}; + +} // namespace android + +#endif // android_hardware_audio_V2_0_Hidl_Utils_H_ diff --git a/audio/common/all-versions/default/OWNERS b/audio/common/all-versions/default/OWNERS new file mode 100644 index 000000000..6fdc97ca2 --- /dev/null +++ b/audio/common/all-versions/default/OWNERS @@ -0,0 +1,3 @@ +elaurent@google.com +krocard@google.com +mnaganov@google.com -- cgit v1.2.3