François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 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 | |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 17 | #define LOG_TAG "VolumeGroupAttributes" |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 18 | //#define LOG_NDEBUG 0 |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <binder/Parcel.h> |
| 22 | |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 23 | #include <media/AidlConversion.h> |
François Gaffie | 8d7fd5a | 2023-01-17 17:28:09 +0100 | [diff] [blame] | 24 | #include <media/AudioProductStrategy.h> |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 25 | #include <media/VolumeGroupAttributes.h> |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 26 | #include <media/PolicyAidlConversion.h> |
| 27 | |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 28 | namespace android { |
| 29 | |
François Gaffie | 8d7fd5a | 2023-01-17 17:28:09 +0100 | [diff] [blame] | 30 | int VolumeGroupAttributes::matchesScore(const audio_attributes_t &attributes) const { |
| 31 | return AudioProductStrategy::attributesMatchesScore(mAttributes, attributes); |
| 32 | } |
| 33 | |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 34 | status_t VolumeGroupAttributes::readFromParcel(const Parcel* parcel) { |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 35 | media::AudioAttributesEx aidl; |
| 36 | RETURN_STATUS_IF_ERROR(aidl.readFromParcel(parcel)); |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 37 | *this = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioAttributesEx_VolumeGroupAttributes(aidl)); |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 38 | return OK; |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 39 | } |
| 40 | |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 41 | status_t VolumeGroupAttributes::writeToParcel(Parcel* parcel) const { |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 42 | media::AudioAttributesEx aidl = VALUE_OR_RETURN_STATUS( |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 43 | legacy2aidl_VolumeGroupAttributes_AudioAttributesEx(*this)); |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 44 | return aidl.writeToParcel(parcel); |
| 45 | } |
| 46 | |
| 47 | ConversionResult<media::AudioAttributesEx> |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 48 | legacy2aidl_VolumeGroupAttributes_AudioAttributesEx(const VolumeGroupAttributes& legacy) { |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 49 | media::AudioAttributesEx aidl; |
| 50 | aidl.attributes = VALUE_OR_RETURN( |
Mikhail Naganov | 1c40090 | 2023-05-17 11:48:43 -0700 | [diff] [blame] | 51 | legacy2aidl_audio_attributes_t_AudioAttributes(legacy.getAttributes())); |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 52 | aidl.streamType = VALUE_OR_RETURN( |
| 53 | legacy2aidl_audio_stream_type_t_AudioStreamType(legacy.getStreamType())); |
| 54 | aidl.groupId = VALUE_OR_RETURN(legacy2aidl_volume_group_t_int32_t(legacy.getGroupId())); |
| 55 | return aidl; |
| 56 | } |
| 57 | |
François Gaffie | 1e2b56f | 2022-04-01 14:34:29 +0200 | [diff] [blame] | 58 | ConversionResult<VolumeGroupAttributes> |
| 59 | aidl2legacy_AudioAttributesEx_VolumeGroupAttributes(const media::AudioAttributesEx& aidl) { |
| 60 | return VolumeGroupAttributes(VALUE_OR_RETURN(aidl2legacy_int32_t_volume_group_t(aidl.groupId)), |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 61 | VALUE_OR_RETURN(aidl2legacy_AudioStreamType_audio_stream_type_t( |
| 62 | aidl.streamType)), |
Mikhail Naganov | 1c40090 | 2023-05-17 11:48:43 -0700 | [diff] [blame] | 63 | VALUE_OR_RETURN(aidl2legacy_AudioAttributes_audio_attributes_t( |
Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 64 | aidl.attributes))); |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | } // namespace android |