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 { |
| 37 | public: |
| 38 | static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config); |
| 39 | static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig); |
| 40 | static void audioGainConfigFromHal( |
| 41 | const struct audio_gain_config& halConfig, AudioGainConfig* config); |
| 42 | static void audioGainConfigToHal( |
| 43 | const AudioGainConfig& config, struct audio_gain_config* halConfig); |
| 44 | static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain); |
| 45 | static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain); |
| 46 | static void audioOffloadInfoFromHal( |
| 47 | const audio_offload_info_t& halOffload, AudioOffloadInfo* offload); |
| 48 | static void audioOffloadInfoToHal( |
| 49 | const AudioOffloadInfo& offload, audio_offload_info_t* halOffload); |
| 50 | static void audioPortConfigFromHal( |
| 51 | const struct audio_port_config& halConfig, AudioPortConfig* config); |
| 52 | static void audioPortConfigToHal( |
| 53 | const AudioPortConfig& config, struct audio_port_config* halConfig); |
| 54 | static void audioPortConfigsFromHal( |
| 55 | unsigned int numHalConfigs, const struct audio_port_config *halConfigs, |
| 56 | hidl_vec<AudioPortConfig> *configs); |
| 57 | static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal( |
| 58 | const hidl_vec<AudioPortConfig>& configs); |
| 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_ |