| François Gaffie | 4b2018b | 2018-11-07 11:18:59 +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 |  | 
|  | 17 | #define LOG_TAG "AudioVolumeGroup" | 
|  | 18 |  | 
|  | 19 | //#define LOG_NDEBUG 0 | 
|  | 20 |  | 
|  | 21 | #include <utils/Log.h> | 
|  | 22 | #include <binder/Parcel.h> | 
|  | 23 |  | 
| Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 24 | #include <media/AidlConversion.h> | 
| François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 25 | #include <media/AudioVolumeGroup.h> | 
| Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 26 | #include <media/PolicyAidlConversion.h> | 
|  | 27 |  | 
| François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 28 | namespace android { | 
|  | 29 |  | 
| Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 30 | using media::audio::common::AudioStreamType; | 
|  | 31 |  | 
| François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 32 | status_t AudioVolumeGroup::readFromParcel(const Parcel *parcel) | 
|  | 33 | { | 
| Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 34 | media::AudioVolumeGroup aidl; | 
|  | 35 | RETURN_STATUS_IF_ERROR(aidl.readFromParcel(parcel)); | 
|  | 36 | *this = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioVolumeGroup(aidl)); | 
|  | 37 | return OK; | 
| François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 38 | } | 
|  | 39 |  | 
|  | 40 | status_t AudioVolumeGroup::writeToParcel(Parcel *parcel) const | 
|  | 41 | { | 
| Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 42 | media::AudioVolumeGroup aidl = VALUE_OR_RETURN_STATUS(legacy2aidl_AudioVolumeGroup(*this)); | 
|  | 43 | return aidl.writeToParcel(parcel); | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 | ConversionResult<media::AudioVolumeGroup> | 
|  | 47 | legacy2aidl_AudioVolumeGroup(const AudioVolumeGroup& legacy) { | 
|  | 48 | media::AudioVolumeGroup aidl; | 
|  | 49 | aidl.groupId = VALUE_OR_RETURN(legacy2aidl_volume_group_t_int32_t(legacy.getId())); | 
|  | 50 | aidl.name = legacy.getName(); | 
|  | 51 | aidl.audioAttributes = VALUE_OR_RETURN( | 
|  | 52 | convertContainer<std::vector<media::AudioAttributesInternal>>( | 
|  | 53 | legacy.getAudioAttributes(), | 
|  | 54 | legacy2aidl_audio_attributes_t_AudioAttributesInternal)); | 
|  | 55 | aidl.streams = VALUE_OR_RETURN( | 
| Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 56 | convertContainer<std::vector<AudioStreamType>>(legacy.getStreamTypes(), | 
| Ytai Ben-Tsvi | 0a4904a | 2021-01-06 12:57:05 -0800 | [diff] [blame] | 57 | legacy2aidl_audio_stream_type_t_AudioStreamType)); | 
|  | 58 | return aidl; | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | ConversionResult<AudioVolumeGroup> | 
|  | 62 | aidl2legacy_AudioVolumeGroup(const media::AudioVolumeGroup& aidl) { | 
|  | 63 | return AudioVolumeGroup( | 
|  | 64 | aidl.name, | 
|  | 65 | VALUE_OR_RETURN(aidl2legacy_int32_t_volume_group_t(aidl.groupId)), | 
|  | 66 | VALUE_OR_RETURN(convertContainer<AttributesVector>( | 
|  | 67 | aidl.audioAttributes, | 
|  | 68 | aidl2legacy_AudioAttributesInternal_audio_attributes_t)), | 
|  | 69 | VALUE_OR_RETURN(convertContainer<StreamTypeVector>( | 
|  | 70 | aidl.streams, | 
|  | 71 | aidl2legacy_AudioStreamType_audio_stream_type_t)) | 
|  | 72 | ); | 
| François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 73 | } | 
|  | 74 |  | 
|  | 75 | } // namespace android |