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> |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 25 | #include "IAudioFlinger.h" |
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> |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 28 | #include <system/thread_defs.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; |
Mikhail Naganov | 1c40090 | 2023-05-17 11:48:43 -0700 | [diff] [blame] | 59 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributes(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; |
Mikhail Naganov | 1c40090 | 2023-05-17 11:48:43 -0700 | [diff] [blame] | 80 | legacy.attr = VALUE_OR_RETURN(aidl2legacy_AudioAttributes_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)); |
jiabin | 94ed47c | 2023-07-27 23:34:20 +0000 | [diff] [blame] | 119 | aidl.afTrackFlags = VALUE_OR_RETURN( |
| 120 | legacy2aidl_audio_output_flags_t_int32_t_mask(afTrackFlags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 121 | aidl.outputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(outputId)); |
| 122 | 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] | 123 | aidl.audioTrack = audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 124 | return aidl; |
| 125 | } |
| 126 | |
| 127 | ConversionResult<IAudioFlinger::CreateTrackOutput> |
| 128 | IAudioFlinger::CreateTrackOutput::fromAidl( |
| 129 | const media::CreateTrackResponse& aidl) { |
| 130 | IAudioFlinger::CreateTrackOutput legacy; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 131 | 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] | 132 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 133 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 134 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 135 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 136 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 137 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 138 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
Andy Hung | a2159aa | 2021-07-20 13:01:52 -0700 | [diff] [blame] | 139 | legacy.streamType = VALUE_OR_RETURN( |
| 140 | aidl2legacy_AudioStreamType_audio_stream_type_t(aidl.streamType)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 141 | legacy.afFrameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.afFrameCount)); |
| 142 | legacy.afSampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afSampleRate)); |
| 143 | legacy.afLatencyMs = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afLatencyMs)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame] | 144 | legacy.afChannelMask = VALUE_OR_RETURN( |
| 145 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.afChannelMask, |
| 146 | false /*isInput*/)); |
| 147 | legacy.afFormat = VALUE_OR_RETURN( |
| 148 | aidl2legacy_AudioFormatDescription_audio_format_t(aidl.afFormat)); |
jiabin | 94ed47c | 2023-07-27 23:34:20 +0000 | [diff] [blame] | 149 | legacy.afTrackFlags = VALUE_OR_RETURN( |
| 150 | aidl2legacy_int32_t_audio_output_flags_t_mask(aidl.afTrackFlags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 151 | legacy.outputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.outputId)); |
| 152 | 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] | 153 | legacy.audioTrack = aidl.audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 154 | return legacy; |
| 155 | } |
| 156 | |
| 157 | ConversionResult<media::CreateRecordRequest> |
| 158 | IAudioFlinger::CreateRecordInput::toAidl() const { |
| 159 | media::CreateRecordRequest aidl; |
Mikhail Naganov | 1c40090 | 2023-05-17 11:48:43 -0700 | [diff] [blame] | 160 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributes(attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 161 | aidl.config = VALUE_OR_RETURN( |
| 162 | legacy2aidl_audio_config_base_t_AudioConfigBase(config, true /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 163 | aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 164 | 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] | 165 | aidl.maxSharedAudioHistoryMs = VALUE_OR_RETURN( |
| 166 | convertIntegral<int32_t>(maxSharedAudioHistoryMs)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 167 | 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] | 168 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 169 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 170 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 171 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 172 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 173 | return aidl; |
| 174 | } |
| 175 | |
| 176 | ConversionResult<IAudioFlinger::CreateRecordInput> |
| 177 | IAudioFlinger::CreateRecordInput::fromAidl( |
| 178 | const media::CreateRecordRequest& aidl) { |
| 179 | IAudioFlinger::CreateRecordInput legacy; |
Eric Laurent | ec376dc | 2021-04-08 20:41:22 +0200 | [diff] [blame] | 180 | legacy.attr = VALUE_OR_RETURN( |
Mikhail Naganov | 1c40090 | 2023-05-17 11:48:43 -0700 | [diff] [blame] | 181 | aidl2legacy_AudioAttributes_audio_attributes_t(aidl.attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 182 | legacy.config = VALUE_OR_RETURN( |
| 183 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config, true /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 184 | legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 185 | 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] | 186 | legacy.maxSharedAudioHistoryMs = VALUE_OR_RETURN( |
| 187 | convertIntegral<int32_t>(aidl.maxSharedAudioHistoryMs)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 188 | 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] | 189 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 190 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 191 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 192 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 193 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 194 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 195 | return legacy; |
| 196 | } |
| 197 | |
| 198 | ConversionResult<media::CreateRecordResponse> |
| 199 | IAudioFlinger::CreateRecordOutput::toAidl() const { |
| 200 | media::CreateRecordResponse aidl; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 201 | 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] | 202 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 203 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 204 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 205 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 206 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 207 | aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
| 208 | aidl.inputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(inputId)); |
| 209 | aidl.cblk = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(cblk)); |
| 210 | aidl.buffers = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(buffers)); |
| 211 | 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] | 212 | aidl.audioRecord = audioRecord; |
jiabin | b00edc3 | 2021-08-16 16:27:54 +0000 | [diff] [blame] | 213 | aidl.serverConfig = VALUE_OR_RETURN( |
| 214 | legacy2aidl_audio_config_base_t_AudioConfigBase(serverConfig, true /*isInput*/)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame] | 215 | aidl.halConfig = VALUE_OR_RETURN( |
| 216 | legacy2aidl_audio_config_base_t_AudioConfigBase(halConfig, true /*isInput*/)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 217 | return aidl; |
| 218 | } |
| 219 | |
| 220 | ConversionResult<IAudioFlinger::CreateRecordOutput> |
| 221 | IAudioFlinger::CreateRecordOutput::fromAidl( |
| 222 | const media::CreateRecordResponse& aidl) { |
| 223 | IAudioFlinger::CreateRecordOutput legacy; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 224 | 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] | 225 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 226 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 227 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 228 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 229 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 230 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 231 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
| 232 | legacy.inputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.inputId)); |
| 233 | legacy.cblk = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.cblk)); |
| 234 | legacy.buffers = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.buffers)); |
| 235 | 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] | 236 | legacy.audioRecord = aidl.audioRecord; |
jiabin | b00edc3 | 2021-08-16 16:27:54 +0000 | [diff] [blame] | 237 | legacy.serverConfig = VALUE_OR_RETURN( |
| 238 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.serverConfig, true /*isInput*/)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame] | 239 | legacy.halConfig = VALUE_OR_RETURN( |
| 240 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.halConfig, true /*isInput*/)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 241 | return legacy; |
| 242 | } |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 243 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 244 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 245 | // AudioFlingerClientAdapter |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 247 | AudioFlingerClientAdapter::AudioFlingerClientAdapter( |
| 248 | const sp<media::IAudioFlingerService> delegate) : mDelegate(delegate) {} |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 249 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 250 | status_t AudioFlingerClientAdapter::createTrack(const media::CreateTrackRequest& input, |
| 251 | media::CreateTrackResponse& output) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 252 | return statusTFromBinderStatus(mDelegate->createTrack(input, &output)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 255 | status_t AudioFlingerClientAdapter::createRecord(const media::CreateRecordRequest& input, |
| 256 | media::CreateRecordResponse& output) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 257 | return statusTFromBinderStatus(mDelegate->createRecord(input, &output)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | uint32_t AudioFlingerClientAdapter::sampleRate(audio_io_handle_t ioHandle) const { |
| 261 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 262 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 263 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 264 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->sampleRate(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 265 | return convertIntegral<uint32_t>(aidlRet); |
| 266 | }(); |
| 267 | // Failure is ignored. |
| 268 | return result.value_or(0); |
| 269 | } |
| 270 | |
| 271 | audio_format_t AudioFlingerClientAdapter::format(audio_io_handle_t output) const { |
| 272 | auto result = [&]() -> ConversionResult<audio_format_t> { |
| 273 | 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] | 274 | AudioFormatDescription aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 275 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->format(outputAidl, &aidlRet))); |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 276 | return aidl2legacy_AudioFormatDescription_audio_format_t(aidlRet); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 277 | }(); |
| 278 | return result.value_or(AUDIO_FORMAT_INVALID); |
| 279 | } |
| 280 | |
| 281 | size_t AudioFlingerClientAdapter::frameCount(audio_io_handle_t ioHandle) const { |
| 282 | auto result = [&]() -> ConversionResult<size_t> { |
| 283 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 284 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 285 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->frameCount(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 286 | return convertIntegral<size_t>(aidlRet); |
| 287 | }(); |
| 288 | // Failure is ignored. |
| 289 | return result.value_or(0); |
| 290 | } |
| 291 | |
| 292 | uint32_t AudioFlingerClientAdapter::latency(audio_io_handle_t output) const { |
| 293 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 294 | int32_t outputAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 295 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 296 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->latency(outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 297 | return convertIntegral<uint32_t>(aidlRet); |
| 298 | }(); |
| 299 | // Failure is ignored. |
| 300 | return result.value_or(0); |
| 301 | } |
| 302 | |
| 303 | status_t AudioFlingerClientAdapter::setMasterVolume(float value) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 304 | return statusTFromBinderStatus(mDelegate->setMasterVolume(value)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | status_t AudioFlingerClientAdapter::setMasterMute(bool muted) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 308 | return statusTFromBinderStatus(mDelegate->setMasterMute(muted)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | float AudioFlingerClientAdapter::masterVolume() const { |
| 312 | auto result = [&]() -> ConversionResult<float> { |
| 313 | float aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 314 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->masterVolume(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 315 | return aidlRet; |
| 316 | }(); |
| 317 | // Failure is ignored. |
| 318 | return result.value_or(0.f); |
| 319 | } |
| 320 | |
| 321 | bool AudioFlingerClientAdapter::masterMute() const { |
| 322 | auto result = [&]() -> ConversionResult<bool> { |
| 323 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 324 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->masterMute(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 325 | return aidlRet; |
| 326 | }(); |
| 327 | // Failure is ignored. |
| 328 | return result.value_or(false); |
| 329 | } |
| 330 | |
| 331 | status_t AudioFlingerClientAdapter::setMasterBalance(float balance) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 332 | return statusTFromBinderStatus(mDelegate->setMasterBalance(balance)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | status_t AudioFlingerClientAdapter::getMasterBalance(float* balance) const{ |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 336 | return statusTFromBinderStatus(mDelegate->getMasterBalance(balance)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | status_t AudioFlingerClientAdapter::setStreamVolume(audio_stream_type_t stream, float value, |
| 340 | audio_io_handle_t output) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 341 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 342 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 343 | 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] | 344 | return statusTFromBinderStatus(mDelegate->setStreamVolume(streamAidl, value, outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | status_t AudioFlingerClientAdapter::setStreamMute(audio_stream_type_t stream, bool muted) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 348 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 349 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 350 | return statusTFromBinderStatus(mDelegate->setStreamMute(streamAidl, muted)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | float AudioFlingerClientAdapter::streamVolume(audio_stream_type_t stream, |
| 354 | audio_io_handle_t output) const { |
| 355 | auto result = [&]() -> ConversionResult<float> { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 356 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 357 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 358 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 359 | float aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 360 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 361 | mDelegate->streamVolume(streamAidl, outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 362 | return aidlRet; |
| 363 | }(); |
| 364 | // Failure is ignored. |
| 365 | return result.value_or(0.f); |
| 366 | } |
| 367 | |
| 368 | bool AudioFlingerClientAdapter::streamMute(audio_stream_type_t stream) const { |
| 369 | auto result = [&]() -> ConversionResult<bool> { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 370 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 371 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 372 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 373 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 374 | mDelegate->streamMute(streamAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 375 | return aidlRet; |
| 376 | }(); |
| 377 | // Failure is ignored. |
| 378 | return result.value_or(false); |
| 379 | } |
| 380 | |
| 381 | status_t AudioFlingerClientAdapter::setMode(audio_mode_t mode) { |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 382 | AudioMode modeAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_mode_t_AudioMode(mode)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 383 | return statusTFromBinderStatus(mDelegate->setMode(modeAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | status_t AudioFlingerClientAdapter::setMicMute(bool state) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 387 | return statusTFromBinderStatus(mDelegate->setMicMute(state)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | bool AudioFlingerClientAdapter::getMicMute() const { |
| 391 | auto result = [&]() -> ConversionResult<bool> { |
| 392 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 393 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 394 | mDelegate->getMicMute(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 395 | return aidlRet; |
| 396 | }(); |
| 397 | // Failure is ignored. |
| 398 | return result.value_or(false); |
| 399 | } |
| 400 | |
| 401 | void AudioFlingerClientAdapter::setRecordSilenced(audio_port_handle_t portId, bool silenced) { |
| 402 | auto result = [&]() -> status_t { |
| 403 | int32_t portIdAidl = VALUE_OR_RETURN_STATUS( |
| 404 | legacy2aidl_audio_port_handle_t_int32_t(portId)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 405 | return statusTFromBinderStatus(mDelegate->setRecordSilenced(portIdAidl, silenced)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 406 | }(); |
| 407 | // Failure is ignored. |
| 408 | (void) result; |
| 409 | } |
| 410 | |
| 411 | status_t AudioFlingerClientAdapter::setParameters(audio_io_handle_t ioHandle, |
| 412 | const String8& keyValuePairs) { |
| 413 | int32_t ioHandleAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 414 | std::string keyValuePairsAidl = VALUE_OR_RETURN_STATUS( |
| 415 | legacy2aidl_String8_string(keyValuePairs)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 416 | return statusTFromBinderStatus(mDelegate->setParameters(ioHandleAidl, keyValuePairsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | String8 AudioFlingerClientAdapter::getParameters(audio_io_handle_t ioHandle, const String8& keys) |
| 420 | const { |
| 421 | auto result = [&]() -> ConversionResult<String8> { |
| 422 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 423 | std::string keysAidl = VALUE_OR_RETURN(legacy2aidl_String8_string(keys)); |
| 424 | std::string aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 425 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 426 | mDelegate->getParameters(ioHandleAidl, keysAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 427 | return aidl2legacy_string_view_String8(aidlRet); |
| 428 | }(); |
| 429 | // Failure is ignored. |
| 430 | return result.value_or(String8()); |
| 431 | } |
| 432 | |
| 433 | void AudioFlingerClientAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 434 | mDelegate->registerClient(client); |
| 435 | // Failure is ignored. |
| 436 | } |
| 437 | |
| 438 | size_t AudioFlingerClientAdapter::getInputBufferSize(uint32_t sampleRate, audio_format_t format, |
| 439 | audio_channel_mask_t channelMask) const { |
| 440 | auto result = [&]() -> ConversionResult<size_t> { |
| 441 | int32_t sampleRateAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 442 | AudioFormatDescription formatAidl = VALUE_OR_RETURN( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 443 | legacy2aidl_audio_format_t_AudioFormatDescription(format)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 444 | AudioChannelLayout channelMaskAidl = VALUE_OR_RETURN( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 445 | legacy2aidl_audio_channel_mask_t_AudioChannelLayout(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 446 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 447 | RETURN_IF_ERROR(statusTFromBinderStatus( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 448 | mDelegate->getInputBufferSize(sampleRateAidl, formatAidl, channelMaskAidl, |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 449 | &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 450 | return convertIntegral<size_t>(aidlRet); |
| 451 | }(); |
| 452 | // Failure is ignored. |
| 453 | return result.value_or(0); |
| 454 | } |
| 455 | |
| 456 | status_t AudioFlingerClientAdapter::openOutput(const media::OpenOutputRequest& request, |
| 457 | media::OpenOutputResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 458 | return statusTFromBinderStatus(mDelegate->openOutput(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | audio_io_handle_t AudioFlingerClientAdapter::openDuplicateOutput(audio_io_handle_t output1, |
| 462 | audio_io_handle_t output2) { |
| 463 | auto result = [&]() -> ConversionResult<audio_io_handle_t> { |
| 464 | int32_t output1Aidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output1)); |
| 465 | int32_t output2Aidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output2)); |
| 466 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 467 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 468 | mDelegate->openDuplicateOutput(output1Aidl, output2Aidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 469 | return aidl2legacy_int32_t_audio_io_handle_t(aidlRet); |
| 470 | }(); |
| 471 | // Failure is ignored. |
| 472 | return result.value_or(0); |
| 473 | } |
| 474 | |
| 475 | status_t AudioFlingerClientAdapter::closeOutput(audio_io_handle_t output) { |
| 476 | 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] | 477 | return statusTFromBinderStatus(mDelegate->closeOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | status_t AudioFlingerClientAdapter::suspendOutput(audio_io_handle_t output) { |
| 481 | 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] | 482 | return statusTFromBinderStatus(mDelegate->suspendOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | status_t AudioFlingerClientAdapter::restoreOutput(audio_io_handle_t output) { |
| 486 | 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] | 487 | return statusTFromBinderStatus(mDelegate->restoreOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | status_t AudioFlingerClientAdapter::openInput(const media::OpenInputRequest& request, |
| 491 | media::OpenInputResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 492 | return statusTFromBinderStatus(mDelegate->openInput(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | status_t AudioFlingerClientAdapter::closeInput(audio_io_handle_t input) { |
| 496 | 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] | 497 | return statusTFromBinderStatus(mDelegate->closeInput(inputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 498 | } |
| 499 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 500 | status_t AudioFlingerClientAdapter::setVoiceVolume(float volume) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 501 | return statusTFromBinderStatus(mDelegate->setVoiceVolume(volume)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | status_t AudioFlingerClientAdapter::getRenderPosition(uint32_t* halFrames, uint32_t* dspFrames, |
| 505 | audio_io_handle_t output) const { |
| 506 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 507 | media::RenderPosition aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 508 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 509 | mDelegate->getRenderPosition(outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 510 | if (halFrames != nullptr) { |
| 511 | *halFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.halFrames)); |
| 512 | } |
| 513 | if (dspFrames != nullptr) { |
| 514 | *dspFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.dspFrames)); |
| 515 | } |
| 516 | return OK; |
| 517 | } |
| 518 | |
| 519 | uint32_t AudioFlingerClientAdapter::getInputFramesLost(audio_io_handle_t ioHandle) const { |
| 520 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 521 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 522 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 523 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 524 | mDelegate->getInputFramesLost(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 525 | return convertIntegral<uint32_t>(aidlRet); |
| 526 | }(); |
| 527 | // Failure is ignored. |
| 528 | return result.value_or(0); |
| 529 | } |
| 530 | |
| 531 | audio_unique_id_t AudioFlingerClientAdapter::newAudioUniqueId(audio_unique_id_use_t use) { |
| 532 | auto result = [&]() -> ConversionResult<audio_unique_id_t> { |
| 533 | media::AudioUniqueIdUse useAidl = VALUE_OR_RETURN( |
| 534 | legacy2aidl_audio_unique_id_use_t_AudioUniqueIdUse(use)); |
| 535 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 536 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 537 | mDelegate->newAudioUniqueId(useAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 538 | return aidl2legacy_int32_t_audio_unique_id_t(aidlRet); |
| 539 | }(); |
| 540 | return result.value_or(AUDIO_UNIQUE_ID_ALLOCATE); |
| 541 | } |
| 542 | |
| 543 | void AudioFlingerClientAdapter::acquireAudioSessionId(audio_session_t audioSession, pid_t pid, |
| 544 | uid_t uid) { |
| 545 | [&]() -> status_t { |
| 546 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 547 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 548 | int32_t pidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(pid)); |
| 549 | 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] | 550 | return statusTFromBinderStatus( |
| 551 | mDelegate->acquireAudioSessionId(audioSessionAidl, pidAidl, uidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 552 | }(); |
| 553 | // Failure is ignored. |
| 554 | } |
| 555 | |
| 556 | void AudioFlingerClientAdapter::releaseAudioSessionId(audio_session_t audioSession, pid_t pid) { |
| 557 | [&]() -> status_t { |
| 558 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 559 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 560 | 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] | 561 | return statusTFromBinderStatus( |
| 562 | mDelegate->releaseAudioSessionId(audioSessionAidl, pidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 563 | }(); |
| 564 | // Failure is ignored. |
| 565 | } |
| 566 | |
| 567 | status_t AudioFlingerClientAdapter::queryNumberEffects(uint32_t* numEffects) const { |
| 568 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 569 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 570 | mDelegate->queryNumberEffects(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 571 | if (numEffects != nullptr) { |
| 572 | *numEffects = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet)); |
| 573 | } |
| 574 | return OK; |
| 575 | } |
| 576 | |
| 577 | status_t |
| 578 | AudioFlingerClientAdapter::queryEffect(uint32_t index, effect_descriptor_t* pDescriptor) const { |
| 579 | int32_t indexAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(index)); |
| 580 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 581 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 582 | mDelegate->queryEffect(indexAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 583 | if (pDescriptor != nullptr) { |
| 584 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 585 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 586 | } |
| 587 | return OK; |
| 588 | } |
| 589 | |
| 590 | status_t AudioFlingerClientAdapter::getEffectDescriptor(const effect_uuid_t* pEffectUUID, |
| 591 | const effect_uuid_t* pTypeUUID, |
| 592 | uint32_t preferredTypeFlag, |
| 593 | effect_descriptor_t* pDescriptor) const { |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 594 | AudioUuid effectUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 595 | legacy2aidl_audio_uuid_t_AudioUuid(*pEffectUUID)); |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 596 | AudioUuid typeUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 597 | legacy2aidl_audio_uuid_t_AudioUuid(*pTypeUUID)); |
| 598 | int32_t preferredTypeFlagAidl = VALUE_OR_RETURN_STATUS( |
| 599 | convertReinterpret<int32_t>(preferredTypeFlag)); |
| 600 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 601 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 602 | mDelegate->getEffectDescriptor(effectUuidAidl, typeUuidAidl, preferredTypeFlagAidl, |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 603 | &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 604 | if (pDescriptor != nullptr) { |
| 605 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 606 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 607 | } |
| 608 | return OK; |
| 609 | } |
| 610 | |
| 611 | status_t AudioFlingerClientAdapter::createEffect(const media::CreateEffectRequest& request, |
| 612 | media::CreateEffectResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 613 | return statusTFromBinderStatus(mDelegate->createEffect(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | status_t |
| 617 | AudioFlingerClientAdapter::moveEffects(audio_session_t session, audio_io_handle_t srcOutput, |
| 618 | audio_io_handle_t dstOutput) { |
| 619 | int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session)); |
| 620 | int32_t srcOutputAidl = VALUE_OR_RETURN_STATUS( |
| 621 | legacy2aidl_audio_io_handle_t_int32_t(srcOutput)); |
| 622 | int32_t dstOutputAidl = VALUE_OR_RETURN_STATUS( |
| 623 | legacy2aidl_audio_io_handle_t_int32_t(dstOutput)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 624 | return statusTFromBinderStatus( |
| 625 | mDelegate->moveEffects(sessionAidl, srcOutputAidl, dstOutputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | void AudioFlingerClientAdapter::setEffectSuspended(int effectId, |
| 629 | audio_session_t sessionId, |
| 630 | bool suspended) { |
| 631 | [&]() -> status_t { |
| 632 | int32_t effectIdAidl = VALUE_OR_RETURN_STATUS(convertReinterpret<int32_t>(effectId)); |
| 633 | int32_t sessionIdAidl = VALUE_OR_RETURN_STATUS( |
| 634 | legacy2aidl_audio_session_t_int32_t(sessionId)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 635 | return statusTFromBinderStatus( |
| 636 | mDelegate->setEffectSuspended(effectIdAidl, sessionIdAidl, suspended)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 637 | }(); |
| 638 | // Failure is ignored. |
| 639 | } |
| 640 | |
| 641 | audio_module_handle_t AudioFlingerClientAdapter::loadHwModule(const char* name) { |
| 642 | auto result = [&]() -> ConversionResult<audio_module_handle_t> { |
| 643 | std::string nameAidl(name); |
| 644 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 645 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 646 | mDelegate->loadHwModule(nameAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 647 | return aidl2legacy_int32_t_audio_module_handle_t(aidlRet); |
| 648 | }(); |
| 649 | // Failure is ignored. |
| 650 | return result.value_or(0); |
| 651 | } |
| 652 | |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 653 | uint32_t AudioFlingerClientAdapter::getPrimaryOutputSamplingRate() const { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 654 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 655 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 656 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 657 | mDelegate->getPrimaryOutputSamplingRate(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 658 | return convertIntegral<uint32_t>(aidlRet); |
| 659 | }(); |
| 660 | // Failure is ignored. |
| 661 | return result.value_or(0); |
| 662 | } |
| 663 | |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 664 | size_t AudioFlingerClientAdapter::getPrimaryOutputFrameCount() const { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 665 | auto result = [&]() -> ConversionResult<size_t> { |
| 666 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 667 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 668 | mDelegate->getPrimaryOutputFrameCount(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 669 | return convertIntegral<size_t>(aidlRet); |
| 670 | }(); |
| 671 | // Failure is ignored. |
| 672 | return result.value_or(0); |
| 673 | } |
| 674 | |
| 675 | status_t AudioFlingerClientAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 676 | return statusTFromBinderStatus(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 677 | } |
| 678 | |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 679 | status_t AudioFlingerClientAdapter::getAudioPort(struct audio_port_v7* port) const { |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 680 | media::AudioPortFw portAidl = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 681 | legacy2aidl_audio_port_v7_AudioPortFw(*port)); |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 682 | media::AudioPortFw aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 683 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 684 | mDelegate->getAudioPort(portAidl, &aidlRet))); |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 685 | *port = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPortFw_audio_port_v7(aidlRet)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 686 | return OK; |
| 687 | } |
| 688 | |
| 689 | status_t AudioFlingerClientAdapter::createAudioPatch(const struct audio_patch* patch, |
| 690 | audio_patch_handle_t* handle) { |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 691 | media::AudioPatchFw patchAidl = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 692 | legacy2aidl_audio_patch_AudioPatchFw(*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, |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 712 | struct audio_patch* patches) const { |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 713 | std::vector<media::AudioPatchFw> aidlRet; |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 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, |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 719 | aidl2legacy_AudioPatchFw_audio_patch); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | status_t AudioFlingerClientAdapter::setAudioPortConfig(const struct audio_port_config* config) { |
Atneya Nair | 7a9594f | 2022-12-18 17:26:26 -0800 | [diff] [blame] | 723 | media::AudioPortConfigFw configAidl = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 724 | legacy2aidl_audio_port_config_AudioPortConfigFw(*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 |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 760 | AudioFlingerClientAdapter::getMicrophones( |
| 761 | std::vector<media::MicrophoneInfoFw>* microphones) const { |
Mikhail Naganov | d5d9de7 | 2023-02-13 11:45:03 -0800 | [diff] [blame] | 762 | std::vector<media::MicrophoneInfoFw> aidlRet; |
| 763 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mDelegate->getMicrophones(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 764 | if (microphones != nullptr) { |
Mikhail Naganov | d5d9de7 | 2023-02-13 11:45:03 -0800 | [diff] [blame] | 765 | *microphones = std::move(aidlRet); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 766 | } |
| 767 | return OK; |
| 768 | } |
| 769 | |
| 770 | status_t AudioFlingerClientAdapter::setAudioHalPids(const std::vector<pid_t>& pids) { |
| 771 | std::vector<int32_t> pidsAidl = VALUE_OR_RETURN_STATUS( |
| 772 | convertContainer<std::vector<int32_t>>(pids, legacy2aidl_pid_t_int32_t)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 773 | return statusTFromBinderStatus(mDelegate->setAudioHalPids(pidsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 774 | } |
| 775 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 776 | status_t AudioFlingerClientAdapter::setVibratorInfos( |
| 777 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 778 | return statusTFromBinderStatus(mDelegate->setVibratorInfos(vibratorInfos)); |
| 779 | } |
| 780 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 781 | status_t AudioFlingerClientAdapter::updateSecondaryOutputs( |
| 782 | const TrackSecondaryOutputsMap& trackSecondaryOutputs) { |
| 783 | std::vector<media::TrackSecondaryOutputInfo> trackSecondaryOutputInfos = |
| 784 | VALUE_OR_RETURN_STATUS( |
| 785 | convertContainer<std::vector<media::TrackSecondaryOutputInfo>>( |
| 786 | trackSecondaryOutputs, |
| 787 | legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo)); |
| 788 | return statusTFromBinderStatus(mDelegate->updateSecondaryOutputs(trackSecondaryOutputInfos)); |
| 789 | } |
| 790 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 791 | status_t AudioFlingerClientAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 792 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *policyInfos) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 793 | return statusTFromBinderStatus(mDelegate->getMmapPolicyInfos(policyType, policyInfos)); |
| 794 | } |
| 795 | |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 796 | int32_t AudioFlingerClientAdapter::getAAudioMixerBurstCount() const { |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 797 | auto result = [&]() -> ConversionResult<int32_t> { |
| 798 | int32_t aidlRet; |
| 799 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->getAAudioMixerBurstCount(&aidlRet))); |
| 800 | return convertIntegral<int32_t>(aidlRet); |
| 801 | }(); |
| 802 | // Failure is ignored. |
| 803 | return result.value_or(0); |
| 804 | } |
| 805 | |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 806 | int32_t AudioFlingerClientAdapter::getAAudioHardwareBurstMinUsec() const { |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 807 | auto result = [&]() -> ConversionResult<int32_t> { |
| 808 | int32_t aidlRet; |
| 809 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 810 | mDelegate->getAAudioHardwareBurstMinUsec(&aidlRet))); |
| 811 | return convertIntegral<int32_t>(aidlRet); |
| 812 | }(); |
| 813 | // Failure is ignored. |
| 814 | return result.value_or(0); |
| 815 | } |
| 816 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 817 | status_t AudioFlingerClientAdapter::setDeviceConnectedState( |
jiabin | c004863 | 2023-04-27 22:04:31 +0000 | [diff] [blame] | 818 | const struct audio_port_v7 *port, media::DeviceConnectedState state) { |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 819 | media::AudioPortFw aidlPort = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 820 | legacy2aidl_audio_port_v7_AudioPortFw(*port)); |
jiabin | c004863 | 2023-04-27 22:04:31 +0000 | [diff] [blame] | 821 | return statusTFromBinderStatus(mDelegate->setDeviceConnectedState(aidlPort, state)); |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 822 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 823 | |
Mikhail Naganov | b1ddbb0 | 2023-03-15 17:06:59 -0700 | [diff] [blame] | 824 | status_t AudioFlingerClientAdapter::setSimulateDeviceConnections(bool enabled) { |
| 825 | return statusTFromBinderStatus(mDelegate->setSimulateDeviceConnections(enabled)); |
| 826 | } |
| 827 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 828 | status_t AudioFlingerClientAdapter::setRequestedLatencyMode( |
| 829 | audio_io_handle_t output, audio_latency_mode_t mode) { |
| 830 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 831 | media::audio::common::AudioLatencyMode modeAidl = VALUE_OR_RETURN_STATUS( |
| 832 | legacy2aidl_audio_latency_mode_t_AudioLatencyMode(mode)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 833 | return statusTFromBinderStatus(mDelegate->setRequestedLatencyMode(outputAidl, modeAidl)); |
| 834 | } |
| 835 | |
| 836 | status_t AudioFlingerClientAdapter::getSupportedLatencyModes( |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 837 | audio_io_handle_t output, std::vector<audio_latency_mode_t>* modes) const { |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 838 | if (modes == nullptr) { |
| 839 | return BAD_VALUE; |
| 840 | } |
| 841 | |
| 842 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 843 | std::vector<media::audio::common::AudioLatencyMode> modesAidl; |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 844 | |
| 845 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 846 | mDelegate->getSupportedLatencyModes(outputAidl, &modesAidl))); |
| 847 | |
| 848 | *modes = VALUE_OR_RETURN_STATUS( |
| 849 | convertContainer<std::vector<audio_latency_mode_t>>(modesAidl, |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 850 | aidl2legacy_AudioLatencyMode_audio_latency_mode_t)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 851 | |
| 852 | return NO_ERROR; |
| 853 | } |
| 854 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 855 | status_t AudioFlingerClientAdapter::setBluetoothVariableLatencyEnabled(bool enabled) { |
| 856 | return statusTFromBinderStatus(mDelegate->setBluetoothVariableLatencyEnabled(enabled)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 857 | } |
| 858 | |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 859 | status_t AudioFlingerClientAdapter::isBluetoothVariableLatencyEnabled(bool* enabled) const { |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 860 | if (enabled == nullptr) { |
| 861 | return BAD_VALUE; |
| 862 | } |
| 863 | |
| 864 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 865 | mDelegate->isBluetoothVariableLatencyEnabled(enabled))); |
| 866 | |
| 867 | return NO_ERROR; |
| 868 | } |
| 869 | |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 870 | status_t AudioFlingerClientAdapter::supportsBluetoothVariableLatency(bool* support) const { |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 871 | if (support == nullptr) { |
| 872 | return BAD_VALUE; |
| 873 | } |
| 874 | |
| 875 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 876 | mDelegate->supportsBluetoothVariableLatency(support))); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 877 | |
| 878 | return NO_ERROR; |
| 879 | } |
| 880 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 881 | status_t AudioFlingerClientAdapter::getSoundDoseInterface( |
| 882 | const sp<media::ISoundDoseCallback> &callback, |
Andy Hung | cdd80ef | 2023-07-17 11:37:26 -0700 | [diff] [blame] | 883 | sp<media::ISoundDose>* soundDose) const { |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 884 | return statusTFromBinderStatus(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 885 | } |
| 886 | |
jiabin | c44b346 | 2022-12-08 12:52:31 -0800 | [diff] [blame] | 887 | status_t AudioFlingerClientAdapter::invalidateTracks( |
| 888 | const std::vector<audio_port_handle_t>& portIds) { |
| 889 | std::vector<int32_t> portIdsAidl = VALUE_OR_RETURN_STATUS( |
| 890 | convertContainer<std::vector<int32_t>>( |
| 891 | portIds, legacy2aidl_audio_port_handle_t_int32_t)); |
| 892 | return statusTFromBinderStatus(mDelegate->invalidateTracks(portIdsAidl)); |
| 893 | } |
| 894 | |
Mikhail Naganov | ffd9771 | 2023-05-03 17:45:36 -0700 | [diff] [blame] | 895 | status_t AudioFlingerClientAdapter::getAudioPolicyConfig(media::AudioPolicyConfig *config) { |
| 896 | if (config == nullptr) { |
| 897 | return BAD_VALUE; |
| 898 | } |
| 899 | |
| 900 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mDelegate->getAudioPolicyConfig(config))); |
| 901 | |
| 902 | return NO_ERROR; |
| 903 | } |
| 904 | |
jiabin | 12537fc | 2023-10-12 17:56:08 +0000 | [diff] [blame] | 905 | status_t AudioFlingerClientAdapter::getAudioMixPort(const struct audio_port_v7 *devicePort, |
| 906 | struct audio_port_v7 *mixPort) const { |
| 907 | if (devicePort == nullptr || mixPort == nullptr) { |
| 908 | return BAD_VALUE; |
| 909 | } |
| 910 | media::AudioPortFw devicePortAidl = VALUE_OR_RETURN_STATUS( |
| 911 | legacy2aidl_audio_port_v7_AudioPortFw(*devicePort)); |
| 912 | media::AudioPortFw mixPortAidl = VALUE_OR_RETURN_STATUS( |
| 913 | legacy2aidl_audio_port_v7_AudioPortFw(*mixPort)); |
| 914 | media::AudioPortFw aidlRet; |
| 915 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 916 | mDelegate->getAudioMixPort(devicePortAidl, mixPortAidl, &aidlRet))); |
| 917 | *mixPort = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPortFw_audio_port_v7(aidlRet)); |
| 918 | return OK; |
| 919 | } |
| 920 | |
jiabin | 220eea1 | 2024-05-17 17:55:20 +0000 | [diff] [blame] | 921 | status_t AudioFlingerClientAdapter::setTracksInternalMute( |
| 922 | const std::vector<media::TrackInternalMuteInfo>& tracksInternalMuted) { |
| 923 | return statusTFromBinderStatus(mDelegate->setTracksInternalMute(tracksInternalMuted)); |
| 924 | } |
| 925 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 926 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 927 | // AudioFlingerServerAdapter |
| 928 | AudioFlingerServerAdapter::AudioFlingerServerAdapter( |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 929 | const sp<AudioFlingerServerAdapter::Delegate>& delegate) : mDelegate(delegate) { |
| 930 | setMinSchedulerPolicy(SCHED_NORMAL, ANDROID_PRIORITY_AUDIO); |
Andy Hung | 58b01b1 | 2024-03-26 18:04:29 -0700 | [diff] [blame] | 931 | setInheritRt(true); |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 932 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 933 | |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 934 | status_t AudioFlingerServerAdapter::onTransact(uint32_t code, |
| 935 | const Parcel& data, |
| 936 | Parcel* reply, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 937 | uint32_t flags) { |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 938 | return mDelegate->onTransactWrapper(static_cast<Delegate::TransactionCode>(code), |
| 939 | data, |
| 940 | flags, |
| 941 | [&] { |
| 942 | return BnAudioFlingerService::onTransact( |
| 943 | code, |
| 944 | data, |
| 945 | reply, |
| 946 | flags); |
| 947 | }); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | status_t AudioFlingerServerAdapter::dump(int fd, const Vector<String16>& args) { |
| 951 | return mDelegate->dump(fd, args); |
| 952 | } |
| 953 | |
| 954 | Status AudioFlingerServerAdapter::createTrack(const media::CreateTrackRequest& request, |
| 955 | media::CreateTrackResponse* _aidl_return) { |
| 956 | return Status::fromStatusT(mDelegate->createTrack(request, *_aidl_return)); |
| 957 | } |
| 958 | |
| 959 | Status AudioFlingerServerAdapter::createRecord(const media::CreateRecordRequest& request, |
| 960 | media::CreateRecordResponse* _aidl_return) { |
| 961 | return Status::fromStatusT(mDelegate->createRecord(request, *_aidl_return)); |
| 962 | } |
| 963 | |
| 964 | Status AudioFlingerServerAdapter::sampleRate(int32_t ioHandle, int32_t* _aidl_return) { |
| 965 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 966 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 967 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 968 | convertIntegral<int32_t>(mDelegate->sampleRate(ioHandleLegacy))); |
| 969 | return Status::ok(); |
| 970 | } |
| 971 | |
| 972 | Status AudioFlingerServerAdapter::format(int32_t output, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 973 | AudioFormatDescription* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 974 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 975 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 976 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 977 | legacy2aidl_audio_format_t_AudioFormatDescription(mDelegate->format(outputLegacy))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 978 | return Status::ok(); |
| 979 | } |
| 980 | |
| 981 | Status AudioFlingerServerAdapter::frameCount(int32_t ioHandle, int64_t* _aidl_return) { |
| 982 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 983 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 984 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 985 | convertIntegral<int64_t>(mDelegate->frameCount(ioHandleLegacy))); |
| 986 | return Status::ok(); |
| 987 | } |
| 988 | |
| 989 | Status AudioFlingerServerAdapter::latency(int32_t output, int32_t* _aidl_return) { |
| 990 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 991 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 992 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 993 | convertIntegral<int32_t>(mDelegate->latency(outputLegacy))); |
| 994 | return Status::ok(); |
| 995 | } |
| 996 | |
| 997 | Status AudioFlingerServerAdapter::setMasterVolume(float value) { |
| 998 | return Status::fromStatusT(mDelegate->setMasterVolume(value)); |
| 999 | } |
| 1000 | |
| 1001 | Status AudioFlingerServerAdapter::setMasterMute(bool muted) { |
| 1002 | return Status::fromStatusT(mDelegate->setMasterMute(muted)); |
| 1003 | } |
| 1004 | |
| 1005 | Status AudioFlingerServerAdapter::masterVolume(float* _aidl_return) { |
| 1006 | *_aidl_return = mDelegate->masterVolume(); |
| 1007 | return Status::ok(); |
| 1008 | } |
| 1009 | |
| 1010 | Status AudioFlingerServerAdapter::masterMute(bool* _aidl_return) { |
| 1011 | *_aidl_return = mDelegate->masterMute(); |
| 1012 | return Status::ok(); |
| 1013 | } |
| 1014 | |
| 1015 | Status AudioFlingerServerAdapter::setMasterBalance(float balance) { |
| 1016 | return Status::fromStatusT(mDelegate->setMasterBalance(balance)); |
| 1017 | } |
| 1018 | |
| 1019 | Status AudioFlingerServerAdapter::getMasterBalance(float* _aidl_return) { |
| 1020 | return Status::fromStatusT(mDelegate->getMasterBalance(_aidl_return)); |
| 1021 | } |
| 1022 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1023 | Status AudioFlingerServerAdapter::setStreamVolume(AudioStreamType stream, float value, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1024 | int32_t output) { |
| 1025 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1026 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1027 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1028 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1029 | return Status::fromStatusT(mDelegate->setStreamVolume(streamLegacy, value, outputLegacy)); |
| 1030 | } |
| 1031 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1032 | Status AudioFlingerServerAdapter::setStreamMute(AudioStreamType stream, bool muted) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1033 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1034 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1035 | return Status::fromStatusT(mDelegate->setStreamMute(streamLegacy, muted)); |
| 1036 | } |
| 1037 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1038 | Status AudioFlingerServerAdapter::streamVolume(AudioStreamType stream, int32_t output, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1039 | float* _aidl_return) { |
| 1040 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1041 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1042 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1043 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1044 | *_aidl_return = mDelegate->streamVolume(streamLegacy, outputLegacy); |
| 1045 | return Status::ok(); |
| 1046 | } |
| 1047 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1048 | Status AudioFlingerServerAdapter::streamMute(AudioStreamType stream, bool* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1049 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1050 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1051 | *_aidl_return = mDelegate->streamMute(streamLegacy); |
| 1052 | return Status::ok(); |
| 1053 | } |
| 1054 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1055 | Status AudioFlingerServerAdapter::setMode(AudioMode mode) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1056 | audio_mode_t modeLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioMode_audio_mode_t(mode)); |
| 1057 | return Status::fromStatusT(mDelegate->setMode(modeLegacy)); |
| 1058 | } |
| 1059 | |
| 1060 | Status AudioFlingerServerAdapter::setMicMute(bool state) { |
| 1061 | return Status::fromStatusT(mDelegate->setMicMute(state)); |
| 1062 | } |
| 1063 | |
| 1064 | Status AudioFlingerServerAdapter::getMicMute(bool* _aidl_return) { |
| 1065 | *_aidl_return = mDelegate->getMicMute(); |
| 1066 | return Status::ok(); |
| 1067 | } |
| 1068 | |
| 1069 | Status AudioFlingerServerAdapter::setRecordSilenced(int32_t portId, bool silenced) { |
| 1070 | audio_port_handle_t portIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1071 | aidl2legacy_int32_t_audio_port_handle_t(portId)); |
| 1072 | mDelegate->setRecordSilenced(portIdLegacy, silenced); |
| 1073 | return Status::ok(); |
| 1074 | } |
| 1075 | |
| 1076 | Status |
| 1077 | AudioFlingerServerAdapter::setParameters(int32_t ioHandle, const std::string& keyValuePairs) { |
| 1078 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1079 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1080 | String8 keyValuePairsLegacy = VALUE_OR_RETURN_BINDER( |
| 1081 | aidl2legacy_string_view_String8(keyValuePairs)); |
| 1082 | return Status::fromStatusT(mDelegate->setParameters(ioHandleLegacy, keyValuePairsLegacy)); |
| 1083 | } |
| 1084 | |
| 1085 | Status AudioFlingerServerAdapter::getParameters(int32_t ioHandle, const std::string& keys, |
| 1086 | std::string* _aidl_return) { |
| 1087 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1088 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1089 | String8 keysLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_string_view_String8(keys)); |
| 1090 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1091 | legacy2aidl_String8_string(mDelegate->getParameters(ioHandleLegacy, keysLegacy))); |
| 1092 | return Status::ok(); |
| 1093 | } |
| 1094 | |
| 1095 | Status AudioFlingerServerAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 1096 | mDelegate->registerClient(client); |
| 1097 | return Status::ok(); |
| 1098 | } |
| 1099 | |
| 1100 | Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 1101 | const AudioFormatDescription& format, |
| 1102 | const AudioChannelLayout& channelMask, |
Mikhail Naganov | 2d8df4e | 2021-06-03 13:59:13 -0700 | [diff] [blame] | 1103 | int64_t* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1104 | uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate)); |
| 1105 | audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 1106 | aidl2legacy_AudioFormatDescription_audio_format_t(format)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1107 | audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 1108 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1109 | size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy); |
| 1110 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size)); |
| 1111 | return Status::ok(); |
| 1112 | } |
| 1113 | |
| 1114 | Status AudioFlingerServerAdapter::openOutput(const media::OpenOutputRequest& request, |
| 1115 | media::OpenOutputResponse* _aidl_return) { |
| 1116 | return Status::fromStatusT(mDelegate->openOutput(request, _aidl_return)); |
| 1117 | } |
| 1118 | |
| 1119 | Status AudioFlingerServerAdapter::openDuplicateOutput(int32_t output1, int32_t output2, |
| 1120 | int32_t* _aidl_return) { |
| 1121 | audio_io_handle_t output1Legacy = VALUE_OR_RETURN_BINDER( |
| 1122 | aidl2legacy_int32_t_audio_io_handle_t(output1)); |
| 1123 | audio_io_handle_t output2Legacy = VALUE_OR_RETURN_BINDER( |
| 1124 | aidl2legacy_int32_t_audio_io_handle_t(output2)); |
| 1125 | audio_io_handle_t result = mDelegate->openDuplicateOutput(output1Legacy, output2Legacy); |
| 1126 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_io_handle_t_int32_t(result)); |
| 1127 | return Status::ok(); |
| 1128 | } |
| 1129 | |
| 1130 | Status AudioFlingerServerAdapter::closeOutput(int32_t output) { |
| 1131 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1132 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1133 | return Status::fromStatusT(mDelegate->closeOutput(outputLegacy)); |
| 1134 | } |
| 1135 | |
| 1136 | Status AudioFlingerServerAdapter::suspendOutput(int32_t output) { |
| 1137 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1138 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1139 | return Status::fromStatusT(mDelegate->suspendOutput(outputLegacy)); |
| 1140 | } |
| 1141 | |
| 1142 | Status AudioFlingerServerAdapter::restoreOutput(int32_t output) { |
| 1143 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1144 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1145 | return Status::fromStatusT(mDelegate->restoreOutput(outputLegacy)); |
| 1146 | } |
| 1147 | |
| 1148 | Status AudioFlingerServerAdapter::openInput(const media::OpenInputRequest& request, |
| 1149 | media::OpenInputResponse* _aidl_return) { |
| 1150 | return Status::fromStatusT(mDelegate->openInput(request, _aidl_return)); |
| 1151 | } |
| 1152 | |
| 1153 | Status AudioFlingerServerAdapter::closeInput(int32_t input) { |
| 1154 | audio_io_handle_t inputLegacy = VALUE_OR_RETURN_BINDER( |
| 1155 | aidl2legacy_int32_t_audio_io_handle_t(input)); |
| 1156 | return Status::fromStatusT(mDelegate->closeInput(inputLegacy)); |
| 1157 | } |
| 1158 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1159 | Status AudioFlingerServerAdapter::setVoiceVolume(float volume) { |
| 1160 | return Status::fromStatusT(mDelegate->setVoiceVolume(volume)); |
| 1161 | } |
| 1162 | |
| 1163 | Status |
| 1164 | AudioFlingerServerAdapter::getRenderPosition(int32_t output, media::RenderPosition* _aidl_return) { |
| 1165 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1166 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1167 | uint32_t halFramesLegacy; |
| 1168 | uint32_t dspFramesLegacy; |
| 1169 | RETURN_BINDER_IF_ERROR( |
| 1170 | mDelegate->getRenderPosition(&halFramesLegacy, &dspFramesLegacy, outputLegacy)); |
| 1171 | _aidl_return->halFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(halFramesLegacy)); |
| 1172 | _aidl_return->dspFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(dspFramesLegacy)); |
| 1173 | return Status::ok(); |
| 1174 | } |
| 1175 | |
| 1176 | Status AudioFlingerServerAdapter::getInputFramesLost(int32_t ioHandle, int32_t* _aidl_return) { |
| 1177 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1178 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1179 | uint32_t result = mDelegate->getInputFramesLost(ioHandleLegacy); |
| 1180 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(result)); |
| 1181 | return Status::ok(); |
| 1182 | } |
| 1183 | |
| 1184 | Status |
| 1185 | AudioFlingerServerAdapter::newAudioUniqueId(media::AudioUniqueIdUse use, int32_t* _aidl_return) { |
| 1186 | audio_unique_id_use_t useLegacy = VALUE_OR_RETURN_BINDER( |
| 1187 | aidl2legacy_AudioUniqueIdUse_audio_unique_id_use_t(use)); |
| 1188 | audio_unique_id_t result = mDelegate->newAudioUniqueId(useLegacy); |
| 1189 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_unique_id_t_int32_t(result)); |
| 1190 | return Status::ok(); |
| 1191 | } |
| 1192 | |
| 1193 | Status |
| 1194 | AudioFlingerServerAdapter::acquireAudioSessionId(int32_t audioSession, int32_t pid, int32_t uid) { |
| 1195 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1196 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1197 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1198 | uid_t uidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_uid_t(uid)); |
| 1199 | mDelegate->acquireAudioSessionId(audioSessionLegacy, pidLegacy, uidLegacy); |
| 1200 | return Status::ok(); |
| 1201 | } |
| 1202 | |
| 1203 | Status AudioFlingerServerAdapter::releaseAudioSessionId(int32_t audioSession, int32_t pid) { |
| 1204 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1205 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1206 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1207 | mDelegate->releaseAudioSessionId(audioSessionLegacy, pidLegacy); |
| 1208 | return Status::ok(); |
| 1209 | } |
| 1210 | |
| 1211 | Status AudioFlingerServerAdapter::queryNumberEffects(int32_t* _aidl_return) { |
| 1212 | uint32_t result; |
| 1213 | RETURN_BINDER_IF_ERROR(mDelegate->queryNumberEffects(&result)); |
| 1214 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(result)); |
| 1215 | return Status::ok(); |
| 1216 | } |
| 1217 | |
| 1218 | Status |
| 1219 | AudioFlingerServerAdapter::queryEffect(int32_t index, media::EffectDescriptor* _aidl_return) { |
| 1220 | uint32_t indexLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(index)); |
| 1221 | effect_descriptor_t result; |
| 1222 | RETURN_BINDER_IF_ERROR(mDelegate->queryEffect(indexLegacy, &result)); |
| 1223 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1224 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1225 | return Status::ok(); |
| 1226 | } |
| 1227 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1228 | Status AudioFlingerServerAdapter::getEffectDescriptor(const AudioUuid& effectUUID, |
| 1229 | const AudioUuid& typeUUID, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1230 | int32_t preferredTypeFlag, |
| 1231 | media::EffectDescriptor* _aidl_return) { |
| 1232 | effect_uuid_t effectUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1233 | aidl2legacy_AudioUuid_audio_uuid_t(effectUUID)); |
| 1234 | effect_uuid_t typeUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1235 | aidl2legacy_AudioUuid_audio_uuid_t(typeUUID)); |
| 1236 | uint32_t preferredTypeFlagLegacy = VALUE_OR_RETURN_BINDER( |
| 1237 | convertReinterpret<uint32_t>(preferredTypeFlag)); |
| 1238 | effect_descriptor_t result; |
| 1239 | RETURN_BINDER_IF_ERROR(mDelegate->getEffectDescriptor(&effectUuidLegacy, &typeUuidLegacy, |
| 1240 | preferredTypeFlagLegacy, &result)); |
| 1241 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1242 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1243 | return Status::ok(); |
| 1244 | } |
| 1245 | |
| 1246 | Status AudioFlingerServerAdapter::createEffect(const media::CreateEffectRequest& request, |
| 1247 | media::CreateEffectResponse* _aidl_return) { |
| 1248 | return Status::fromStatusT(mDelegate->createEffect(request, _aidl_return)); |
| 1249 | } |
| 1250 | |
| 1251 | Status |
| 1252 | AudioFlingerServerAdapter::moveEffects(int32_t session, int32_t srcOutput, int32_t dstOutput) { |
| 1253 | audio_session_t sessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1254 | aidl2legacy_int32_t_audio_session_t(session)); |
| 1255 | audio_io_handle_t srcOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1256 | aidl2legacy_int32_t_audio_io_handle_t(srcOutput)); |
| 1257 | audio_io_handle_t dstOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1258 | aidl2legacy_int32_t_audio_io_handle_t(dstOutput)); |
| 1259 | return Status::fromStatusT( |
| 1260 | mDelegate->moveEffects(sessionLegacy, srcOutputLegacy, dstOutputLegacy)); |
| 1261 | } |
| 1262 | |
| 1263 | Status AudioFlingerServerAdapter::setEffectSuspended(int32_t effectId, int32_t sessionId, |
| 1264 | bool suspended) { |
| 1265 | int effectIdLegacy = VALUE_OR_RETURN_BINDER(convertReinterpret<int>(effectId)); |
| 1266 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1267 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1268 | mDelegate->setEffectSuspended(effectIdLegacy, sessionIdLegacy, suspended); |
| 1269 | return Status::ok(); |
| 1270 | } |
| 1271 | |
| 1272 | Status AudioFlingerServerAdapter::loadHwModule(const std::string& name, int32_t* _aidl_return) { |
| 1273 | audio_module_handle_t result = mDelegate->loadHwModule(name.c_str()); |
| 1274 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_module_handle_t_int32_t(result)); |
| 1275 | return Status::ok(); |
| 1276 | } |
| 1277 | |
| 1278 | Status AudioFlingerServerAdapter::getPrimaryOutputSamplingRate(int32_t* _aidl_return) { |
| 1279 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1280 | convertIntegral<int32_t>(mDelegate->getPrimaryOutputSamplingRate())); |
| 1281 | return Status::ok(); |
| 1282 | } |
| 1283 | |
| 1284 | Status AudioFlingerServerAdapter::getPrimaryOutputFrameCount(int64_t* _aidl_return) { |
| 1285 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1286 | convertIntegral<int64_t>(mDelegate->getPrimaryOutputFrameCount())); |
| 1287 | return Status::ok(); |
| 1288 | |
| 1289 | } |
| 1290 | |
| 1291 | Status AudioFlingerServerAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
| 1292 | return Status::fromStatusT(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
| 1293 | } |
| 1294 | |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 1295 | Status AudioFlingerServerAdapter::getAudioPort(const media::AudioPortFw& port, |
| 1296 | media::AudioPortFw* _aidl_return) { |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1297 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPortFw_audio_port_v7(port)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1298 | RETURN_BINDER_IF_ERROR(mDelegate->getAudioPort(&portLegacy)); |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1299 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_port_v7_AudioPortFw(portLegacy)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1300 | return Status::ok(); |
| 1301 | } |
| 1302 | |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 1303 | Status AudioFlingerServerAdapter::createAudioPatch(const media::AudioPatchFw& patch, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1304 | int32_t* _aidl_return) { |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1305 | audio_patch patchLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPatchFw_audio_patch(patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 1306 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1307 | aidl2legacy_int32_t_audio_patch_handle_t(*_aidl_return)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1308 | RETURN_BINDER_IF_ERROR(mDelegate->createAudioPatch(&patchLegacy, &handleLegacy)); |
| 1309 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_patch_handle_t_int32_t(handleLegacy)); |
| 1310 | return Status::ok(); |
| 1311 | } |
| 1312 | |
| 1313 | Status AudioFlingerServerAdapter::releaseAudioPatch(int32_t handle) { |
| 1314 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1315 | aidl2legacy_int32_t_audio_patch_handle_t(handle)); |
| 1316 | return Status::fromStatusT(mDelegate->releaseAudioPatch(handleLegacy)); |
| 1317 | } |
| 1318 | |
| 1319 | Status AudioFlingerServerAdapter::listAudioPatches(int32_t maxCount, |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 1320 | std::vector<media::AudioPatchFw>* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1321 | unsigned int count = VALUE_OR_RETURN_BINDER(convertIntegral<unsigned int>(maxCount)); |
| 1322 | count = std::min(count, static_cast<unsigned int>(MAX_ITEMS_PER_LIST)); |
| 1323 | std::unique_ptr<audio_patch[]> patchesLegacy(new audio_patch[count]); |
| 1324 | RETURN_BINDER_IF_ERROR(mDelegate->listAudioPatches(&count, patchesLegacy.get())); |
| 1325 | RETURN_BINDER_IF_ERROR(convertRange(&patchesLegacy[0], |
| 1326 | &patchesLegacy[count], |
| 1327 | std::back_inserter(*_aidl_return), |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1328 | legacy2aidl_audio_patch_AudioPatchFw)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1329 | return Status::ok(); |
| 1330 | } |
| 1331 | |
Atneya Nair | 7a9594f | 2022-12-18 17:26:26 -0800 | [diff] [blame] | 1332 | Status AudioFlingerServerAdapter::setAudioPortConfig(const media::AudioPortConfigFw& config) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1333 | audio_port_config configLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1334 | aidl2legacy_AudioPortConfigFw_audio_port_config(config)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1335 | return Status::fromStatusT(mDelegate->setAudioPortConfig(&configLegacy)); |
| 1336 | } |
| 1337 | |
| 1338 | Status AudioFlingerServerAdapter::getAudioHwSyncForSession(int32_t sessionId, |
| 1339 | int32_t* _aidl_return) { |
| 1340 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1341 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1342 | audio_hw_sync_t result = mDelegate->getAudioHwSyncForSession(sessionIdLegacy); |
| 1343 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_hw_sync_t_int32_t(result)); |
| 1344 | return Status::ok(); |
| 1345 | } |
| 1346 | |
| 1347 | Status AudioFlingerServerAdapter::systemReady() { |
| 1348 | return Status::fromStatusT(mDelegate->systemReady()); |
| 1349 | } |
| 1350 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 1351 | Status AudioFlingerServerAdapter::audioPolicyReady() { |
| 1352 | mDelegate->audioPolicyReady(); |
| 1353 | return Status::ok(); |
| 1354 | } |
| 1355 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1356 | Status AudioFlingerServerAdapter::frameCountHAL(int32_t ioHandle, int64_t* _aidl_return) { |
| 1357 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1358 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1359 | size_t result = mDelegate->frameCountHAL(ioHandleLegacy); |
| 1360 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(result)); |
| 1361 | return Status::ok(); |
| 1362 | } |
| 1363 | |
| 1364 | Status AudioFlingerServerAdapter::getMicrophones( |
Mikhail Naganov | d5d9de7 | 2023-02-13 11:45:03 -0800 | [diff] [blame] | 1365 | std::vector<media::MicrophoneInfoFw>* _aidl_return) { |
| 1366 | RETURN_BINDER_IF_ERROR(mDelegate->getMicrophones(_aidl_return)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1367 | return Status::ok(); |
| 1368 | } |
| 1369 | |
| 1370 | Status AudioFlingerServerAdapter::setAudioHalPids(const std::vector<int32_t>& pids) { |
| 1371 | std::vector<pid_t> pidsLegacy = VALUE_OR_RETURN_BINDER( |
| 1372 | convertContainer<std::vector<pid_t>>(pids, aidl2legacy_int32_t_pid_t)); |
| 1373 | RETURN_BINDER_IF_ERROR(mDelegate->setAudioHalPids(pidsLegacy)); |
| 1374 | return Status::ok(); |
| 1375 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1376 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 1377 | Status AudioFlingerServerAdapter::setVibratorInfos( |
| 1378 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 1379 | return Status::fromStatusT(mDelegate->setVibratorInfos(vibratorInfos)); |
| 1380 | } |
| 1381 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 1382 | Status AudioFlingerServerAdapter::updateSecondaryOutputs( |
| 1383 | const std::vector<media::TrackSecondaryOutputInfo>& trackSecondaryOutputInfos) { |
| 1384 | TrackSecondaryOutputsMap trackSecondaryOutputs = |
| 1385 | VALUE_OR_RETURN_BINDER(convertContainer<TrackSecondaryOutputsMap>( |
| 1386 | trackSecondaryOutputInfos, |
| 1387 | aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair)); |
| 1388 | return Status::fromStatusT(mDelegate->updateSecondaryOutputs(trackSecondaryOutputs)); |
| 1389 | } |
| 1390 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1391 | Status AudioFlingerServerAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 1392 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *_aidl_return) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1393 | return Status::fromStatusT(mDelegate->getMmapPolicyInfos(policyType, _aidl_return)); |
| 1394 | } |
| 1395 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 1396 | Status AudioFlingerServerAdapter::getAAudioMixerBurstCount(int32_t* _aidl_return) { |
| 1397 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1398 | convertIntegral<int32_t>(mDelegate->getAAudioMixerBurstCount())); |
| 1399 | return Status::ok(); |
| 1400 | } |
| 1401 | |
| 1402 | Status AudioFlingerServerAdapter::getAAudioHardwareBurstMinUsec(int32_t* _aidl_return) { |
| 1403 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1404 | convertIntegral<int32_t>(mDelegate->getAAudioHardwareBurstMinUsec())); |
| 1405 | return Status::ok(); |
| 1406 | } |
| 1407 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1408 | Status AudioFlingerServerAdapter::setDeviceConnectedState( |
jiabin | c004863 | 2023-04-27 22:04:31 +0000 | [diff] [blame] | 1409 | const media::AudioPortFw& port, media::DeviceConnectedState state) { |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1410 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPortFw_audio_port_v7(port)); |
jiabin | c004863 | 2023-04-27 22:04:31 +0000 | [diff] [blame] | 1411 | return Status::fromStatusT(mDelegate->setDeviceConnectedState(&portLegacy, state)); |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1412 | } |
| 1413 | |
Mikhail Naganov | b1ddbb0 | 2023-03-15 17:06:59 -0700 | [diff] [blame] | 1414 | Status AudioFlingerServerAdapter::setSimulateDeviceConnections(bool enabled) { |
| 1415 | return Status::fromStatusT(mDelegate->setSimulateDeviceConnections(enabled)); |
| 1416 | } |
| 1417 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1418 | Status AudioFlingerServerAdapter::setRequestedLatencyMode( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1419 | int32_t output, media::audio::common::AudioLatencyMode modeAidl) { |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1420 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1421 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1422 | audio_latency_mode_t modeLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1423 | aidl2legacy_AudioLatencyMode_audio_latency_mode_t(modeAidl)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1424 | return Status::fromStatusT(mDelegate->setRequestedLatencyMode( |
| 1425 | outputLegacy, modeLegacy)); |
| 1426 | } |
| 1427 | |
| 1428 | Status AudioFlingerServerAdapter::getSupportedLatencyModes( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1429 | int output, std::vector<media::audio::common::AudioLatencyMode>* _aidl_return) { |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1430 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1431 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1432 | std::vector<audio_latency_mode_t> modesLegacy; |
| 1433 | |
| 1434 | RETURN_BINDER_IF_ERROR(mDelegate->getSupportedLatencyModes(outputLegacy, &modesLegacy)); |
| 1435 | |
| 1436 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1437 | convertContainer<std::vector<media::audio::common::AudioLatencyMode>>( |
| 1438 | modesLegacy, legacy2aidl_audio_latency_mode_t_AudioLatencyMode)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1439 | return Status::ok(); |
| 1440 | } |
| 1441 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 1442 | Status AudioFlingerServerAdapter::setBluetoothVariableLatencyEnabled(bool enabled) { |
| 1443 | return Status::fromStatusT(mDelegate->setBluetoothVariableLatencyEnabled(enabled)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 1444 | } |
| 1445 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 1446 | Status AudioFlingerServerAdapter::isBluetoothVariableLatencyEnabled(bool *enabled) { |
| 1447 | return Status::fromStatusT(mDelegate->isBluetoothVariableLatencyEnabled(enabled)); |
| 1448 | } |
| 1449 | |
| 1450 | Status AudioFlingerServerAdapter::supportsBluetoothVariableLatency(bool *support) { |
| 1451 | return Status::fromStatusT(mDelegate->supportsBluetoothVariableLatency(support)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 1452 | } |
| 1453 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1454 | Status AudioFlingerServerAdapter::getSoundDoseInterface( |
| 1455 | const sp<media::ISoundDoseCallback>& callback, |
| 1456 | sp<media::ISoundDose>* soundDose) |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1457 | { |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1458 | return Status::fromStatusT(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1459 | } |
| 1460 | |
jiabin | c44b346 | 2022-12-08 12:52:31 -0800 | [diff] [blame] | 1461 | Status AudioFlingerServerAdapter::invalidateTracks(const std::vector<int32_t>& portIds) { |
| 1462 | std::vector<audio_port_handle_t> portIdsLegacy = VALUE_OR_RETURN_BINDER( |
| 1463 | convertContainer<std::vector<audio_port_handle_t>>( |
| 1464 | portIds, aidl2legacy_int32_t_audio_port_handle_t)); |
| 1465 | RETURN_BINDER_IF_ERROR(mDelegate->invalidateTracks(portIdsLegacy)); |
| 1466 | return Status::ok(); |
| 1467 | } |
| 1468 | |
Mikhail Naganov | ffd9771 | 2023-05-03 17:45:36 -0700 | [diff] [blame] | 1469 | Status AudioFlingerServerAdapter::getAudioPolicyConfig(media::AudioPolicyConfig* _aidl_return) { |
| 1470 | return Status::fromStatusT(mDelegate->getAudioPolicyConfig(_aidl_return)); |
| 1471 | } |
| 1472 | |
jiabin | 12537fc | 2023-10-12 17:56:08 +0000 | [diff] [blame] | 1473 | Status AudioFlingerServerAdapter::getAudioMixPort(const media::AudioPortFw &devicePort, |
| 1474 | const media::AudioPortFw &mixPort, |
| 1475 | media::AudioPortFw *_aidl_return) { |
| 1476 | audio_port_v7 devicePortLegacy = VALUE_OR_RETURN_BINDER( |
| 1477 | aidl2legacy_AudioPortFw_audio_port_v7(devicePort)); |
| 1478 | audio_port_v7 mixPortLegacy = VALUE_OR_RETURN_BINDER( |
| 1479 | aidl2legacy_AudioPortFw_audio_port_v7(mixPort)); |
| 1480 | RETURN_BINDER_IF_ERROR(mDelegate->getAudioMixPort(&devicePortLegacy, &mixPortLegacy)); |
| 1481 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_port_v7_AudioPortFw(mixPortLegacy)); |
| 1482 | return Status::ok(); |
| 1483 | } |
| 1484 | |
jiabin | 220eea1 | 2024-05-17 17:55:20 +0000 | [diff] [blame] | 1485 | Status AudioFlingerServerAdapter::setTracksInternalMute( |
| 1486 | const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) { |
| 1487 | return Status::fromStatusT(mDelegate->setTracksInternalMute(tracksInternalMute)); |
| 1488 | } |
| 1489 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1490 | } // namespace android |