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