blob: 2de46678af2a03564af485ec1b1da8d8295ecd94 [file] [log] [blame]
François Gaffied0ba9ed2018-11-05 11:50:42 +01001/*
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
François Gaffie1e2b56f2022-04-01 14:34:29 +020017#define LOG_TAG "VolumeGroupAttributes"
François Gaffied0ba9ed2018-11-05 11:50:42 +010018//#define LOG_NDEBUG 0
19#include <utils/Log.h>
20
21#include <binder/Parcel.h>
22
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080023#include <media/AidlConversion.h>
François Gaffie1e2b56f2022-04-01 14:34:29 +020024#include <media/VolumeGroupAttributes.h>
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080025#include <media/PolicyAidlConversion.h>
26
François Gaffied0ba9ed2018-11-05 11:50:42 +010027namespace android {
28
François Gaffie1e2b56f2022-04-01 14:34:29 +020029status_t VolumeGroupAttributes::readFromParcel(const Parcel* parcel) {
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080030 media::AudioAttributesEx aidl;
31 RETURN_STATUS_IF_ERROR(aidl.readFromParcel(parcel));
François Gaffie1e2b56f2022-04-01 14:34:29 +020032 *this = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioAttributesEx_VolumeGroupAttributes(aidl));
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080033 return OK;
François Gaffied0ba9ed2018-11-05 11:50:42 +010034}
35
François Gaffie1e2b56f2022-04-01 14:34:29 +020036status_t VolumeGroupAttributes::writeToParcel(Parcel* parcel) const {
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080037 media::AudioAttributesEx aidl = VALUE_OR_RETURN_STATUS(
François Gaffie1e2b56f2022-04-01 14:34:29 +020038 legacy2aidl_VolumeGroupAttributes_AudioAttributesEx(*this));
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080039 return aidl.writeToParcel(parcel);
40}
41
42ConversionResult<media::AudioAttributesEx>
François Gaffie1e2b56f2022-04-01 14:34:29 +020043legacy2aidl_VolumeGroupAttributes_AudioAttributesEx(const VolumeGroupAttributes& legacy) {
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080044 media::AudioAttributesEx aidl;
45 aidl.attributes = VALUE_OR_RETURN(
46 legacy2aidl_audio_attributes_t_AudioAttributesInternal(legacy.getAttributes()));
47 aidl.streamType = VALUE_OR_RETURN(
48 legacy2aidl_audio_stream_type_t_AudioStreamType(legacy.getStreamType()));
49 aidl.groupId = VALUE_OR_RETURN(legacy2aidl_volume_group_t_int32_t(legacy.getGroupId()));
50 return aidl;
51}
52
François Gaffie1e2b56f2022-04-01 14:34:29 +020053ConversionResult<VolumeGroupAttributes>
54aidl2legacy_AudioAttributesEx_VolumeGroupAttributes(const media::AudioAttributesEx& aidl) {
55 return VolumeGroupAttributes(VALUE_OR_RETURN(aidl2legacy_int32_t_volume_group_t(aidl.groupId)),
Ytai Ben-Tsvi0a4904a2021-01-06 12:57:05 -080056 VALUE_OR_RETURN(aidl2legacy_AudioStreamType_audio_stream_type_t(
57 aidl.streamType)),
58 VALUE_OR_RETURN(aidl2legacy_AudioAttributesInternal_audio_attributes_t(
59 aidl.attributes)));
François Gaffied0ba9ed2018-11-05 11:50:42 +010060}
61
62} // namespace android