blob: e7d4c463880bdedf27c4f786d5934b9ddca6db29 [file] [log] [blame]
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07001/*
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"
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080021#include "HidlUtils.h"
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070022
23namespace android {
24namespace hardware {
25namespace audio {
26namespace effect {
27namespace V2_0 {
28namespace implementation {
29
30void effectDescriptorFromHal(
31 const effect_descriptor_t& halDescriptor, EffectDescriptor* descriptor) {
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080032 HidlUtils::uuidFromHal(halDescriptor.type, &descriptor->type);
33 HidlUtils::uuidFromHal(halDescriptor.uuid, &descriptor->uuid);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070034 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
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070042std::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