Home | History | Annotate | Download | only in default
      1 /*
      2  * Copyright (C) 2018 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_Hidl_Utils_H_
     18 #define android_hardware_audio_Hidl_Utils_H_
     19 
     20 #include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
     21 
     22 #include <memory>
     23 
     24 #include <system/audio.h>
     25 
     26 using ::android::hardware::hidl_vec;
     27 
     28 namespace android {
     29 namespace hardware {
     30 namespace audio {
     31 namespace common {
     32 namespace CPP_VERSION {
     33 namespace implementation {
     34 
     35 using namespace ::android::hardware::audio::common::CPP_VERSION;
     36 
     37 class HidlUtils {
     38    public:
     39     static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config);
     40     static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
     41     static void audioGainConfigFromHal(const struct audio_gain_config& halConfig,
     42                                        AudioGainConfig* config);
     43     static void audioGainConfigToHal(const AudioGainConfig& config,
     44                                      struct audio_gain_config* halConfig);
     45     static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
     46     static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
     47     static AudioUsage audioUsageFromHal(const audio_usage_t halUsage);
     48     static audio_usage_t audioUsageToHal(const AudioUsage usage);
     49     static void audioOffloadInfoFromHal(const audio_offload_info_t& halOffload,
     50                                         AudioOffloadInfo* offload);
     51     static void audioOffloadInfoToHal(const AudioOffloadInfo& offload,
     52                                       audio_offload_info_t* halOffload);
     53     static void audioPortConfigFromHal(const struct audio_port_config& halConfig,
     54                                        AudioPortConfig* config);
     55     static void audioPortConfigToHal(const AudioPortConfig& config,
     56                                      struct audio_port_config* halConfig);
     57     static void audioPortConfigsFromHal(unsigned int numHalConfigs,
     58                                         const struct audio_port_config* halConfigs,
     59                                         hidl_vec<AudioPortConfig>* configs);
     60     static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
     61         const hidl_vec<AudioPortConfig>& configs);
     62     static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
     63     static void audioPortToHal(const AudioPort& port, struct audio_port* halPort);
     64     static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid);
     65     static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
     66 };
     67 
     68 }  // namespace implementation
     69 }  // namespace CPP_VERSION
     70 }  // namespace common
     71 }  // namespace audio
     72 }  // namespace hardware
     73 }  // namespace android
     74 
     75 #endif  // android_hardware_audio_Hidl_Utils_H_
     76