Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef android_hardware_audio_V2_0_Hidl_Utils_H_ |
| 18 | #define android_hardware_audio_V2_0_Hidl_Utils_H_ |
| 19 | |
| 20 | #include <memory> |
| 21 | |
| 22 | #include <android/hardware/audio/common/2.0/types.h> |
| 23 | #include <system/audio.h> |
| 24 | |
| 25 | using ::android::hardware::audio::common::V2_0::AudioConfig; |
| 26 | using ::android::hardware::audio::common::V2_0::AudioGain; |
| 27 | using ::android::hardware::audio::common::V2_0::AudioGainConfig; |
| 28 | using ::android::hardware::audio::common::V2_0::AudioOffloadInfo; |
| 29 | using ::android::hardware::audio::common::V2_0::AudioPort; |
| 30 | using ::android::hardware::audio::common::V2_0::AudioPortConfig; |
| 31 | using ::android::hardware::audio::common::V2_0::Uuid; |
| 32 | using ::android::hardware::hidl_vec; |
| 33 | |
| 34 | namespace android { |
| 35 | |
| 36 | class HidlUtils { |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame^] | 37 | public: |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 38 | static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config); |
| 39 | static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig); |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame^] | 40 | static void audioGainConfigFromHal(const struct audio_gain_config& halConfig, |
| 41 | AudioGainConfig* config); |
| 42 | static void audioGainConfigToHal(const AudioGainConfig& config, |
| 43 | struct audio_gain_config* halConfig); |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 44 | static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain); |
| 45 | static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain); |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame^] | 46 | static void audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, |
| 47 | AudioOffloadInfo* offload); |
| 48 | static void audioOffloadInfoToHal(const AudioOffloadInfo& offload, |
| 49 | audio_offload_info_t* halOffload); |
| 50 | static void audioPortConfigFromHal(const struct audio_port_config& halConfig, |
| 51 | AudioPortConfig* config); |
| 52 | static void audioPortConfigToHal(const AudioPortConfig& config, |
| 53 | struct audio_port_config* halConfig); |
| 54 | static void audioPortConfigsFromHal(unsigned int numHalConfigs, |
| 55 | const struct audio_port_config* halConfigs, |
| 56 | hidl_vec<AudioPortConfig>* configs); |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 57 | static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal( |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame^] | 58 | const hidl_vec<AudioPortConfig>& configs); |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 59 | static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port); |
| 60 | static void audioPortToHal(const AudioPort& port, struct audio_port* halPort); |
| 61 | static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid); |
| 62 | static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid); |
| 63 | }; |
| 64 | |
| 65 | } // namespace android |
| 66 | |
| 67 | #endif // android_hardware_audio_V2_0_Hidl_Utils_H_ |