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