Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | ** |
| 3 | ** Copyright 2007, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "IAudioFlinger" |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 20 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | #include <utils/Log.h> |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <sys/types.h> |
| 25 | |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 26 | #include <binder/IPCThreadState.h> |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 27 | #include <binder/Parcel.h> |
Steven Moreland | 25a9e55 | 2017-04-17 14:30:39 -0700 | [diff] [blame] | 28 | #include "IAudioFlinger.h" |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 32 | using aidl_utils::statusTFromBinderStatus; |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 33 | using binder::Status; |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 34 | using media::audio::common::AudioChannelLayout; |
| 35 | using media::audio::common::AudioFormatDescription; |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 36 | using media::audio::common::AudioMMapPolicyInfo; |
| 37 | using media::audio::common::AudioMMapPolicyType; |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 38 | using media::audio::common::AudioMode; |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 39 | using media::audio::common::AudioStreamType; |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 40 | using media::audio::common::AudioUuid; |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 41 | |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 42 | #define MAX_ITEMS_PER_LIST 1024 |
| 43 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 44 | #define VALUE_OR_RETURN_BINDER(x) \ |
| 45 | ({ \ |
| 46 | auto _tmp = (x); \ |
| 47 | if (!_tmp.ok()) return Status::fromStatusT(_tmp.error()); \ |
| 48 | std::move(_tmp.value()); \ |
| 49 | }) |
| 50 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 51 | #define RETURN_BINDER_IF_ERROR(x) \ |
| 52 | { \ |
| 53 | auto _tmp = (x); \ |
| 54 | if (_tmp != OK) return Status::fromStatusT(_tmp); \ |
| 55 | } |
| 56 | |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 57 | ConversionResult<media::CreateTrackRequest> IAudioFlinger::CreateTrackInput::toAidl() const { |
| 58 | media::CreateTrackRequest aidl; |
| 59 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 60 | // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks. |
| 61 | aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig( |
| 62 | config, false /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 63 | aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 64 | aidl.sharedBuffer = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(sharedBuffer)); |
| 65 | aidl.notificationsPerBuffer = VALUE_OR_RETURN(convertIntegral<int32_t>(notificationsPerBuffer)); |
| 66 | aidl.speed = speed; |
| 67 | aidl.audioTrackCallback = audioTrackCallback; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 68 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_output_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 69 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 70 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 71 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 72 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 73 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 74 | return aidl; |
| 75 | } |
| 76 | |
| 77 | ConversionResult<IAudioFlinger::CreateTrackInput> |
| 78 | IAudioFlinger::CreateTrackInput::fromAidl(const media::CreateTrackRequest& aidl) { |
| 79 | IAudioFlinger::CreateTrackInput legacy; |
| 80 | legacy.attr = VALUE_OR_RETURN(aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 81 | // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks. |
| 82 | legacy.config = VALUE_OR_RETURN( |
| 83 | aidl2legacy_AudioConfig_audio_config_t(aidl.config, false /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 84 | legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 85 | legacy.sharedBuffer = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.sharedBuffer)); |
| 86 | legacy.notificationsPerBuffer = VALUE_OR_RETURN( |
| 87 | convertIntegral<uint32_t>(aidl.notificationsPerBuffer)); |
| 88 | legacy.speed = aidl.speed; |
| 89 | legacy.audioTrackCallback = aidl.audioTrackCallback; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 90 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_output_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 91 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 92 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 93 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 94 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 95 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 96 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 97 | return legacy; |
| 98 | } |
| 99 | |
| 100 | ConversionResult<media::CreateTrackResponse> |
| 101 | IAudioFlinger::CreateTrackOutput::toAidl() const { |
| 102 | media::CreateTrackResponse aidl; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 103 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_output_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 104 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 105 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 106 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 107 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 108 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 109 | aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
Andy Hung | a2159aa | 2021-07-20 13:01:52 -0700 | [diff] [blame] | 110 | aidl.streamType = VALUE_OR_RETURN( |
| 111 | legacy2aidl_audio_stream_type_t_AudioStreamType(streamType)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 112 | aidl.afFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(afFrameCount)); |
| 113 | aidl.afSampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(afSampleRate)); |
| 114 | aidl.afLatencyMs = VALUE_OR_RETURN(convertIntegral<int32_t>(afLatencyMs)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame^] | 115 | aidl.afChannelMask = VALUE_OR_RETURN( |
| 116 | legacy2aidl_audio_channel_mask_t_AudioChannelLayout(afChannelMask, false /*isInput*/)); |
| 117 | aidl.afFormat = VALUE_OR_RETURN( |
| 118 | legacy2aidl_audio_format_t_AudioFormatDescription(afFormat)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 119 | aidl.outputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(outputId)); |
| 120 | aidl.portId = VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 121 | aidl.audioTrack = audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 122 | return aidl; |
| 123 | } |
| 124 | |
| 125 | ConversionResult<IAudioFlinger::CreateTrackOutput> |
| 126 | IAudioFlinger::CreateTrackOutput::fromAidl( |
| 127 | const media::CreateTrackResponse& aidl) { |
| 128 | IAudioFlinger::CreateTrackOutput legacy; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 129 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_output_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 130 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 131 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 132 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 133 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 134 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 135 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 136 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
Andy Hung | a2159aa | 2021-07-20 13:01:52 -0700 | [diff] [blame] | 137 | legacy.streamType = VALUE_OR_RETURN( |
| 138 | aidl2legacy_AudioStreamType_audio_stream_type_t(aidl.streamType)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 139 | legacy.afFrameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.afFrameCount)); |
| 140 | legacy.afSampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afSampleRate)); |
| 141 | legacy.afLatencyMs = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afLatencyMs)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame^] | 142 | legacy.afChannelMask = VALUE_OR_RETURN( |
| 143 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.afChannelMask, |
| 144 | false /*isInput*/)); |
| 145 | legacy.afFormat = VALUE_OR_RETURN( |
| 146 | aidl2legacy_AudioFormatDescription_audio_format_t(aidl.afFormat)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 147 | legacy.outputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.outputId)); |
| 148 | legacy.portId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_port_handle_t(aidl.portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 149 | legacy.audioTrack = aidl.audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 150 | return legacy; |
| 151 | } |
| 152 | |
| 153 | ConversionResult<media::CreateRecordRequest> |
| 154 | IAudioFlinger::CreateRecordInput::toAidl() const { |
| 155 | media::CreateRecordRequest aidl; |
| 156 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 157 | aidl.config = VALUE_OR_RETURN( |
| 158 | legacy2aidl_audio_config_base_t_AudioConfigBase(config, true /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 159 | aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 160 | aidl.riid = VALUE_OR_RETURN(legacy2aidl_audio_unique_id_t_int32_t(riid)); |
Eric Laurent | ec376dc | 2021-04-08 20:41:22 +0200 | [diff] [blame] | 161 | aidl.maxSharedAudioHistoryMs = VALUE_OR_RETURN( |
| 162 | convertIntegral<int32_t>(maxSharedAudioHistoryMs)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 163 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_input_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 164 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 165 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 166 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 167 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 168 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 169 | return aidl; |
| 170 | } |
| 171 | |
| 172 | ConversionResult<IAudioFlinger::CreateRecordInput> |
| 173 | IAudioFlinger::CreateRecordInput::fromAidl( |
| 174 | const media::CreateRecordRequest& aidl) { |
| 175 | IAudioFlinger::CreateRecordInput legacy; |
Eric Laurent | ec376dc | 2021-04-08 20:41:22 +0200 | [diff] [blame] | 176 | legacy.attr = VALUE_OR_RETURN( |
| 177 | aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 178 | legacy.config = VALUE_OR_RETURN( |
| 179 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config, true /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 180 | legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 181 | legacy.riid = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_unique_id_t(aidl.riid)); |
Eric Laurent | ec376dc | 2021-04-08 20:41:22 +0200 | [diff] [blame] | 182 | legacy.maxSharedAudioHistoryMs = VALUE_OR_RETURN( |
| 183 | convertIntegral<int32_t>(aidl.maxSharedAudioHistoryMs)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 184 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_input_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 185 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 186 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 187 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 188 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 189 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 190 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 191 | return legacy; |
| 192 | } |
| 193 | |
| 194 | ConversionResult<media::CreateRecordResponse> |
| 195 | IAudioFlinger::CreateRecordOutput::toAidl() const { |
| 196 | media::CreateRecordResponse aidl; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 197 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_input_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 198 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 199 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 200 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 201 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 202 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 203 | aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
| 204 | aidl.inputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(inputId)); |
| 205 | aidl.cblk = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(cblk)); |
| 206 | aidl.buffers = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(buffers)); |
| 207 | aidl.portId = VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 208 | aidl.audioRecord = audioRecord; |
jiabin | b00edc3 | 2021-08-16 16:27:54 +0000 | [diff] [blame] | 209 | aidl.serverConfig = VALUE_OR_RETURN( |
| 210 | legacy2aidl_audio_config_base_t_AudioConfigBase(serverConfig, true /*isInput*/)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame^] | 211 | aidl.halConfig = VALUE_OR_RETURN( |
| 212 | legacy2aidl_audio_config_base_t_AudioConfigBase(halConfig, true /*isInput*/)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 213 | return aidl; |
| 214 | } |
| 215 | |
| 216 | ConversionResult<IAudioFlinger::CreateRecordOutput> |
| 217 | IAudioFlinger::CreateRecordOutput::fromAidl( |
| 218 | const media::CreateRecordResponse& aidl) { |
| 219 | IAudioFlinger::CreateRecordOutput legacy; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 220 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_input_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 221 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 222 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 223 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 224 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 225 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 226 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 227 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
| 228 | legacy.inputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.inputId)); |
| 229 | legacy.cblk = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.cblk)); |
| 230 | legacy.buffers = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.buffers)); |
| 231 | legacy.portId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_port_handle_t(aidl.portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 232 | legacy.audioRecord = aidl.audioRecord; |
jiabin | b00edc3 | 2021-08-16 16:27:54 +0000 | [diff] [blame] | 233 | legacy.serverConfig = VALUE_OR_RETURN( |
| 234 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.serverConfig, true /*isInput*/)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame^] | 235 | legacy.halConfig = VALUE_OR_RETURN( |
| 236 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.halConfig, true /*isInput*/)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 237 | return legacy; |
| 238 | } |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 239 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 240 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 241 | // AudioFlingerClientAdapter |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 243 | AudioFlingerClientAdapter::AudioFlingerClientAdapter( |
| 244 | const sp<media::IAudioFlingerService> delegate) : mDelegate(delegate) {} |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 245 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 246 | status_t AudioFlingerClientAdapter::createTrack(const media::CreateTrackRequest& input, |
| 247 | media::CreateTrackResponse& output) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 248 | return statusTFromBinderStatus(mDelegate->createTrack(input, &output)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 251 | status_t AudioFlingerClientAdapter::createRecord(const media::CreateRecordRequest& input, |
| 252 | media::CreateRecordResponse& output) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 253 | return statusTFromBinderStatus(mDelegate->createRecord(input, &output)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | uint32_t AudioFlingerClientAdapter::sampleRate(audio_io_handle_t ioHandle) const { |
| 257 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 258 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 259 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 260 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->sampleRate(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 261 | return convertIntegral<uint32_t>(aidlRet); |
| 262 | }(); |
| 263 | // Failure is ignored. |
| 264 | return result.value_or(0); |
| 265 | } |
| 266 | |
| 267 | audio_format_t AudioFlingerClientAdapter::format(audio_io_handle_t output) const { |
| 268 | auto result = [&]() -> ConversionResult<audio_format_t> { |
| 269 | int32_t outputAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 270 | AudioFormatDescription aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 271 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->format(outputAidl, &aidlRet))); |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 272 | return aidl2legacy_AudioFormatDescription_audio_format_t(aidlRet); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 273 | }(); |
| 274 | return result.value_or(AUDIO_FORMAT_INVALID); |
| 275 | } |
| 276 | |
| 277 | size_t AudioFlingerClientAdapter::frameCount(audio_io_handle_t ioHandle) const { |
| 278 | auto result = [&]() -> ConversionResult<size_t> { |
| 279 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 280 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 281 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->frameCount(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 282 | return convertIntegral<size_t>(aidlRet); |
| 283 | }(); |
| 284 | // Failure is ignored. |
| 285 | return result.value_or(0); |
| 286 | } |
| 287 | |
| 288 | uint32_t AudioFlingerClientAdapter::latency(audio_io_handle_t output) const { |
| 289 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 290 | int32_t outputAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 291 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 292 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->latency(outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 293 | return convertIntegral<uint32_t>(aidlRet); |
| 294 | }(); |
| 295 | // Failure is ignored. |
| 296 | return result.value_or(0); |
| 297 | } |
| 298 | |
| 299 | status_t AudioFlingerClientAdapter::setMasterVolume(float value) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 300 | return statusTFromBinderStatus(mDelegate->setMasterVolume(value)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | status_t AudioFlingerClientAdapter::setMasterMute(bool muted) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 304 | return statusTFromBinderStatus(mDelegate->setMasterMute(muted)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | float AudioFlingerClientAdapter::masterVolume() const { |
| 308 | auto result = [&]() -> ConversionResult<float> { |
| 309 | float aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 310 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->masterVolume(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 311 | return aidlRet; |
| 312 | }(); |
| 313 | // Failure is ignored. |
| 314 | return result.value_or(0.f); |
| 315 | } |
| 316 | |
| 317 | bool AudioFlingerClientAdapter::masterMute() const { |
| 318 | auto result = [&]() -> ConversionResult<bool> { |
| 319 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 320 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->masterMute(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 321 | return aidlRet; |
| 322 | }(); |
| 323 | // Failure is ignored. |
| 324 | return result.value_or(false); |
| 325 | } |
| 326 | |
| 327 | status_t AudioFlingerClientAdapter::setMasterBalance(float balance) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 328 | return statusTFromBinderStatus(mDelegate->setMasterBalance(balance)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | status_t AudioFlingerClientAdapter::getMasterBalance(float* balance) const{ |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 332 | return statusTFromBinderStatus(mDelegate->getMasterBalance(balance)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | status_t AudioFlingerClientAdapter::setStreamVolume(audio_stream_type_t stream, float value, |
| 336 | audio_io_handle_t output) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 337 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 338 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 339 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 340 | return statusTFromBinderStatus(mDelegate->setStreamVolume(streamAidl, value, outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | status_t AudioFlingerClientAdapter::setStreamMute(audio_stream_type_t stream, bool muted) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 344 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 345 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 346 | return statusTFromBinderStatus(mDelegate->setStreamMute(streamAidl, muted)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | float AudioFlingerClientAdapter::streamVolume(audio_stream_type_t stream, |
| 350 | audio_io_handle_t output) const { |
| 351 | auto result = [&]() -> ConversionResult<float> { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 352 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 353 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 354 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 355 | float aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 356 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 357 | mDelegate->streamVolume(streamAidl, outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 358 | return aidlRet; |
| 359 | }(); |
| 360 | // Failure is ignored. |
| 361 | return result.value_or(0.f); |
| 362 | } |
| 363 | |
| 364 | bool AudioFlingerClientAdapter::streamMute(audio_stream_type_t stream) const { |
| 365 | auto result = [&]() -> ConversionResult<bool> { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 366 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 367 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 368 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 369 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 370 | mDelegate->streamMute(streamAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 371 | return aidlRet; |
| 372 | }(); |
| 373 | // Failure is ignored. |
| 374 | return result.value_or(false); |
| 375 | } |
| 376 | |
| 377 | status_t AudioFlingerClientAdapter::setMode(audio_mode_t mode) { |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 378 | AudioMode modeAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_mode_t_AudioMode(mode)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 379 | return statusTFromBinderStatus(mDelegate->setMode(modeAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | status_t AudioFlingerClientAdapter::setMicMute(bool state) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 383 | return statusTFromBinderStatus(mDelegate->setMicMute(state)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | bool AudioFlingerClientAdapter::getMicMute() const { |
| 387 | auto result = [&]() -> ConversionResult<bool> { |
| 388 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 389 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 390 | mDelegate->getMicMute(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 391 | return aidlRet; |
| 392 | }(); |
| 393 | // Failure is ignored. |
| 394 | return result.value_or(false); |
| 395 | } |
| 396 | |
| 397 | void AudioFlingerClientAdapter::setRecordSilenced(audio_port_handle_t portId, bool silenced) { |
| 398 | auto result = [&]() -> status_t { |
| 399 | int32_t portIdAidl = VALUE_OR_RETURN_STATUS( |
| 400 | legacy2aidl_audio_port_handle_t_int32_t(portId)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 401 | return statusTFromBinderStatus(mDelegate->setRecordSilenced(portIdAidl, silenced)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 402 | }(); |
| 403 | // Failure is ignored. |
| 404 | (void) result; |
| 405 | } |
| 406 | |
| 407 | status_t AudioFlingerClientAdapter::setParameters(audio_io_handle_t ioHandle, |
| 408 | const String8& keyValuePairs) { |
| 409 | int32_t ioHandleAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 410 | std::string keyValuePairsAidl = VALUE_OR_RETURN_STATUS( |
| 411 | legacy2aidl_String8_string(keyValuePairs)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 412 | return statusTFromBinderStatus(mDelegate->setParameters(ioHandleAidl, keyValuePairsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | String8 AudioFlingerClientAdapter::getParameters(audio_io_handle_t ioHandle, const String8& keys) |
| 416 | const { |
| 417 | auto result = [&]() -> ConversionResult<String8> { |
| 418 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 419 | std::string keysAidl = VALUE_OR_RETURN(legacy2aidl_String8_string(keys)); |
| 420 | std::string aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 421 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 422 | mDelegate->getParameters(ioHandleAidl, keysAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 423 | return aidl2legacy_string_view_String8(aidlRet); |
| 424 | }(); |
| 425 | // Failure is ignored. |
| 426 | return result.value_or(String8()); |
| 427 | } |
| 428 | |
| 429 | void AudioFlingerClientAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 430 | mDelegate->registerClient(client); |
| 431 | // Failure is ignored. |
| 432 | } |
| 433 | |
| 434 | size_t AudioFlingerClientAdapter::getInputBufferSize(uint32_t sampleRate, audio_format_t format, |
| 435 | audio_channel_mask_t channelMask) const { |
| 436 | auto result = [&]() -> ConversionResult<size_t> { |
| 437 | int32_t sampleRateAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 438 | AudioFormatDescription formatAidl = VALUE_OR_RETURN( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 439 | legacy2aidl_audio_format_t_AudioFormatDescription(format)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 440 | AudioChannelLayout channelMaskAidl = VALUE_OR_RETURN( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 441 | legacy2aidl_audio_channel_mask_t_AudioChannelLayout(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 442 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 443 | RETURN_IF_ERROR(statusTFromBinderStatus( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 444 | mDelegate->getInputBufferSize(sampleRateAidl, formatAidl, channelMaskAidl, |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 445 | &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 446 | return convertIntegral<size_t>(aidlRet); |
| 447 | }(); |
| 448 | // Failure is ignored. |
| 449 | return result.value_or(0); |
| 450 | } |
| 451 | |
| 452 | status_t AudioFlingerClientAdapter::openOutput(const media::OpenOutputRequest& request, |
| 453 | media::OpenOutputResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 454 | return statusTFromBinderStatus(mDelegate->openOutput(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | audio_io_handle_t AudioFlingerClientAdapter::openDuplicateOutput(audio_io_handle_t output1, |
| 458 | audio_io_handle_t output2) { |
| 459 | auto result = [&]() -> ConversionResult<audio_io_handle_t> { |
| 460 | int32_t output1Aidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output1)); |
| 461 | int32_t output2Aidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output2)); |
| 462 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 463 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 464 | mDelegate->openDuplicateOutput(output1Aidl, output2Aidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 465 | return aidl2legacy_int32_t_audio_io_handle_t(aidlRet); |
| 466 | }(); |
| 467 | // Failure is ignored. |
| 468 | return result.value_or(0); |
| 469 | } |
| 470 | |
| 471 | status_t AudioFlingerClientAdapter::closeOutput(audio_io_handle_t output) { |
| 472 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 473 | return statusTFromBinderStatus(mDelegate->closeOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | status_t AudioFlingerClientAdapter::suspendOutput(audio_io_handle_t output) { |
| 477 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 478 | return statusTFromBinderStatus(mDelegate->suspendOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | status_t AudioFlingerClientAdapter::restoreOutput(audio_io_handle_t output) { |
| 482 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 483 | return statusTFromBinderStatus(mDelegate->restoreOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | status_t AudioFlingerClientAdapter::openInput(const media::OpenInputRequest& request, |
| 487 | media::OpenInputResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 488 | return statusTFromBinderStatus(mDelegate->openInput(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | status_t AudioFlingerClientAdapter::closeInput(audio_io_handle_t input) { |
| 492 | int32_t inputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(input)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 493 | return statusTFromBinderStatus(mDelegate->closeInput(inputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | status_t AudioFlingerClientAdapter::invalidateStream(audio_stream_type_t stream) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 497 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 498 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 499 | return statusTFromBinderStatus(mDelegate->invalidateStream(streamAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | status_t AudioFlingerClientAdapter::setVoiceVolume(float volume) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 503 | return statusTFromBinderStatus(mDelegate->setVoiceVolume(volume)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | status_t AudioFlingerClientAdapter::getRenderPosition(uint32_t* halFrames, uint32_t* dspFrames, |
| 507 | audio_io_handle_t output) const { |
| 508 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 509 | media::RenderPosition aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 510 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 511 | mDelegate->getRenderPosition(outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 512 | if (halFrames != nullptr) { |
| 513 | *halFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.halFrames)); |
| 514 | } |
| 515 | if (dspFrames != nullptr) { |
| 516 | *dspFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.dspFrames)); |
| 517 | } |
| 518 | return OK; |
| 519 | } |
| 520 | |
| 521 | uint32_t AudioFlingerClientAdapter::getInputFramesLost(audio_io_handle_t ioHandle) const { |
| 522 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 523 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 524 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 525 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 526 | mDelegate->getInputFramesLost(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 527 | return convertIntegral<uint32_t>(aidlRet); |
| 528 | }(); |
| 529 | // Failure is ignored. |
| 530 | return result.value_or(0); |
| 531 | } |
| 532 | |
| 533 | audio_unique_id_t AudioFlingerClientAdapter::newAudioUniqueId(audio_unique_id_use_t use) { |
| 534 | auto result = [&]() -> ConversionResult<audio_unique_id_t> { |
| 535 | media::AudioUniqueIdUse useAidl = VALUE_OR_RETURN( |
| 536 | legacy2aidl_audio_unique_id_use_t_AudioUniqueIdUse(use)); |
| 537 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 538 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 539 | mDelegate->newAudioUniqueId(useAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 540 | return aidl2legacy_int32_t_audio_unique_id_t(aidlRet); |
| 541 | }(); |
| 542 | return result.value_or(AUDIO_UNIQUE_ID_ALLOCATE); |
| 543 | } |
| 544 | |
| 545 | void AudioFlingerClientAdapter::acquireAudioSessionId(audio_session_t audioSession, pid_t pid, |
| 546 | uid_t uid) { |
| 547 | [&]() -> status_t { |
| 548 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 549 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 550 | int32_t pidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(pid)); |
| 551 | int32_t uidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(uid)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 552 | return statusTFromBinderStatus( |
| 553 | mDelegate->acquireAudioSessionId(audioSessionAidl, pidAidl, uidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 554 | }(); |
| 555 | // Failure is ignored. |
| 556 | } |
| 557 | |
| 558 | void AudioFlingerClientAdapter::releaseAudioSessionId(audio_session_t audioSession, pid_t pid) { |
| 559 | [&]() -> status_t { |
| 560 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 561 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 562 | int32_t pidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(pid)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 563 | return statusTFromBinderStatus( |
| 564 | mDelegate->releaseAudioSessionId(audioSessionAidl, pidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 565 | }(); |
| 566 | // Failure is ignored. |
| 567 | } |
| 568 | |
| 569 | status_t AudioFlingerClientAdapter::queryNumberEffects(uint32_t* numEffects) const { |
| 570 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 571 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 572 | mDelegate->queryNumberEffects(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 573 | if (numEffects != nullptr) { |
| 574 | *numEffects = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet)); |
| 575 | } |
| 576 | return OK; |
| 577 | } |
| 578 | |
| 579 | status_t |
| 580 | AudioFlingerClientAdapter::queryEffect(uint32_t index, effect_descriptor_t* pDescriptor) const { |
| 581 | int32_t indexAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(index)); |
| 582 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 583 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 584 | mDelegate->queryEffect(indexAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 585 | if (pDescriptor != nullptr) { |
| 586 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 587 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 588 | } |
| 589 | return OK; |
| 590 | } |
| 591 | |
| 592 | status_t AudioFlingerClientAdapter::getEffectDescriptor(const effect_uuid_t* pEffectUUID, |
| 593 | const effect_uuid_t* pTypeUUID, |
| 594 | uint32_t preferredTypeFlag, |
| 595 | effect_descriptor_t* pDescriptor) const { |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 596 | AudioUuid effectUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 597 | legacy2aidl_audio_uuid_t_AudioUuid(*pEffectUUID)); |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 598 | AudioUuid typeUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 599 | legacy2aidl_audio_uuid_t_AudioUuid(*pTypeUUID)); |
| 600 | int32_t preferredTypeFlagAidl = VALUE_OR_RETURN_STATUS( |
| 601 | convertReinterpret<int32_t>(preferredTypeFlag)); |
| 602 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 603 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 604 | mDelegate->getEffectDescriptor(effectUuidAidl, typeUuidAidl, preferredTypeFlagAidl, |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 605 | &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 606 | if (pDescriptor != nullptr) { |
| 607 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 608 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 609 | } |
| 610 | return OK; |
| 611 | } |
| 612 | |
| 613 | status_t AudioFlingerClientAdapter::createEffect(const media::CreateEffectRequest& request, |
| 614 | media::CreateEffectResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 615 | return statusTFromBinderStatus(mDelegate->createEffect(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | status_t |
| 619 | AudioFlingerClientAdapter::moveEffects(audio_session_t session, audio_io_handle_t srcOutput, |
| 620 | audio_io_handle_t dstOutput) { |
| 621 | int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session)); |
| 622 | int32_t srcOutputAidl = VALUE_OR_RETURN_STATUS( |
| 623 | legacy2aidl_audio_io_handle_t_int32_t(srcOutput)); |
| 624 | int32_t dstOutputAidl = VALUE_OR_RETURN_STATUS( |
| 625 | legacy2aidl_audio_io_handle_t_int32_t(dstOutput)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 626 | return statusTFromBinderStatus( |
| 627 | mDelegate->moveEffects(sessionAidl, srcOutputAidl, dstOutputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | void AudioFlingerClientAdapter::setEffectSuspended(int effectId, |
| 631 | audio_session_t sessionId, |
| 632 | bool suspended) { |
| 633 | [&]() -> status_t { |
| 634 | int32_t effectIdAidl = VALUE_OR_RETURN_STATUS(convertReinterpret<int32_t>(effectId)); |
| 635 | int32_t sessionIdAidl = VALUE_OR_RETURN_STATUS( |
| 636 | legacy2aidl_audio_session_t_int32_t(sessionId)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 637 | return statusTFromBinderStatus( |
| 638 | mDelegate->setEffectSuspended(effectIdAidl, sessionIdAidl, suspended)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 639 | }(); |
| 640 | // Failure is ignored. |
| 641 | } |
| 642 | |
| 643 | audio_module_handle_t AudioFlingerClientAdapter::loadHwModule(const char* name) { |
| 644 | auto result = [&]() -> ConversionResult<audio_module_handle_t> { |
| 645 | std::string nameAidl(name); |
| 646 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 647 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 648 | mDelegate->loadHwModule(nameAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 649 | return aidl2legacy_int32_t_audio_module_handle_t(aidlRet); |
| 650 | }(); |
| 651 | // Failure is ignored. |
| 652 | return result.value_or(0); |
| 653 | } |
| 654 | |
| 655 | uint32_t AudioFlingerClientAdapter::getPrimaryOutputSamplingRate() { |
| 656 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 657 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 658 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 659 | mDelegate->getPrimaryOutputSamplingRate(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 660 | return convertIntegral<uint32_t>(aidlRet); |
| 661 | }(); |
| 662 | // Failure is ignored. |
| 663 | return result.value_or(0); |
| 664 | } |
| 665 | |
| 666 | size_t AudioFlingerClientAdapter::getPrimaryOutputFrameCount() { |
| 667 | auto result = [&]() -> ConversionResult<size_t> { |
| 668 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 669 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 670 | mDelegate->getPrimaryOutputFrameCount(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 671 | return convertIntegral<size_t>(aidlRet); |
| 672 | }(); |
| 673 | // Failure is ignored. |
| 674 | return result.value_or(0); |
| 675 | } |
| 676 | |
| 677 | status_t AudioFlingerClientAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 678 | return statusTFromBinderStatus(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | status_t AudioFlingerClientAdapter::getAudioPort(struct audio_port_v7* port) { |
| 682 | media::AudioPort portAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_v7_AudioPort(*port)); |
| 683 | media::AudioPort aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 684 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 685 | mDelegate->getAudioPort(portAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 686 | *port = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPort_audio_port_v7(aidlRet)); |
| 687 | return OK; |
| 688 | } |
| 689 | |
| 690 | status_t AudioFlingerClientAdapter::createAudioPatch(const struct audio_patch* patch, |
| 691 | audio_patch_handle_t* handle) { |
| 692 | media::AudioPatch patchAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_AudioPatch(*patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 693 | int32_t aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t( |
| 694 | AUDIO_PATCH_HANDLE_NONE)); |
| 695 | if (handle != nullptr) { |
| 696 | aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t(*handle)); |
| 697 | } |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 698 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 699 | mDelegate->createAudioPatch(patchAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 700 | if (handle != nullptr) { |
| 701 | *handle = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_patch_handle_t(aidlRet)); |
| 702 | } |
| 703 | return OK; |
| 704 | } |
| 705 | |
| 706 | status_t AudioFlingerClientAdapter::releaseAudioPatch(audio_patch_handle_t handle) { |
| 707 | int32_t handleAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t(handle)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 708 | return statusTFromBinderStatus(mDelegate->releaseAudioPatch(handleAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | status_t AudioFlingerClientAdapter::listAudioPatches(unsigned int* num_patches, |
| 712 | struct audio_patch* patches) { |
| 713 | std::vector<media::AudioPatch> aidlRet; |
| 714 | int32_t maxPatches = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*num_patches)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 715 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 716 | mDelegate->listAudioPatches(maxPatches, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 717 | *num_patches = VALUE_OR_RETURN_STATUS(convertIntegral<unsigned int>(aidlRet.size())); |
| 718 | return convertRange(aidlRet.begin(), aidlRet.end(), patches, |
| 719 | aidl2legacy_AudioPatch_audio_patch); |
| 720 | } |
| 721 | |
| 722 | status_t AudioFlingerClientAdapter::setAudioPortConfig(const struct audio_port_config* config) { |
| 723 | media::AudioPortConfig configAidl = VALUE_OR_RETURN_STATUS( |
| 724 | legacy2aidl_audio_port_config_AudioPortConfig(*config)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 725 | return statusTFromBinderStatus(mDelegate->setAudioPortConfig(configAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | audio_hw_sync_t AudioFlingerClientAdapter::getAudioHwSyncForSession(audio_session_t sessionId) { |
| 729 | auto result = [&]() -> ConversionResult<audio_hw_sync_t> { |
| 730 | int32_t sessionIdAidl = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 731 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 732 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 733 | mDelegate->getAudioHwSyncForSession(sessionIdAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 734 | return aidl2legacy_int32_t_audio_hw_sync_t(aidlRet); |
| 735 | }(); |
| 736 | return result.value_or(AUDIO_HW_SYNC_INVALID); |
| 737 | } |
| 738 | |
| 739 | status_t AudioFlingerClientAdapter::systemReady() { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 740 | return statusTFromBinderStatus(mDelegate->systemReady()); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 741 | } |
| 742 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 743 | status_t AudioFlingerClientAdapter::audioPolicyReady() { |
| 744 | return statusTFromBinderStatus(mDelegate->audioPolicyReady()); |
| 745 | } |
| 746 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 747 | size_t AudioFlingerClientAdapter::frameCountHAL(audio_io_handle_t ioHandle) const { |
| 748 | auto result = [&]() -> ConversionResult<size_t> { |
| 749 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 750 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 751 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 752 | mDelegate->frameCountHAL(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 753 | return convertIntegral<size_t>(aidlRet); |
| 754 | }(); |
| 755 | // Failure is ignored. |
| 756 | return result.value_or(0); |
| 757 | } |
| 758 | |
| 759 | status_t |
| 760 | AudioFlingerClientAdapter::getMicrophones(std::vector<media::MicrophoneInfo>* microphones) { |
| 761 | std::vector<media::MicrophoneInfoData> aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 762 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 763 | mDelegate->getMicrophones(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 764 | if (microphones != nullptr) { |
| 765 | *microphones = VALUE_OR_RETURN_STATUS( |
| 766 | convertContainer<std::vector<media::MicrophoneInfo>>(aidlRet, |
| 767 | media::aidl2legacy_MicrophoneInfo)); |
| 768 | } |
| 769 | return OK; |
| 770 | } |
| 771 | |
| 772 | status_t AudioFlingerClientAdapter::setAudioHalPids(const std::vector<pid_t>& pids) { |
| 773 | std::vector<int32_t> pidsAidl = VALUE_OR_RETURN_STATUS( |
| 774 | convertContainer<std::vector<int32_t>>(pids, legacy2aidl_pid_t_int32_t)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 775 | return statusTFromBinderStatus(mDelegate->setAudioHalPids(pidsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 776 | } |
| 777 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 778 | status_t AudioFlingerClientAdapter::setVibratorInfos( |
| 779 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 780 | return statusTFromBinderStatus(mDelegate->setVibratorInfos(vibratorInfos)); |
| 781 | } |
| 782 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 783 | status_t AudioFlingerClientAdapter::updateSecondaryOutputs( |
| 784 | const TrackSecondaryOutputsMap& trackSecondaryOutputs) { |
| 785 | std::vector<media::TrackSecondaryOutputInfo> trackSecondaryOutputInfos = |
| 786 | VALUE_OR_RETURN_STATUS( |
| 787 | convertContainer<std::vector<media::TrackSecondaryOutputInfo>>( |
| 788 | trackSecondaryOutputs, |
| 789 | legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo)); |
| 790 | return statusTFromBinderStatus(mDelegate->updateSecondaryOutputs(trackSecondaryOutputInfos)); |
| 791 | } |
| 792 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 793 | status_t AudioFlingerClientAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 794 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *policyInfos) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 795 | return statusTFromBinderStatus(mDelegate->getMmapPolicyInfos(policyType, policyInfos)); |
| 796 | } |
| 797 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 798 | int32_t AudioFlingerClientAdapter::getAAudioMixerBurstCount() { |
| 799 | auto result = [&]() -> ConversionResult<int32_t> { |
| 800 | int32_t aidlRet; |
| 801 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->getAAudioMixerBurstCount(&aidlRet))); |
| 802 | return convertIntegral<int32_t>(aidlRet); |
| 803 | }(); |
| 804 | // Failure is ignored. |
| 805 | return result.value_or(0); |
| 806 | } |
| 807 | |
| 808 | int32_t AudioFlingerClientAdapter::getAAudioHardwareBurstMinUsec() { |
| 809 | auto result = [&]() -> ConversionResult<int32_t> { |
| 810 | int32_t aidlRet; |
| 811 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 812 | mDelegate->getAAudioHardwareBurstMinUsec(&aidlRet))); |
| 813 | return convertIntegral<int32_t>(aidlRet); |
| 814 | }(); |
| 815 | // Failure is ignored. |
| 816 | return result.value_or(0); |
| 817 | } |
| 818 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 819 | status_t AudioFlingerClientAdapter::setDeviceConnectedState( |
| 820 | const struct audio_port_v7 *port, bool connected) { |
| 821 | media::AudioPort aidlPort = VALUE_OR_RETURN_STATUS( |
| 822 | legacy2aidl_audio_port_v7_AudioPort(*port)); |
| 823 | return statusTFromBinderStatus(mDelegate->setDeviceConnectedState(aidlPort, connected)); |
| 824 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 825 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 826 | status_t AudioFlingerClientAdapter::setRequestedLatencyMode( |
| 827 | audio_io_handle_t output, audio_latency_mode_t mode) { |
| 828 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 829 | media::LatencyMode modeAidl = VALUE_OR_RETURN_STATUS( |
| 830 | legacy2aidl_audio_latency_mode_t_LatencyMode(mode)); |
| 831 | return statusTFromBinderStatus(mDelegate->setRequestedLatencyMode(outputAidl, modeAidl)); |
| 832 | } |
| 833 | |
| 834 | status_t AudioFlingerClientAdapter::getSupportedLatencyModes( |
| 835 | audio_io_handle_t output, std::vector<audio_latency_mode_t>* modes) { |
| 836 | if (modes == nullptr) { |
| 837 | return BAD_VALUE; |
| 838 | } |
| 839 | |
| 840 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 841 | std::vector<media::LatencyMode> modesAidl; |
| 842 | |
| 843 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 844 | mDelegate->getSupportedLatencyModes(outputAidl, &modesAidl))); |
| 845 | |
| 846 | *modes = VALUE_OR_RETURN_STATUS( |
| 847 | convertContainer<std::vector<audio_latency_mode_t>>(modesAidl, |
| 848 | aidl2legacy_LatencyMode_audio_latency_mode_t)); |
| 849 | |
| 850 | return NO_ERROR; |
| 851 | } |
| 852 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 853 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 854 | // AudioFlingerServerAdapter |
| 855 | AudioFlingerServerAdapter::AudioFlingerServerAdapter( |
| 856 | const sp<AudioFlingerServerAdapter::Delegate>& delegate) : mDelegate(delegate) {} |
| 857 | |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 858 | status_t AudioFlingerServerAdapter::onTransact(uint32_t code, |
| 859 | const Parcel& data, |
| 860 | Parcel* reply, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 861 | uint32_t flags) { |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 862 | return mDelegate->onTransactWrapper(static_cast<Delegate::TransactionCode>(code), |
| 863 | data, |
| 864 | flags, |
| 865 | [&] { |
| 866 | return BnAudioFlingerService::onTransact( |
| 867 | code, |
| 868 | data, |
| 869 | reply, |
| 870 | flags); |
| 871 | }); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | status_t AudioFlingerServerAdapter::dump(int fd, const Vector<String16>& args) { |
| 875 | return mDelegate->dump(fd, args); |
| 876 | } |
| 877 | |
| 878 | Status AudioFlingerServerAdapter::createTrack(const media::CreateTrackRequest& request, |
| 879 | media::CreateTrackResponse* _aidl_return) { |
| 880 | return Status::fromStatusT(mDelegate->createTrack(request, *_aidl_return)); |
| 881 | } |
| 882 | |
| 883 | Status AudioFlingerServerAdapter::createRecord(const media::CreateRecordRequest& request, |
| 884 | media::CreateRecordResponse* _aidl_return) { |
| 885 | return Status::fromStatusT(mDelegate->createRecord(request, *_aidl_return)); |
| 886 | } |
| 887 | |
| 888 | Status AudioFlingerServerAdapter::sampleRate(int32_t ioHandle, int32_t* _aidl_return) { |
| 889 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 890 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 891 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 892 | convertIntegral<int32_t>(mDelegate->sampleRate(ioHandleLegacy))); |
| 893 | return Status::ok(); |
| 894 | } |
| 895 | |
| 896 | Status AudioFlingerServerAdapter::format(int32_t output, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 897 | AudioFormatDescription* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 898 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 899 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 900 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 901 | legacy2aidl_audio_format_t_AudioFormatDescription(mDelegate->format(outputLegacy))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 902 | return Status::ok(); |
| 903 | } |
| 904 | |
| 905 | Status AudioFlingerServerAdapter::frameCount(int32_t ioHandle, int64_t* _aidl_return) { |
| 906 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 907 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 908 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 909 | convertIntegral<int64_t>(mDelegate->frameCount(ioHandleLegacy))); |
| 910 | return Status::ok(); |
| 911 | } |
| 912 | |
| 913 | Status AudioFlingerServerAdapter::latency(int32_t output, int32_t* _aidl_return) { |
| 914 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 915 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 916 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 917 | convertIntegral<int32_t>(mDelegate->latency(outputLegacy))); |
| 918 | return Status::ok(); |
| 919 | } |
| 920 | |
| 921 | Status AudioFlingerServerAdapter::setMasterVolume(float value) { |
| 922 | return Status::fromStatusT(mDelegate->setMasterVolume(value)); |
| 923 | } |
| 924 | |
| 925 | Status AudioFlingerServerAdapter::setMasterMute(bool muted) { |
| 926 | return Status::fromStatusT(mDelegate->setMasterMute(muted)); |
| 927 | } |
| 928 | |
| 929 | Status AudioFlingerServerAdapter::masterVolume(float* _aidl_return) { |
| 930 | *_aidl_return = mDelegate->masterVolume(); |
| 931 | return Status::ok(); |
| 932 | } |
| 933 | |
| 934 | Status AudioFlingerServerAdapter::masterMute(bool* _aidl_return) { |
| 935 | *_aidl_return = mDelegate->masterMute(); |
| 936 | return Status::ok(); |
| 937 | } |
| 938 | |
| 939 | Status AudioFlingerServerAdapter::setMasterBalance(float balance) { |
| 940 | return Status::fromStatusT(mDelegate->setMasterBalance(balance)); |
| 941 | } |
| 942 | |
| 943 | Status AudioFlingerServerAdapter::getMasterBalance(float* _aidl_return) { |
| 944 | return Status::fromStatusT(mDelegate->getMasterBalance(_aidl_return)); |
| 945 | } |
| 946 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 947 | Status AudioFlingerServerAdapter::setStreamVolume(AudioStreamType stream, float value, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 948 | int32_t output) { |
| 949 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 950 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 951 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 952 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 953 | return Status::fromStatusT(mDelegate->setStreamVolume(streamLegacy, value, outputLegacy)); |
| 954 | } |
| 955 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 956 | Status AudioFlingerServerAdapter::setStreamMute(AudioStreamType stream, bool muted) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 957 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 958 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 959 | return Status::fromStatusT(mDelegate->setStreamMute(streamLegacy, muted)); |
| 960 | } |
| 961 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 962 | Status AudioFlingerServerAdapter::streamVolume(AudioStreamType stream, int32_t output, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 963 | float* _aidl_return) { |
| 964 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 965 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 966 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 967 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 968 | *_aidl_return = mDelegate->streamVolume(streamLegacy, outputLegacy); |
| 969 | return Status::ok(); |
| 970 | } |
| 971 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 972 | Status AudioFlingerServerAdapter::streamMute(AudioStreamType stream, bool* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 973 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 974 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 975 | *_aidl_return = mDelegate->streamMute(streamLegacy); |
| 976 | return Status::ok(); |
| 977 | } |
| 978 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 979 | Status AudioFlingerServerAdapter::setMode(AudioMode mode) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 980 | audio_mode_t modeLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioMode_audio_mode_t(mode)); |
| 981 | return Status::fromStatusT(mDelegate->setMode(modeLegacy)); |
| 982 | } |
| 983 | |
| 984 | Status AudioFlingerServerAdapter::setMicMute(bool state) { |
| 985 | return Status::fromStatusT(mDelegate->setMicMute(state)); |
| 986 | } |
| 987 | |
| 988 | Status AudioFlingerServerAdapter::getMicMute(bool* _aidl_return) { |
| 989 | *_aidl_return = mDelegate->getMicMute(); |
| 990 | return Status::ok(); |
| 991 | } |
| 992 | |
| 993 | Status AudioFlingerServerAdapter::setRecordSilenced(int32_t portId, bool silenced) { |
| 994 | audio_port_handle_t portIdLegacy = VALUE_OR_RETURN_BINDER( |
| 995 | aidl2legacy_int32_t_audio_port_handle_t(portId)); |
| 996 | mDelegate->setRecordSilenced(portIdLegacy, silenced); |
| 997 | return Status::ok(); |
| 998 | } |
| 999 | |
| 1000 | Status |
| 1001 | AudioFlingerServerAdapter::setParameters(int32_t ioHandle, const std::string& keyValuePairs) { |
| 1002 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1003 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1004 | String8 keyValuePairsLegacy = VALUE_OR_RETURN_BINDER( |
| 1005 | aidl2legacy_string_view_String8(keyValuePairs)); |
| 1006 | return Status::fromStatusT(mDelegate->setParameters(ioHandleLegacy, keyValuePairsLegacy)); |
| 1007 | } |
| 1008 | |
| 1009 | Status AudioFlingerServerAdapter::getParameters(int32_t ioHandle, const std::string& keys, |
| 1010 | std::string* _aidl_return) { |
| 1011 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1012 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1013 | String8 keysLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_string_view_String8(keys)); |
| 1014 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1015 | legacy2aidl_String8_string(mDelegate->getParameters(ioHandleLegacy, keysLegacy))); |
| 1016 | return Status::ok(); |
| 1017 | } |
| 1018 | |
| 1019 | Status AudioFlingerServerAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 1020 | mDelegate->registerClient(client); |
| 1021 | return Status::ok(); |
| 1022 | } |
| 1023 | |
| 1024 | Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 1025 | const AudioFormatDescription& format, |
| 1026 | const AudioChannelLayout& channelMask, |
Mikhail Naganov | 2d8df4e | 2021-06-03 13:59:13 -0700 | [diff] [blame] | 1027 | int64_t* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1028 | uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate)); |
| 1029 | audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 1030 | aidl2legacy_AudioFormatDescription_audio_format_t(format)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1031 | audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 1032 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1033 | size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy); |
| 1034 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size)); |
| 1035 | return Status::ok(); |
| 1036 | } |
| 1037 | |
| 1038 | Status AudioFlingerServerAdapter::openOutput(const media::OpenOutputRequest& request, |
| 1039 | media::OpenOutputResponse* _aidl_return) { |
| 1040 | return Status::fromStatusT(mDelegate->openOutput(request, _aidl_return)); |
| 1041 | } |
| 1042 | |
| 1043 | Status AudioFlingerServerAdapter::openDuplicateOutput(int32_t output1, int32_t output2, |
| 1044 | int32_t* _aidl_return) { |
| 1045 | audio_io_handle_t output1Legacy = VALUE_OR_RETURN_BINDER( |
| 1046 | aidl2legacy_int32_t_audio_io_handle_t(output1)); |
| 1047 | audio_io_handle_t output2Legacy = VALUE_OR_RETURN_BINDER( |
| 1048 | aidl2legacy_int32_t_audio_io_handle_t(output2)); |
| 1049 | audio_io_handle_t result = mDelegate->openDuplicateOutput(output1Legacy, output2Legacy); |
| 1050 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_io_handle_t_int32_t(result)); |
| 1051 | return Status::ok(); |
| 1052 | } |
| 1053 | |
| 1054 | Status AudioFlingerServerAdapter::closeOutput(int32_t output) { |
| 1055 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1056 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1057 | return Status::fromStatusT(mDelegate->closeOutput(outputLegacy)); |
| 1058 | } |
| 1059 | |
| 1060 | Status AudioFlingerServerAdapter::suspendOutput(int32_t output) { |
| 1061 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1062 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1063 | return Status::fromStatusT(mDelegate->suspendOutput(outputLegacy)); |
| 1064 | } |
| 1065 | |
| 1066 | Status AudioFlingerServerAdapter::restoreOutput(int32_t output) { |
| 1067 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1068 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1069 | return Status::fromStatusT(mDelegate->restoreOutput(outputLegacy)); |
| 1070 | } |
| 1071 | |
| 1072 | Status AudioFlingerServerAdapter::openInput(const media::OpenInputRequest& request, |
| 1073 | media::OpenInputResponse* _aidl_return) { |
| 1074 | return Status::fromStatusT(mDelegate->openInput(request, _aidl_return)); |
| 1075 | } |
| 1076 | |
| 1077 | Status AudioFlingerServerAdapter::closeInput(int32_t input) { |
| 1078 | audio_io_handle_t inputLegacy = VALUE_OR_RETURN_BINDER( |
| 1079 | aidl2legacy_int32_t_audio_io_handle_t(input)); |
| 1080 | return Status::fromStatusT(mDelegate->closeInput(inputLegacy)); |
| 1081 | } |
| 1082 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1083 | Status AudioFlingerServerAdapter::invalidateStream(AudioStreamType stream) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1084 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1085 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1086 | return Status::fromStatusT(mDelegate->invalidateStream(streamLegacy)); |
| 1087 | } |
| 1088 | |
| 1089 | Status AudioFlingerServerAdapter::setVoiceVolume(float volume) { |
| 1090 | return Status::fromStatusT(mDelegate->setVoiceVolume(volume)); |
| 1091 | } |
| 1092 | |
| 1093 | Status |
| 1094 | AudioFlingerServerAdapter::getRenderPosition(int32_t output, media::RenderPosition* _aidl_return) { |
| 1095 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1096 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1097 | uint32_t halFramesLegacy; |
| 1098 | uint32_t dspFramesLegacy; |
| 1099 | RETURN_BINDER_IF_ERROR( |
| 1100 | mDelegate->getRenderPosition(&halFramesLegacy, &dspFramesLegacy, outputLegacy)); |
| 1101 | _aidl_return->halFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(halFramesLegacy)); |
| 1102 | _aidl_return->dspFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(dspFramesLegacy)); |
| 1103 | return Status::ok(); |
| 1104 | } |
| 1105 | |
| 1106 | Status AudioFlingerServerAdapter::getInputFramesLost(int32_t ioHandle, int32_t* _aidl_return) { |
| 1107 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1108 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1109 | uint32_t result = mDelegate->getInputFramesLost(ioHandleLegacy); |
| 1110 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(result)); |
| 1111 | return Status::ok(); |
| 1112 | } |
| 1113 | |
| 1114 | Status |
| 1115 | AudioFlingerServerAdapter::newAudioUniqueId(media::AudioUniqueIdUse use, int32_t* _aidl_return) { |
| 1116 | audio_unique_id_use_t useLegacy = VALUE_OR_RETURN_BINDER( |
| 1117 | aidl2legacy_AudioUniqueIdUse_audio_unique_id_use_t(use)); |
| 1118 | audio_unique_id_t result = mDelegate->newAudioUniqueId(useLegacy); |
| 1119 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_unique_id_t_int32_t(result)); |
| 1120 | return Status::ok(); |
| 1121 | } |
| 1122 | |
| 1123 | Status |
| 1124 | AudioFlingerServerAdapter::acquireAudioSessionId(int32_t audioSession, int32_t pid, int32_t uid) { |
| 1125 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1126 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1127 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1128 | uid_t uidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_uid_t(uid)); |
| 1129 | mDelegate->acquireAudioSessionId(audioSessionLegacy, pidLegacy, uidLegacy); |
| 1130 | return Status::ok(); |
| 1131 | } |
| 1132 | |
| 1133 | Status AudioFlingerServerAdapter::releaseAudioSessionId(int32_t audioSession, int32_t pid) { |
| 1134 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1135 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1136 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1137 | mDelegate->releaseAudioSessionId(audioSessionLegacy, pidLegacy); |
| 1138 | return Status::ok(); |
| 1139 | } |
| 1140 | |
| 1141 | Status AudioFlingerServerAdapter::queryNumberEffects(int32_t* _aidl_return) { |
| 1142 | uint32_t result; |
| 1143 | RETURN_BINDER_IF_ERROR(mDelegate->queryNumberEffects(&result)); |
| 1144 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(result)); |
| 1145 | return Status::ok(); |
| 1146 | } |
| 1147 | |
| 1148 | Status |
| 1149 | AudioFlingerServerAdapter::queryEffect(int32_t index, media::EffectDescriptor* _aidl_return) { |
| 1150 | uint32_t indexLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(index)); |
| 1151 | effect_descriptor_t result; |
| 1152 | RETURN_BINDER_IF_ERROR(mDelegate->queryEffect(indexLegacy, &result)); |
| 1153 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1154 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1155 | return Status::ok(); |
| 1156 | } |
| 1157 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1158 | Status AudioFlingerServerAdapter::getEffectDescriptor(const AudioUuid& effectUUID, |
| 1159 | const AudioUuid& typeUUID, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1160 | int32_t preferredTypeFlag, |
| 1161 | media::EffectDescriptor* _aidl_return) { |
| 1162 | effect_uuid_t effectUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1163 | aidl2legacy_AudioUuid_audio_uuid_t(effectUUID)); |
| 1164 | effect_uuid_t typeUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1165 | aidl2legacy_AudioUuid_audio_uuid_t(typeUUID)); |
| 1166 | uint32_t preferredTypeFlagLegacy = VALUE_OR_RETURN_BINDER( |
| 1167 | convertReinterpret<uint32_t>(preferredTypeFlag)); |
| 1168 | effect_descriptor_t result; |
| 1169 | RETURN_BINDER_IF_ERROR(mDelegate->getEffectDescriptor(&effectUuidLegacy, &typeUuidLegacy, |
| 1170 | preferredTypeFlagLegacy, &result)); |
| 1171 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1172 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1173 | return Status::ok(); |
| 1174 | } |
| 1175 | |
| 1176 | Status AudioFlingerServerAdapter::createEffect(const media::CreateEffectRequest& request, |
| 1177 | media::CreateEffectResponse* _aidl_return) { |
| 1178 | return Status::fromStatusT(mDelegate->createEffect(request, _aidl_return)); |
| 1179 | } |
| 1180 | |
| 1181 | Status |
| 1182 | AudioFlingerServerAdapter::moveEffects(int32_t session, int32_t srcOutput, int32_t dstOutput) { |
| 1183 | audio_session_t sessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1184 | aidl2legacy_int32_t_audio_session_t(session)); |
| 1185 | audio_io_handle_t srcOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1186 | aidl2legacy_int32_t_audio_io_handle_t(srcOutput)); |
| 1187 | audio_io_handle_t dstOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1188 | aidl2legacy_int32_t_audio_io_handle_t(dstOutput)); |
| 1189 | return Status::fromStatusT( |
| 1190 | mDelegate->moveEffects(sessionLegacy, srcOutputLegacy, dstOutputLegacy)); |
| 1191 | } |
| 1192 | |
| 1193 | Status AudioFlingerServerAdapter::setEffectSuspended(int32_t effectId, int32_t sessionId, |
| 1194 | bool suspended) { |
| 1195 | int effectIdLegacy = VALUE_OR_RETURN_BINDER(convertReinterpret<int>(effectId)); |
| 1196 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1197 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1198 | mDelegate->setEffectSuspended(effectIdLegacy, sessionIdLegacy, suspended); |
| 1199 | return Status::ok(); |
| 1200 | } |
| 1201 | |
| 1202 | Status AudioFlingerServerAdapter::loadHwModule(const std::string& name, int32_t* _aidl_return) { |
| 1203 | audio_module_handle_t result = mDelegate->loadHwModule(name.c_str()); |
| 1204 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_module_handle_t_int32_t(result)); |
| 1205 | return Status::ok(); |
| 1206 | } |
| 1207 | |
| 1208 | Status AudioFlingerServerAdapter::getPrimaryOutputSamplingRate(int32_t* _aidl_return) { |
| 1209 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1210 | convertIntegral<int32_t>(mDelegate->getPrimaryOutputSamplingRate())); |
| 1211 | return Status::ok(); |
| 1212 | } |
| 1213 | |
| 1214 | Status AudioFlingerServerAdapter::getPrimaryOutputFrameCount(int64_t* _aidl_return) { |
| 1215 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1216 | convertIntegral<int64_t>(mDelegate->getPrimaryOutputFrameCount())); |
| 1217 | return Status::ok(); |
| 1218 | |
| 1219 | } |
| 1220 | |
| 1221 | Status AudioFlingerServerAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
| 1222 | return Status::fromStatusT(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
| 1223 | } |
| 1224 | |
| 1225 | Status AudioFlingerServerAdapter::getAudioPort(const media::AudioPort& port, |
| 1226 | media::AudioPort* _aidl_return) { |
| 1227 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPort_audio_port_v7(port)); |
| 1228 | RETURN_BINDER_IF_ERROR(mDelegate->getAudioPort(&portLegacy)); |
| 1229 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_port_v7_AudioPort(portLegacy)); |
| 1230 | return Status::ok(); |
| 1231 | } |
| 1232 | |
| 1233 | Status AudioFlingerServerAdapter::createAudioPatch(const media::AudioPatch& patch, |
| 1234 | int32_t* _aidl_return) { |
| 1235 | audio_patch patchLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPatch_audio_patch(patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 1236 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1237 | aidl2legacy_int32_t_audio_patch_handle_t(*_aidl_return)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1238 | RETURN_BINDER_IF_ERROR(mDelegate->createAudioPatch(&patchLegacy, &handleLegacy)); |
| 1239 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_patch_handle_t_int32_t(handleLegacy)); |
| 1240 | return Status::ok(); |
| 1241 | } |
| 1242 | |
| 1243 | Status AudioFlingerServerAdapter::releaseAudioPatch(int32_t handle) { |
| 1244 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1245 | aidl2legacy_int32_t_audio_patch_handle_t(handle)); |
| 1246 | return Status::fromStatusT(mDelegate->releaseAudioPatch(handleLegacy)); |
| 1247 | } |
| 1248 | |
| 1249 | Status AudioFlingerServerAdapter::listAudioPatches(int32_t maxCount, |
| 1250 | std::vector<media::AudioPatch>* _aidl_return) { |
| 1251 | unsigned int count = VALUE_OR_RETURN_BINDER(convertIntegral<unsigned int>(maxCount)); |
| 1252 | count = std::min(count, static_cast<unsigned int>(MAX_ITEMS_PER_LIST)); |
| 1253 | std::unique_ptr<audio_patch[]> patchesLegacy(new audio_patch[count]); |
| 1254 | RETURN_BINDER_IF_ERROR(mDelegate->listAudioPatches(&count, patchesLegacy.get())); |
| 1255 | RETURN_BINDER_IF_ERROR(convertRange(&patchesLegacy[0], |
| 1256 | &patchesLegacy[count], |
| 1257 | std::back_inserter(*_aidl_return), |
| 1258 | legacy2aidl_audio_patch_AudioPatch)); |
| 1259 | return Status::ok(); |
| 1260 | } |
| 1261 | |
| 1262 | Status AudioFlingerServerAdapter::setAudioPortConfig(const media::AudioPortConfig& config) { |
| 1263 | audio_port_config configLegacy = VALUE_OR_RETURN_BINDER( |
| 1264 | aidl2legacy_AudioPortConfig_audio_port_config(config)); |
| 1265 | return Status::fromStatusT(mDelegate->setAudioPortConfig(&configLegacy)); |
| 1266 | } |
| 1267 | |
| 1268 | Status AudioFlingerServerAdapter::getAudioHwSyncForSession(int32_t sessionId, |
| 1269 | int32_t* _aidl_return) { |
| 1270 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1271 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1272 | audio_hw_sync_t result = mDelegate->getAudioHwSyncForSession(sessionIdLegacy); |
| 1273 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_hw_sync_t_int32_t(result)); |
| 1274 | return Status::ok(); |
| 1275 | } |
| 1276 | |
| 1277 | Status AudioFlingerServerAdapter::systemReady() { |
| 1278 | return Status::fromStatusT(mDelegate->systemReady()); |
| 1279 | } |
| 1280 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 1281 | Status AudioFlingerServerAdapter::audioPolicyReady() { |
| 1282 | mDelegate->audioPolicyReady(); |
| 1283 | return Status::ok(); |
| 1284 | } |
| 1285 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1286 | Status AudioFlingerServerAdapter::frameCountHAL(int32_t ioHandle, int64_t* _aidl_return) { |
| 1287 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1288 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1289 | size_t result = mDelegate->frameCountHAL(ioHandleLegacy); |
| 1290 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(result)); |
| 1291 | return Status::ok(); |
| 1292 | } |
| 1293 | |
| 1294 | Status AudioFlingerServerAdapter::getMicrophones( |
| 1295 | std::vector<media::MicrophoneInfoData>* _aidl_return) { |
| 1296 | std::vector<media::MicrophoneInfo> resultLegacy; |
| 1297 | RETURN_BINDER_IF_ERROR(mDelegate->getMicrophones(&resultLegacy)); |
| 1298 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertContainer<std::vector<media::MicrophoneInfoData>>( |
| 1299 | resultLegacy, media::legacy2aidl_MicrophoneInfo)); |
| 1300 | return Status::ok(); |
| 1301 | } |
| 1302 | |
| 1303 | Status AudioFlingerServerAdapter::setAudioHalPids(const std::vector<int32_t>& pids) { |
| 1304 | std::vector<pid_t> pidsLegacy = VALUE_OR_RETURN_BINDER( |
| 1305 | convertContainer<std::vector<pid_t>>(pids, aidl2legacy_int32_t_pid_t)); |
| 1306 | RETURN_BINDER_IF_ERROR(mDelegate->setAudioHalPids(pidsLegacy)); |
| 1307 | return Status::ok(); |
| 1308 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1309 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 1310 | Status AudioFlingerServerAdapter::setVibratorInfos( |
| 1311 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 1312 | return Status::fromStatusT(mDelegate->setVibratorInfos(vibratorInfos)); |
| 1313 | } |
| 1314 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 1315 | Status AudioFlingerServerAdapter::updateSecondaryOutputs( |
| 1316 | const std::vector<media::TrackSecondaryOutputInfo>& trackSecondaryOutputInfos) { |
| 1317 | TrackSecondaryOutputsMap trackSecondaryOutputs = |
| 1318 | VALUE_OR_RETURN_BINDER(convertContainer<TrackSecondaryOutputsMap>( |
| 1319 | trackSecondaryOutputInfos, |
| 1320 | aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair)); |
| 1321 | return Status::fromStatusT(mDelegate->updateSecondaryOutputs(trackSecondaryOutputs)); |
| 1322 | } |
| 1323 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1324 | Status AudioFlingerServerAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 1325 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *_aidl_return) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1326 | return Status::fromStatusT(mDelegate->getMmapPolicyInfos(policyType, _aidl_return)); |
| 1327 | } |
| 1328 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 1329 | Status AudioFlingerServerAdapter::getAAudioMixerBurstCount(int32_t* _aidl_return) { |
| 1330 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1331 | convertIntegral<int32_t>(mDelegate->getAAudioMixerBurstCount())); |
| 1332 | return Status::ok(); |
| 1333 | } |
| 1334 | |
| 1335 | Status AudioFlingerServerAdapter::getAAudioHardwareBurstMinUsec(int32_t* _aidl_return) { |
| 1336 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1337 | convertIntegral<int32_t>(mDelegate->getAAudioHardwareBurstMinUsec())); |
| 1338 | return Status::ok(); |
| 1339 | } |
| 1340 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1341 | Status AudioFlingerServerAdapter::setDeviceConnectedState( |
| 1342 | const media::AudioPort& port, bool connected) { |
| 1343 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPort_audio_port_v7(port)); |
| 1344 | return Status::fromStatusT(mDelegate->setDeviceConnectedState(&portLegacy, connected)); |
| 1345 | } |
| 1346 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1347 | Status AudioFlingerServerAdapter::setRequestedLatencyMode( |
| 1348 | int32_t output, media::LatencyMode modeAidl) { |
| 1349 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1350 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1351 | audio_latency_mode_t modeLegacy = VALUE_OR_RETURN_BINDER( |
| 1352 | aidl2legacy_LatencyMode_audio_latency_mode_t(modeAidl)); |
| 1353 | return Status::fromStatusT(mDelegate->setRequestedLatencyMode( |
| 1354 | outputLegacy, modeLegacy)); |
| 1355 | } |
| 1356 | |
| 1357 | Status AudioFlingerServerAdapter::getSupportedLatencyModes( |
| 1358 | int output, std::vector<media::LatencyMode>* _aidl_return) { |
| 1359 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1360 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1361 | std::vector<audio_latency_mode_t> modesLegacy; |
| 1362 | |
| 1363 | RETURN_BINDER_IF_ERROR(mDelegate->getSupportedLatencyModes(outputLegacy, &modesLegacy)); |
| 1364 | |
| 1365 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1366 | convertContainer<std::vector<media::LatencyMode>>( |
| 1367 | modesLegacy, legacy2aidl_audio_latency_mode_t_LatencyMode)); |
| 1368 | return Status::ok(); |
| 1369 | } |
| 1370 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1371 | } // namespace android |