blob: 85edc7b2f48c53d11c7d4be0f02100de51707f18 [file] [log] [blame]
Mikhail Naganov4122f632020-10-29 12:37:00 -07001/*
2 * Copyright (C) 2020 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 "UuidUtils.h"
18
19#include <common/all-versions/VersionUtils.h>
20#include <string.h>
21
22namespace android {
23namespace hardware {
24namespace audio {
25namespace common {
26namespace CPP_VERSION {
27namespace implementation {
28
29void UuidUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) {
30 uuid->timeLow = halUuid.timeLow;
31 uuid->timeMid = halUuid.timeMid;
32 uuid->versionAndTimeHigh = halUuid.timeHiAndVersion;
33 uuid->variantAndClockSeqHigh = halUuid.clockSeq;
34 memcpy(uuid->node.data(), halUuid.node, uuid->node.size());
35}
36
37void UuidUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
38 halUuid->timeLow = uuid.timeLow;
39 halUuid->timeMid = uuid.timeMid;
40 halUuid->timeHiAndVersion = uuid.versionAndTimeHigh;
41 halUuid->clockSeq = uuid.variantAndClockSeqHigh;
42 memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
43}
44
45} // namespace implementation
46} // namespace CPP_VERSION
47} // namespace common
48} // namespace audio
49} // namespace hardware
50} // namespace android