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 #include <common/all-versions/IncludeGuard.h>
     18 
     19 #include <memory.h>
     20 #include <stdio.h>
     21 
     22 #include <common/all-versions/VersionUtils.h>
     23 
     24 using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils;
     25 using ::android::hardware::audio::common::utils::mkEnumConverter;
     26 
     27 namespace android {
     28 namespace hardware {
     29 namespace audio {
     30 namespace effect {
     31 namespace AUDIO_HAL_VERSION {
     32 namespace implementation {
     33 
     34 void effectDescriptorFromHal(const effect_descriptor_t& halDescriptor,
     35                              EffectDescriptor* descriptor) {
     36     HidlUtils::uuidFromHal(halDescriptor.type, &descriptor->type);
     37     HidlUtils::uuidFromHal(halDescriptor.uuid, &descriptor->uuid);
     38     descriptor->flags = mkEnumConverter<EffectFlags>(halDescriptor.flags);
     39     descriptor->cpuLoad = halDescriptor.cpuLoad;
     40     descriptor->memoryUsage = halDescriptor.memoryUsage;
     41     memcpy(descriptor->name.data(), halDescriptor.name, descriptor->name.size());
     42     memcpy(descriptor->implementor.data(), halDescriptor.implementor,
     43            descriptor->implementor.size());
     44 }
     45 
     46 std::string uuidToString(const effect_uuid_t& halUuid) {
     47     char str[64];
     48     snprintf(str, sizeof(str), "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", halUuid.timeLow,
     49              halUuid.timeMid, halUuid.timeHiAndVersion, halUuid.clockSeq, halUuid.node[0],
     50              halUuid.node[1], halUuid.node[2], halUuid.node[3], halUuid.node[4], halUuid.node[5]);
     51     return str;
     52 }
     53 
     54 }  // namespace implementation
     55 }  // namespace AUDIO_HAL_VERSION
     56 }  // namespace effect
     57 }  // namespace audio
     58 }  // namespace hardware
     59 }  // namespace android
     60