1 /* 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 #pragma once 18 19 #include <limits> 20 #include <type_traits> 21 22 #include <system/audio.h> 23 24 #include <android/media/AudioClient.h> 25 #include <android/media/AudioDirectMode.h> 26 #include <android/media/AudioIoConfigEvent.h> 27 #include <android/media/AudioIoDescriptor.h> 28 #include <android/media/AudioPortFw.h> 29 #include <android/media/AudioPortConfigFw.h> 30 #include <android/media/AudioPortDeviceExtSys.h> 31 #include <android/media/AudioTimestampInternal.h> 32 #include <android/media/AudioUniqueIdUse.h> 33 #include <android/media/EffectDescriptor.h> 34 #include <android/media/MicrophoneInfoFw.h> 35 #include <android/media/TrackSecondaryOutputInfo.h> 36 37 #include <android/media/SharedFileRegion.h> 38 #include <binder/IMemory.h> 39 #include <media/AidlConversionCppNdk.h> 40 #include <media/AidlConversionUtil.h> 41 #include <media/AudioClient.h> 42 #include <media/AudioCommonTypes.h> 43 #include <media/AudioIoDescriptor.h> 44 #include <media/AudioTimestamp.h> 45 #include <system/audio_effect.h> 46 47 namespace android { 48 49 ConversionResult<audio_io_config_event_t> aidl2legacy_AudioIoConfigEvent_audio_io_config_event_t( 50 media::AudioIoConfigEvent aidl); 51 ConversionResult<media::AudioIoConfigEvent> legacy2aidl_audio_io_config_event_t_AudioIoConfigEvent( 52 audio_io_config_event_t legacy); 53 54 ConversionResult<audio_port_role_t> aidl2legacy_AudioPortRole_audio_port_role_t( 55 media::AudioPortRole aidl); 56 ConversionResult<media::AudioPortRole> legacy2aidl_audio_port_role_t_AudioPortRole( 57 audio_port_role_t legacy); 58 59 ConversionResult<audio_port_type_t> aidl2legacy_AudioPortType_audio_port_type_t( 60 media::AudioPortType aidl); 61 ConversionResult<media::AudioPortType> legacy2aidl_audio_port_type_t_AudioPortType( 62 audio_port_type_t legacy); 63 64 ConversionResult<audio_port_config_device_ext> 65 aidl2legacy_AudioPortDeviceExt_audio_port_config_device_ext( 66 const media::audio::common::AudioPortDeviceExt& aidl, 67 const media::AudioPortDeviceExtSys& aidlDeviceExt); 68 status_t legacy2aidl_audio_port_config_device_ext_AudioPortDeviceExt( 69 const audio_port_config_device_ext& legacy, 70 media::audio::common::AudioPortDeviceExt* aidl, 71 media::AudioPortDeviceExtSys* aidlDeviceExt); 72 73 ConversionResult<audio_port_config_mix_ext> aidl2legacy_AudioPortMixExt( 74 const media::audio::common::AudioPortMixExt& aidl, media::AudioPortRole role, 75 const media::AudioPortMixExtSys& aidlMixExt); 76 status_t legacy2aidl_AudioPortMixExt( 77 const audio_port_config_mix_ext& legacy, audio_port_role_t role, 78 media::audio::common::AudioPortMixExt* aidl, media::AudioPortMixExtSys* aidlMixExt); 79 80 ConversionResult<audio_port_config_session_ext> 81 aidl2legacy_int32_t_audio_port_config_session_ext(int32_t aidl); 82 ConversionResult<int32_t> legacy2aidl_audio_port_config_session_ext_AudioPortConfigSessionExt( 83 const audio_port_config_session_ext& legacy); 84 85 // portId needs to be set when dealing with the HAL. 86 ConversionResult<audio_port_config> aidl2legacy_AudioPortConfigFw_audio_port_config( 87 const media::AudioPortConfigFw& aidl, int32_t* aidlPortId = nullptr); 88 ConversionResult<media::AudioPortConfigFw> legacy2aidl_audio_port_config_AudioPortConfigFw( 89 const audio_port_config& legacy, int32_t portId = 0); 90 91 ConversionResult<struct audio_patch> aidl2legacy_AudioPatchFw_audio_patch( 92 const media::AudioPatchFw& aidl); 93 ConversionResult<media::AudioPatchFw> legacy2aidl_audio_patch_AudioPatchFw( 94 const struct audio_patch& legacy); 95 96 ConversionResult<sp<AudioIoDescriptor>> aidl2legacy_AudioIoDescriptor_AudioIoDescriptor( 97 const media::AudioIoDescriptor& aidl); 98 ConversionResult<media::AudioIoDescriptor> legacy2aidl_AudioIoDescriptor_AudioIoDescriptor( 99 const sp<AudioIoDescriptor>& legacy); 100 101 ConversionResult<AudioClient> aidl2legacy_AudioClient_AudioClient( 102 const media::AudioClient& aidl); 103 ConversionResult<media::AudioClient> legacy2aidl_AudioClient_AudioClient( 104 const AudioClient& legacy); 105 106 ConversionResult<sp<IMemory>> 107 aidl2legacy_SharedFileRegion_IMemory(const media::SharedFileRegion& aidl); 108 ConversionResult<media::SharedFileRegion> 109 legacy2aidl_IMemory_SharedFileRegion(const sp<IMemory>& legacy); 110 111 ConversionResult<sp<::android::IMemory>> aidl2legacy_NullableSharedFileRegion_IMemory( 112 const std::optional<media::SharedFileRegion>& aidl); 113 ConversionResult<std::optional<media::SharedFileRegion>> 114 legacy2aidl_NullableIMemory_SharedFileRegion(const sp<IMemory>& legacy); 115 116 ConversionResult<AudioTimestamp> 117 aidl2legacy_AudioTimestampInternal_AudioTimestamp(const media::AudioTimestampInternal& aidl); 118 ConversionResult<media::AudioTimestampInternal> 119 legacy2aidl_AudioTimestamp_AudioTimestampInternal(const AudioTimestamp& legacy); 120 121 ConversionResult<effect_descriptor_t> 122 aidl2legacy_EffectDescriptor_effect_descriptor_t(const media::EffectDescriptor& aidl); 123 ConversionResult<media::EffectDescriptor> legacy2aidl_effect_descriptor_t_EffectDescriptor( 124 const effect_descriptor_t& legacy); 125 126 ConversionResult<audio_port_device_ext> 127 aidl2legacy_AudioPortDeviceExt_audio_port_device_ext( 128 const media::audio::common::AudioPortDeviceExt& aidl, 129 const media::AudioPortDeviceExtSys& aidlDeviceExt); 130 status_t legacy2aidl_audio_port_device_ext_AudioPortDeviceExt( 131 const audio_port_device_ext& legacy, 132 media::audio::common::AudioPortDeviceExt* aidl, 133 media::AudioPortDeviceExtSys* aidlDeviceExt); 134 135 ConversionResult<audio_port_mix_ext> 136 aidl2legacy_AudioPortMixExt_audio_port_mix_ext( 137 const media::audio::common::AudioPortMixExt& aidl, 138 const media::AudioPortMixExtSys& aidlMixExt); 139 status_t legacy2aidl_audio_port_mix_ext_AudioPortMixExt( 140 const audio_port_mix_ext& legacy, 141 media::audio::common::AudioPortMixExt* aidl, 142 media::AudioPortMixExtSys* aidlMixExt); 143 144 ConversionResult<audio_port_session_ext> 145 aidl2legacy_int32_t_audio_port_session_ext(int32_t aidl); 146 ConversionResult<int32_t> 147 legacy2aidl_audio_port_session_ext_int32_t(const audio_port_session_ext& legacy); 148 149 ConversionResult<audio_port_v7> 150 aidl2legacy_AudioPortFw_audio_port_v7(const media::AudioPortFw& aidl); 151 ConversionResult<media::AudioPortFw> 152 legacy2aidl_audio_port_v7_AudioPortFw(const audio_port_v7& legacy); 153 154 ConversionResult<audio_unique_id_use_t> 155 aidl2legacy_AudioUniqueIdUse_audio_unique_id_use_t(media::AudioUniqueIdUse aidl); 156 ConversionResult<media::AudioUniqueIdUse> 157 legacy2aidl_audio_unique_id_use_t_AudioUniqueIdUse(audio_unique_id_use_t legacy); 158 159 ConversionResult<volume_group_t> 160 aidl2legacy_int32_t_volume_group_t(int32_t aidl); 161 ConversionResult<int32_t> 162 legacy2aidl_volume_group_t_int32_t(volume_group_t legacy); 163 164 using TrackSecondaryOutputInfoPair = std::pair<audio_port_handle_t, std::vector<audio_io_handle_t>>; 165 ConversionResult<TrackSecondaryOutputInfoPair> 166 aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair( 167 const media::TrackSecondaryOutputInfo& aidl); 168 ConversionResult<media::TrackSecondaryOutputInfo> 169 legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo( 170 const TrackSecondaryOutputInfoPair& legacy); 171 172 ConversionResult<audio_direct_mode_t> 173 aidl2legacy_AudioDirectMode_audio_direct_mode_t(media::AudioDirectMode aidl); 174 ConversionResult<media::AudioDirectMode> 175 legacy2aidl_audio_direct_mode_t_AudioDirectMode(audio_direct_mode_t legacy); 176 177 ConversionResult<audio_direct_mode_t> aidl2legacy_int32_t_audio_direct_mode_t_mask(int32_t aidl); 178 ConversionResult<int32_t> legacy2aidl_audio_direct_mode_t_int32_t_mask(audio_direct_mode_t legacy); 179 180 ConversionResult<audio_microphone_characteristic_t> 181 aidl2legacy_MicrophoneInfoFw_audio_microphone_characteristic_t( 182 const media::MicrophoneInfoFw& aidl); 183 ConversionResult<media::MicrophoneInfoFw> 184 legacy2aidl_audio_microphone_characteristic_t_MicrophoneInfoFw( 185 const audio_microphone_characteristic_t& legacy); 186 187 } // namespace android 188