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