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