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 |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | #include <utils/Log.h> |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <sys/types.h> |
| 24 | |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 25 | #include <binder/IPCThreadState.h> |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 26 | #include <binder/Parcel.h> |
Eric Laurent | 4dacbc3 | 2020-10-07 13:48:21 -0700 | [diff] [blame] | 27 | #include <media/AudioSanitizer.h> |
Eric Laurent | 14dc3cb | 2020-09-16 18:42:23 -0700 | [diff] [blame] | 28 | #include <media/IAudioPolicyService.h> |
Andy Hung | 4ef19fa | 2018-05-15 19:35:29 -0700 | [diff] [blame] | 29 | #include <mediautils/ServiceUtilities.h> |
Marco Nelissen | cf90b49 | 2019-09-26 11:20:54 -0700 | [diff] [blame] | 30 | #include <mediautils/TimeCheck.h> |
Steven Moreland | 25a9e55 | 2017-04-17 14:30:39 -0700 | [diff] [blame] | 31 | #include "IAudioFlinger.h" |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | |
| 33 | namespace android { |
| 34 | |
| 35 | enum { |
| 36 | CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION, |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 37 | CREATE_RECORD, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | SAMPLE_RATE, |
Glenn Kasten | 5876f2f | 2012-11-30 10:52:16 -0800 | [diff] [blame] | 39 | RESERVED, // obsolete, was CHANNEL_COUNT |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | FORMAT, |
| 41 | FRAME_COUNT, |
| 42 | LATENCY, |
| 43 | SET_MASTER_VOLUME, |
| 44 | SET_MASTER_MUTE, |
| 45 | MASTER_VOLUME, |
| 46 | MASTER_MUTE, |
| 47 | SET_STREAM_VOLUME, |
| 48 | SET_STREAM_MUTE, |
| 49 | STREAM_VOLUME, |
| 50 | STREAM_MUTE, |
| 51 | SET_MODE, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | SET_MIC_MUTE, |
| 53 | GET_MIC_MUTE, |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 54 | SET_RECORD_SILENCED, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 55 | SET_PARAMETERS, |
| 56 | GET_PARAMETERS, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | REGISTER_CLIENT, |
| 58 | GET_INPUTBUFFERSIZE, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 59 | OPEN_OUTPUT, |
| 60 | OPEN_DUPLICATE_OUTPUT, |
| 61 | CLOSE_OUTPUT, |
| 62 | SUSPEND_OUTPUT, |
| 63 | RESTORE_OUTPUT, |
| 64 | OPEN_INPUT, |
| 65 | CLOSE_INPUT, |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 66 | INVALIDATE_STREAM, |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 67 | SET_VOICE_VOLUME, |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 68 | GET_RENDER_POSITION, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 69 | GET_INPUT_FRAMES_LOST, |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 70 | NEW_AUDIO_UNIQUE_ID, |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 71 | ACQUIRE_AUDIO_SESSION_ID, |
| 72 | RELEASE_AUDIO_SESSION_ID, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 73 | QUERY_NUM_EFFECTS, |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 74 | QUERY_EFFECT, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 75 | GET_EFFECT_DESCRIPTOR, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 76 | CREATE_EFFECT, |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 77 | MOVE_EFFECTS, |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 78 | LOAD_HW_MODULE, |
| 79 | GET_PRIMARY_OUTPUT_SAMPLING_RATE, |
| 80 | GET_PRIMARY_OUTPUT_FRAME_COUNT, |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 81 | SET_LOW_RAM_DEVICE, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 82 | LIST_AUDIO_PORTS, |
| 83 | GET_AUDIO_PORT, |
| 84 | CREATE_AUDIO_PATCH, |
| 85 | RELEASE_AUDIO_PATCH, |
| 86 | LIST_AUDIO_PATCHES, |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 87 | SET_AUDIO_PORT_CONFIG, |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 88 | GET_AUDIO_HW_SYNC_FOR_SESSION, |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 89 | SYSTEM_READY, |
| 90 | FRAME_COUNT_HAL, |
jiabin | 9ff780e | 2018-03-19 18:19:52 -0700 | [diff] [blame] | 91 | GET_MICROPHONES, |
Richard Folke Tullberg | 3fae037 | 2017-01-13 09:04:25 +0100 | [diff] [blame] | 92 | SET_MASTER_BALANCE, |
| 93 | GET_MASTER_BALANCE, |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 94 | SET_EFFECT_SUSPENDED, |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 95 | SET_AUDIO_HAL_PIDS |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | }; |
| 97 | |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 98 | #define MAX_ITEMS_PER_LIST 1024 |
| 99 | |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 100 | ConversionResult<media::CreateTrackRequest> IAudioFlinger::CreateTrackInput::toAidl() const { |
| 101 | media::CreateTrackRequest aidl; |
| 102 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr)); |
| 103 | aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig(config)); |
| 104 | aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient(clientInfo)); |
| 105 | aidl.sharedBuffer = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(sharedBuffer)); |
| 106 | aidl.notificationsPerBuffer = VALUE_OR_RETURN(convertIntegral<int32_t>(notificationsPerBuffer)); |
| 107 | aidl.speed = speed; |
| 108 | aidl.audioTrackCallback = audioTrackCallback; |
| 109 | aidl.opPackageName = opPackageName; |
| 110 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_output_flags_mask(flags)); |
| 111 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 112 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 113 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 114 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 115 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 116 | return aidl; |
| 117 | } |
| 118 | |
| 119 | ConversionResult<IAudioFlinger::CreateTrackInput> |
| 120 | IAudioFlinger::CreateTrackInput::fromAidl(const media::CreateTrackRequest& aidl) { |
| 121 | IAudioFlinger::CreateTrackInput legacy; |
| 122 | legacy.attr = VALUE_OR_RETURN(aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr)); |
| 123 | legacy.config = VALUE_OR_RETURN(aidl2legacy_AudioConfig_audio_config_t(aidl.config)); |
| 124 | legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient(aidl.clientInfo)); |
| 125 | legacy.sharedBuffer = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.sharedBuffer)); |
| 126 | legacy.notificationsPerBuffer = VALUE_OR_RETURN( |
| 127 | convertIntegral<uint32_t>(aidl.notificationsPerBuffer)); |
| 128 | legacy.speed = aidl.speed; |
| 129 | legacy.audioTrackCallback = aidl.audioTrackCallback; |
| 130 | legacy.opPackageName = aidl.opPackageName; |
| 131 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_audio_output_flags_mask(aidl.flags)); |
| 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 | return legacy; |
| 139 | } |
| 140 | |
| 141 | ConversionResult<media::CreateTrackResponse> |
| 142 | IAudioFlinger::CreateTrackOutput::toAidl() const { |
| 143 | media::CreateTrackResponse aidl; |
| 144 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_output_flags_mask(flags)); |
| 145 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 146 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 147 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 148 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 149 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 150 | aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
| 151 | aidl.afFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(afFrameCount)); |
| 152 | aidl.afSampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(afSampleRate)); |
| 153 | aidl.afLatencyMs = VALUE_OR_RETURN(convertIntegral<int32_t>(afLatencyMs)); |
| 154 | aidl.outputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(outputId)); |
| 155 | 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] | 156 | aidl.audioTrack = audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 157 | return aidl; |
| 158 | } |
| 159 | |
| 160 | ConversionResult<IAudioFlinger::CreateTrackOutput> |
| 161 | IAudioFlinger::CreateTrackOutput::fromAidl( |
| 162 | const media::CreateTrackResponse& aidl) { |
| 163 | IAudioFlinger::CreateTrackOutput legacy; |
| 164 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_audio_output_flags_mask(aidl.flags)); |
| 165 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 166 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 167 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 168 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 169 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 170 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 171 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
| 172 | legacy.afFrameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.afFrameCount)); |
| 173 | legacy.afSampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afSampleRate)); |
| 174 | legacy.afLatencyMs = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afLatencyMs)); |
| 175 | legacy.outputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.outputId)); |
| 176 | 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] | 177 | legacy.audioTrack = aidl.audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 178 | return legacy; |
| 179 | } |
| 180 | |
| 181 | ConversionResult<media::CreateRecordRequest> |
| 182 | IAudioFlinger::CreateRecordInput::toAidl() const { |
| 183 | media::CreateRecordRequest aidl; |
| 184 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr)); |
| 185 | aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_base_t_AudioConfigBase(config)); |
| 186 | aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient(clientInfo)); |
| 187 | aidl.opPackageName = VALUE_OR_RETURN(legacy2aidl_String16_string(opPackageName)); |
| 188 | aidl.riid = VALUE_OR_RETURN(legacy2aidl_audio_unique_id_t_int32_t(riid)); |
| 189 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_input_flags_mask(flags)); |
| 190 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 191 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 192 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 193 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 194 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 195 | return aidl; |
| 196 | } |
| 197 | |
| 198 | ConversionResult<IAudioFlinger::CreateRecordInput> |
| 199 | IAudioFlinger::CreateRecordInput::fromAidl( |
| 200 | const media::CreateRecordRequest& aidl) { |
| 201 | IAudioFlinger::CreateRecordInput legacy; |
| 202 | legacy.attr = VALUE_OR_RETURN(aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr)); |
| 203 | legacy.config = VALUE_OR_RETURN(aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config)); |
| 204 | legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient(aidl.clientInfo)); |
| 205 | legacy.opPackageName = VALUE_OR_RETURN(aidl2legacy_string_view_String16(aidl.opPackageName)); |
| 206 | legacy.riid = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_unique_id_t(aidl.riid)); |
| 207 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_audio_input_flags_mask(aidl.flags)); |
| 208 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 209 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 210 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 211 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 212 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 213 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 214 | return legacy; |
| 215 | } |
| 216 | |
| 217 | ConversionResult<media::CreateRecordResponse> |
| 218 | IAudioFlinger::CreateRecordOutput::toAidl() const { |
| 219 | media::CreateRecordResponse aidl; |
| 220 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_input_flags_mask(flags)); |
| 221 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 222 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 223 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 224 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 225 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 226 | aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
| 227 | aidl.inputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(inputId)); |
| 228 | aidl.cblk = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(cblk)); |
| 229 | aidl.buffers = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(buffers)); |
| 230 | 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] | 231 | aidl.audioRecord = audioRecord; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 232 | return aidl; |
| 233 | } |
| 234 | |
| 235 | ConversionResult<IAudioFlinger::CreateRecordOutput> |
| 236 | IAudioFlinger::CreateRecordOutput::fromAidl( |
| 237 | const media::CreateRecordResponse& aidl) { |
| 238 | IAudioFlinger::CreateRecordOutput legacy; |
| 239 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_audio_input_flags_mask(aidl.flags)); |
| 240 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 241 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 242 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 243 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 244 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 245 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 246 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
| 247 | legacy.inputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.inputId)); |
| 248 | legacy.cblk = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.cblk)); |
| 249 | legacy.buffers = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.buffers)); |
| 250 | 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] | 251 | legacy.audioRecord = aidl.audioRecord; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 252 | return legacy; |
| 253 | } |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 254 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 255 | class BpAudioFlinger : public BpInterface<IAudioFlinger> |
| 256 | { |
| 257 | public: |
Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 258 | explicit BpAudioFlinger(const sp<IBinder>& impl) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | : BpInterface<IAudioFlinger>(impl) |
| 260 | { |
| 261 | } |
| 262 | |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 263 | virtual status_t createTrack(const media::CreateTrackRequest& input, |
| 264 | media::CreateTrackResponse& output) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 265 | { |
| 266 | Parcel data, reply; |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 267 | status_t status; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 268 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 269 | data.writeParcelable(input); |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 270 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply); |
| 272 | if (lStatus != NO_ERROR) { |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 273 | ALOGE("createTrack transaction error %d", lStatus); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 274 | return DEAD_OBJECT; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 275 | } |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 276 | status = reply.readInt32(); |
| 277 | if (status != NO_ERROR) { |
| 278 | ALOGE("createTrack returned error %d", status); |
| 279 | return status; |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 280 | } |
| 281 | output.readFromParcel(&reply); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 282 | if (output.audioTrack == 0) { |
| 283 | ALOGE("createTrack returned an NULL IAudioTrack with status OK"); |
| 284 | return DEAD_OBJECT; |
| 285 | } |
| 286 | return OK; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | } |
| 288 | |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 289 | virtual status_t createRecord(const media::CreateRecordRequest& input, |
| 290 | media::CreateRecordResponse& output) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 291 | { |
| 292 | Parcel data, reply; |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 293 | status_t status; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 294 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 295 | |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 296 | data.writeParcelable(input); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 297 | |
| 298 | status_t lStatus = remote()->transact(CREATE_RECORD, data, &reply); |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 299 | if (lStatus != NO_ERROR) { |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 300 | ALOGE("createRecord transaction error %d", lStatus); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 301 | return DEAD_OBJECT; |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 302 | } |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 303 | status = reply.readInt32(); |
| 304 | if (status != NO_ERROR) { |
| 305 | ALOGE("createRecord returned error %d", status); |
| 306 | return status; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 307 | } |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 308 | |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 309 | output.readFromParcel(&reply); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 310 | if (output.audioRecord == 0) { |
| 311 | ALOGE("createRecord returned a NULL IAudioRecord with status OK"); |
| 312 | return DEAD_OBJECT; |
| 313 | } |
| 314 | return OK; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 317 | virtual uint32_t sampleRate(audio_io_handle_t ioHandle) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 318 | { |
| 319 | Parcel data, reply; |
| 320 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 321 | data.writeInt32((int32_t) ioHandle); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 322 | remote()->transact(SAMPLE_RATE, data, &reply); |
| 323 | return reply.readInt32(); |
| 324 | } |
| 325 | |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 326 | // RESERVED for channelCount() |
| 327 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 328 | virtual audio_format_t format(audio_io_handle_t output) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 329 | { |
| 330 | Parcel data, reply; |
| 331 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 332 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 333 | remote()->transact(FORMAT, data, &reply); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 334 | return (audio_format_t) reply.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 335 | } |
| 336 | |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 337 | virtual size_t frameCount(audio_io_handle_t ioHandle) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 338 | { |
| 339 | Parcel data, reply; |
| 340 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 341 | data.writeInt32((int32_t) ioHandle); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | remote()->transact(FRAME_COUNT, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 343 | return reply.readInt64(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 344 | } |
| 345 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 346 | virtual uint32_t latency(audio_io_handle_t output) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 347 | { |
| 348 | Parcel data, reply; |
| 349 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 350 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 351 | remote()->transact(LATENCY, data, &reply); |
| 352 | return reply.readInt32(); |
| 353 | } |
| 354 | |
| 355 | virtual status_t setMasterVolume(float value) |
| 356 | { |
| 357 | Parcel data, reply; |
| 358 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 359 | data.writeFloat(value); |
| 360 | remote()->transact(SET_MASTER_VOLUME, data, &reply); |
| 361 | return reply.readInt32(); |
| 362 | } |
| 363 | |
| 364 | virtual status_t setMasterMute(bool muted) |
| 365 | { |
| 366 | Parcel data, reply; |
| 367 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 368 | data.writeInt32(muted); |
| 369 | remote()->transact(SET_MASTER_MUTE, data, &reply); |
| 370 | return reply.readInt32(); |
| 371 | } |
| 372 | |
| 373 | virtual float masterVolume() const |
| 374 | { |
| 375 | Parcel data, reply; |
| 376 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 377 | remote()->transact(MASTER_VOLUME, data, &reply); |
| 378 | return reply.readFloat(); |
| 379 | } |
| 380 | |
| 381 | virtual bool masterMute() const |
| 382 | { |
| 383 | Parcel data, reply; |
| 384 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 385 | remote()->transact(MASTER_MUTE, data, &reply); |
| 386 | return reply.readInt32(); |
| 387 | } |
| 388 | |
Richard Folke Tullberg | 3fae037 | 2017-01-13 09:04:25 +0100 | [diff] [blame] | 389 | status_t setMasterBalance(float balance) override |
| 390 | { |
| 391 | Parcel data, reply; |
| 392 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 393 | data.writeFloat(balance); |
| 394 | status_t status = remote()->transact(SET_MASTER_BALANCE, data, &reply); |
| 395 | if (status != NO_ERROR) { |
| 396 | return status; |
| 397 | } |
| 398 | return reply.readInt32(); |
| 399 | } |
| 400 | |
| 401 | status_t getMasterBalance(float *balance) const override |
| 402 | { |
| 403 | Parcel data, reply; |
| 404 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 405 | status_t status = remote()->transact(GET_MASTER_BALANCE, data, &reply); |
| 406 | if (status != NO_ERROR) { |
| 407 | return status; |
| 408 | } |
| 409 | status = (status_t)reply.readInt32(); |
| 410 | if (status != NO_ERROR) { |
| 411 | return status; |
| 412 | } |
| 413 | *balance = reply.readFloat(); |
| 414 | return NO_ERROR; |
| 415 | } |
| 416 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 417 | virtual status_t setStreamVolume(audio_stream_type_t stream, float value, |
| 418 | audio_io_handle_t output) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 419 | { |
| 420 | Parcel data, reply; |
| 421 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 422 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 423 | data.writeFloat(value); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 424 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 425 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 426 | return reply.readInt32(); |
| 427 | } |
| 428 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 429 | virtual status_t setStreamMute(audio_stream_type_t stream, bool muted) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 430 | { |
| 431 | Parcel data, reply; |
| 432 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 433 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 434 | data.writeInt32(muted); |
| 435 | remote()->transact(SET_STREAM_MUTE, data, &reply); |
| 436 | return reply.readInt32(); |
| 437 | } |
| 438 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 439 | virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 440 | { |
| 441 | Parcel data, reply; |
| 442 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 443 | data.writeInt32((int32_t) stream); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 444 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 445 | remote()->transact(STREAM_VOLUME, data, &reply); |
| 446 | return reply.readFloat(); |
| 447 | } |
| 448 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 449 | virtual bool streamMute(audio_stream_type_t stream) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 450 | { |
| 451 | Parcel data, reply; |
| 452 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 453 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 454 | remote()->transact(STREAM_MUTE, data, &reply); |
| 455 | return reply.readInt32(); |
| 456 | } |
| 457 | |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 458 | virtual status_t setMode(audio_mode_t mode) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 459 | { |
| 460 | Parcel data, reply; |
| 461 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 462 | data.writeInt32(mode); |
| 463 | remote()->transact(SET_MODE, data, &reply); |
| 464 | return reply.readInt32(); |
| 465 | } |
| 466 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | virtual status_t setMicMute(bool state) |
| 468 | { |
| 469 | Parcel data, reply; |
| 470 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 471 | data.writeInt32(state); |
| 472 | remote()->transact(SET_MIC_MUTE, data, &reply); |
| 473 | return reply.readInt32(); |
| 474 | } |
| 475 | |
| 476 | virtual bool getMicMute() const |
| 477 | { |
| 478 | Parcel data, reply; |
| 479 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 480 | remote()->transact(GET_MIC_MUTE, data, &reply); |
| 481 | return reply.readInt32(); |
| 482 | } |
| 483 | |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 484 | virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced) |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 485 | { |
| 486 | Parcel data, reply; |
| 487 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 488 | data.writeInt32(portId); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 489 | data.writeInt32(silenced ? 1 : 0); |
| 490 | remote()->transact(SET_RECORD_SILENCED, data, &reply); |
| 491 | } |
| 492 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 493 | virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 494 | { |
| 495 | Parcel data, reply; |
| 496 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 497 | data.writeInt32((int32_t) ioHandle); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 498 | data.writeString8(keyValuePairs); |
| 499 | remote()->transact(SET_PARAMETERS, data, &reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | return reply.readInt32(); |
| 501 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 502 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 503 | virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 504 | { |
| 505 | Parcel data, reply; |
| 506 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 507 | data.writeInt32((int32_t) ioHandle); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 508 | data.writeString8(keys); |
| 509 | remote()->transact(GET_PARAMETERS, data, &reply); |
| 510 | return reply.readString8(); |
| 511 | } |
| 512 | |
Ytai Ben-Tsvi | 10dc0a6 | 2020-09-18 11:31:55 -0700 | [diff] [blame] | 513 | virtual void registerClient(const sp<media::IAudioFlingerClient>& client) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | { |
| 515 | Parcel data, reply; |
| 516 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 517 | data.writeStrongBinder(IInterface::asBinder(client)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 518 | remote()->transact(REGISTER_CLIENT, data, &reply); |
| 519 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 520 | |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 521 | virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, |
| 522 | audio_channel_mask_t channelMask) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 523 | { |
| 524 | Parcel data, reply; |
| 525 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 526 | data.writeInt32(sampleRate); |
| 527 | data.writeInt32(format); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 528 | data.writeInt32(channelMask); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 529 | remote()->transact(GET_INPUTBUFFERSIZE, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 530 | return reply.readInt64(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 531 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 532 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 533 | virtual status_t openOutput(audio_module_handle_t module, |
| 534 | audio_io_handle_t *output, |
| 535 | audio_config_t *config, |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame] | 536 | const sp<DeviceDescriptorBase>& device, |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 537 | uint32_t *latencyMs, |
| 538 | audio_output_flags_t flags) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 539 | { |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame] | 540 | if (output == nullptr || config == nullptr || device == nullptr || latencyMs == nullptr) { |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 541 | return BAD_VALUE; |
| 542 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 543 | Parcel data, reply; |
| 544 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 545 | data.writeInt32(module); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 546 | data.write(config, sizeof(audio_config_t)); |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame] | 547 | data.writeParcelable(*device); |
Glenn Kasten | 18868c5 | 2012-03-07 09:15:37 -0800 | [diff] [blame] | 548 | data.writeInt32((int32_t) flags); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 549 | status_t status = remote()->transact(OPEN_OUTPUT, data, &reply); |
| 550 | if (status != NO_ERROR) { |
| 551 | *output = AUDIO_IO_HANDLE_NONE; |
| 552 | return status; |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 553 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 554 | status = (status_t)reply.readInt32(); |
| 555 | if (status != NO_ERROR) { |
| 556 | *output = AUDIO_IO_HANDLE_NONE; |
| 557 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 558 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 559 | *output = (audio_io_handle_t)reply.readInt32(); |
| 560 | ALOGV("openOutput() returned output, %d", *output); |
| 561 | reply.read(config, sizeof(audio_config_t)); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 562 | *latencyMs = reply.readInt32(); |
| 563 | return NO_ERROR; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 564 | } |
| 565 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 566 | virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, |
| 567 | audio_io_handle_t output2) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | { |
| 569 | Parcel data, reply; |
| 570 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 571 | data.writeInt32((int32_t) output1); |
| 572 | data.writeInt32((int32_t) output2); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 573 | remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 574 | return (audio_io_handle_t) reply.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 575 | } |
| 576 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 577 | virtual status_t closeOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 578 | { |
| 579 | Parcel data, reply; |
| 580 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 581 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 582 | remote()->transact(CLOSE_OUTPUT, data, &reply); |
| 583 | return reply.readInt32(); |
| 584 | } |
| 585 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 586 | virtual status_t suspendOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 587 | { |
| 588 | Parcel data, reply; |
| 589 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 590 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 591 | remote()->transact(SUSPEND_OUTPUT, data, &reply); |
| 592 | return reply.readInt32(); |
| 593 | } |
| 594 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 595 | virtual status_t restoreOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 596 | { |
| 597 | Parcel data, reply; |
| 598 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 599 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 600 | remote()->transact(RESTORE_OUTPUT, data, &reply); |
| 601 | return reply.readInt32(); |
| 602 | } |
| 603 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 604 | virtual status_t openInput(audio_module_handle_t module, |
| 605 | audio_io_handle_t *input, |
| 606 | audio_config_t *config, |
| 607 | audio_devices_t *device, |
| 608 | const String8& address, |
| 609 | audio_source_t source, |
| 610 | audio_input_flags_t flags) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 611 | { |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 612 | if (input == NULL || config == NULL || device == NULL) { |
| 613 | return BAD_VALUE; |
| 614 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 615 | Parcel data, reply; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 616 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 617 | data.writeInt32(module); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 618 | data.writeInt32(*input); |
| 619 | data.write(config, sizeof(audio_config_t)); |
| 620 | data.writeInt32(*device); |
| 621 | data.writeString8(address); |
| 622 | data.writeInt32(source); |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 623 | data.writeInt32(flags); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 624 | status_t status = remote()->transact(OPEN_INPUT, data, &reply); |
| 625 | if (status != NO_ERROR) { |
| 626 | *input = AUDIO_IO_HANDLE_NONE; |
| 627 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 628 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 629 | status = (status_t)reply.readInt32(); |
| 630 | if (status != NO_ERROR) { |
| 631 | *input = AUDIO_IO_HANDLE_NONE; |
| 632 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 633 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 634 | *input = (audio_io_handle_t)reply.readInt32(); |
| 635 | reply.read(config, sizeof(audio_config_t)); |
| 636 | *device = (audio_devices_t)reply.readInt32(); |
| 637 | return NO_ERROR; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 638 | } |
| 639 | |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 640 | virtual status_t closeInput(int input) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 641 | { |
| 642 | Parcel data, reply; |
| 643 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 644 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 645 | remote()->transact(CLOSE_INPUT, data, &reply); |
| 646 | return reply.readInt32(); |
| 647 | } |
| 648 | |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 649 | virtual status_t invalidateStream(audio_stream_type_t stream) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 650 | { |
| 651 | Parcel data, reply; |
| 652 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 653 | data.writeInt32((int32_t) stream); |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 654 | remote()->transact(INVALIDATE_STREAM, data, &reply); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 655 | return reply.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 656 | } |
Eric Laurent | f0ee6f4 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 657 | |
| 658 | virtual status_t setVoiceVolume(float volume) |
| 659 | { |
| 660 | Parcel data, reply; |
| 661 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 662 | data.writeFloat(volume); |
| 663 | remote()->transact(SET_VOICE_VOLUME, data, &reply); |
| 664 | return reply.readInt32(); |
| 665 | } |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 666 | |
Kévin PETIT | 377b2ec | 2014-02-03 12:35:36 +0000 | [diff] [blame] | 667 | virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 668 | audio_io_handle_t output) const |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 669 | { |
| 670 | Parcel data, reply; |
| 671 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 672 | data.writeInt32((int32_t) output); |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 673 | remote()->transact(GET_RENDER_POSITION, data, &reply); |
| 674 | status_t status = reply.readInt32(); |
| 675 | if (status == NO_ERROR) { |
| 676 | uint32_t tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 677 | if (halFrames != NULL) { |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 678 | *halFrames = tmp; |
| 679 | } |
| 680 | tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 681 | if (dspFrames != NULL) { |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 682 | *dspFrames = tmp; |
| 683 | } |
| 684 | } |
| 685 | return status; |
| 686 | } |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 687 | |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 688 | virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 689 | { |
| 690 | Parcel data, reply; |
| 691 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 692 | data.writeInt32((int32_t) ioHandle); |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 693 | status_t status = remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply); |
| 694 | if (status != NO_ERROR) { |
| 695 | return 0; |
| 696 | } |
| 697 | return (uint32_t) reply.readInt32(); |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 698 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 699 | |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 700 | virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use) |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 701 | { |
| 702 | Parcel data, reply; |
| 703 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 704 | data.writeInt32((int32_t) use); |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 705 | status_t status = remote()->transact(NEW_AUDIO_UNIQUE_ID, data, &reply); |
| 706 | audio_unique_id_t id = AUDIO_UNIQUE_ID_ALLOCATE; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 707 | if (status == NO_ERROR) { |
| 708 | id = reply.readInt32(); |
| 709 | } |
| 710 | return id; |
| 711 | } |
| 712 | |
Andy Hung | 8b0bfd9 | 2019-12-23 13:11:11 -0800 | [diff] [blame] | 713 | void acquireAudioSessionId(audio_session_t audioSession, pid_t pid, uid_t uid) override |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 714 | { |
| 715 | Parcel data, reply; |
| 716 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 717 | data.writeInt32(audioSession); |
Andy Hung | 8b0bfd9 | 2019-12-23 13:11:11 -0800 | [diff] [blame] | 718 | data.writeInt32((int32_t)pid); |
| 719 | data.writeInt32((int32_t)uid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 720 | remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply); |
| 721 | } |
| 722 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 723 | virtual void releaseAudioSessionId(audio_session_t audioSession, int pid) |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 724 | { |
| 725 | Parcel data, reply; |
| 726 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 727 | data.writeInt32(audioSession); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 728 | data.writeInt32(pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 729 | remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply); |
| 730 | } |
| 731 | |
Glenn Kasten | f587ba5 | 2012-01-26 16:25:10 -0800 | [diff] [blame] | 732 | virtual status_t queryNumberEffects(uint32_t *numEffects) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 733 | { |
| 734 | Parcel data, reply; |
| 735 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 736 | status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply); |
| 737 | if (status != NO_ERROR) { |
| 738 | return status; |
| 739 | } |
| 740 | status = reply.readInt32(); |
| 741 | if (status != NO_ERROR) { |
| 742 | return status; |
| 743 | } |
Glenn Kasten | 9d1f02d | 2012-02-08 17:47:58 -0800 | [diff] [blame] | 744 | if (numEffects != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 745 | *numEffects = (uint32_t)reply.readInt32(); |
| 746 | } |
| 747 | return NO_ERROR; |
| 748 | } |
| 749 | |
Glenn Kasten | f587ba5 | 2012-01-26 16:25:10 -0800 | [diff] [blame] | 750 | virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 751 | { |
| 752 | if (pDescriptor == NULL) { |
| 753 | return BAD_VALUE; |
| 754 | } |
| 755 | Parcel data, reply; |
| 756 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 757 | data.writeInt32(index); |
| 758 | status_t status = remote()->transact(QUERY_EFFECT, data, &reply); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 759 | if (status != NO_ERROR) { |
| 760 | return status; |
| 761 | } |
| 762 | status = reply.readInt32(); |
| 763 | if (status != NO_ERROR) { |
| 764 | return status; |
| 765 | } |
| 766 | reply.read(pDescriptor, sizeof(effect_descriptor_t)); |
| 767 | return NO_ERROR; |
| 768 | } |
| 769 | |
Glenn Kasten | 5e92a78 | 2012-01-30 07:40:52 -0800 | [diff] [blame] | 770 | virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid, |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 771 | const effect_uuid_t *pType, |
| 772 | uint32_t preferredTypeFlag, |
| 773 | effect_descriptor_t *pDescriptor) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 774 | { |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 775 | if (pUuid == NULL || pType == NULL || pDescriptor == NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 776 | return BAD_VALUE; |
| 777 | } |
| 778 | Parcel data, reply; |
| 779 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 780 | data.write(pUuid, sizeof(effect_uuid_t)); |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 781 | data.write(pType, sizeof(effect_uuid_t)); |
| 782 | data.writeUint32(preferredTypeFlag); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 783 | status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply); |
| 784 | if (status != NO_ERROR) { |
| 785 | return status; |
| 786 | } |
| 787 | status = reply.readInt32(); |
| 788 | if (status != NO_ERROR) { |
| 789 | return status; |
| 790 | } |
| 791 | reply.read(pDescriptor, sizeof(effect_descriptor_t)); |
| 792 | return NO_ERROR; |
| 793 | } |
| 794 | |
Ytai Ben-Tsvi | ce18294 | 2020-11-04 14:48:01 -0800 | [diff] [blame^] | 795 | virtual status_t createEffect(const media::CreateEffectRequest& request, |
| 796 | media::CreateEffectResponse* response) |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 797 | { |
| 798 | Parcel data, reply; |
Ytai Ben-Tsvi | 9cd8981 | 2020-07-01 17:12:06 -0700 | [diff] [blame] | 799 | sp<media::IEffect> effect; |
Ytai Ben-Tsvi | ce18294 | 2020-11-04 14:48:01 -0800 | [diff] [blame^] | 800 | if (response == nullptr) { |
| 801 | return BAD_VALUE; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 802 | } |
Ytai Ben-Tsvi | ce18294 | 2020-11-04 14:48:01 -0800 | [diff] [blame^] | 803 | status_t status; |
| 804 | status_t lStatus = data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()) |
| 805 | ?: data.writeParcelable(request) |
| 806 | ?: remote()->transact(CREATE_EFFECT, data, &reply) |
| 807 | ?: reply.readInt32(&status) |
| 808 | ?: reply.readParcelable(response) |
| 809 | ?: status; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 810 | if (lStatus != NO_ERROR) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 811 | ALOGE("createEffect error: %s", strerror(-lStatus)); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 812 | } |
Ytai Ben-Tsvi | ce18294 | 2020-11-04 14:48:01 -0800 | [diff] [blame^] | 813 | return lStatus; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 814 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 815 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 816 | virtual status_t moveEffects(audio_session_t session, audio_io_handle_t srcOutput, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 817 | audio_io_handle_t dstOutput) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 818 | { |
| 819 | Parcel data, reply; |
| 820 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 821 | data.writeInt32(session); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 822 | data.writeInt32((int32_t) srcOutput); |
| 823 | data.writeInt32((int32_t) dstOutput); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 824 | remote()->transact(MOVE_EFFECTS, data, &reply); |
| 825 | return reply.readInt32(); |
| 826 | } |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 827 | |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 828 | virtual void setEffectSuspended(int effectId, |
| 829 | audio_session_t sessionId, |
| 830 | bool suspended) |
| 831 | { |
| 832 | Parcel data, reply; |
| 833 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 834 | data.writeInt32(effectId); |
| 835 | data.writeInt32(sessionId); |
| 836 | data.writeInt32(suspended ? 1 : 0); |
| 837 | remote()->transact(SET_EFFECT_SUSPENDED, data, &reply); |
| 838 | } |
| 839 | |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 840 | virtual audio_module_handle_t loadHwModule(const char *name) |
| 841 | { |
| 842 | Parcel data, reply; |
| 843 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 844 | data.writeCString(name); |
| 845 | remote()->transact(LOAD_HW_MODULE, data, &reply); |
| 846 | return (audio_module_handle_t) reply.readInt32(); |
| 847 | } |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 848 | |
Glenn Kasten | 3b16c76 | 2012-11-14 08:44:39 -0800 | [diff] [blame] | 849 | virtual uint32_t getPrimaryOutputSamplingRate() |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 850 | { |
| 851 | Parcel data, reply; |
| 852 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 853 | remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply); |
| 854 | return reply.readInt32(); |
| 855 | } |
| 856 | |
Glenn Kasten | e33054e | 2012-11-14 12:54:39 -0800 | [diff] [blame] | 857 | virtual size_t getPrimaryOutputFrameCount() |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 858 | { |
| 859 | Parcel data, reply; |
| 860 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 861 | remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 862 | return reply.readInt64(); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 863 | } |
| 864 | |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 865 | virtual status_t setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) override |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 866 | { |
| 867 | Parcel data, reply; |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 868 | |
| 869 | static_assert(NO_ERROR == 0, "NO_ERROR must be 0"); |
| 870 | return data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()) |
| 871 | ?: data.writeInt32((int) isLowRamDevice) |
| 872 | ?: data.writeInt64(totalMemory) |
| 873 | ?: remote()->transact(SET_LOW_RAM_DEVICE, data, &reply) |
| 874 | ?: reply.readInt32(); |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 875 | } |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 876 | |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 877 | virtual status_t listAudioPorts(unsigned int *num_ports, |
| 878 | struct audio_port *ports) |
| 879 | { |
| 880 | if (num_ports == NULL || *num_ports == 0 || ports == NULL) { |
| 881 | return BAD_VALUE; |
| 882 | } |
| 883 | Parcel data, reply; |
| 884 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 885 | data.writeInt32(*num_ports); |
| 886 | status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); |
| 887 | if (status != NO_ERROR || |
| 888 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 889 | return status; |
| 890 | } |
| 891 | *num_ports = (unsigned int)reply.readInt32(); |
| 892 | reply.read(ports, *num_ports * sizeof(struct audio_port)); |
| 893 | return status; |
| 894 | } |
jiabin | b4fed19 | 2020-09-22 14:45:40 -0700 | [diff] [blame] | 895 | virtual status_t getAudioPort(struct audio_port_v7 *port) |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 896 | { |
jiabin | b4fed19 | 2020-09-22 14:45:40 -0700 | [diff] [blame] | 897 | if (port == nullptr) { |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 898 | return BAD_VALUE; |
| 899 | } |
| 900 | Parcel data, reply; |
| 901 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
jiabin | b4fed19 | 2020-09-22 14:45:40 -0700 | [diff] [blame] | 902 | data.write(port, sizeof(struct audio_port_v7)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 903 | status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); |
| 904 | if (status != NO_ERROR || |
| 905 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 906 | return status; |
| 907 | } |
| 908 | reply.read(port, sizeof(struct audio_port)); |
| 909 | return status; |
| 910 | } |
| 911 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 912 | audio_patch_handle_t *handle) |
| 913 | { |
| 914 | if (patch == NULL || handle == NULL) { |
| 915 | return BAD_VALUE; |
| 916 | } |
| 917 | Parcel data, reply; |
| 918 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 919 | data.write(patch, sizeof(struct audio_patch)); |
| 920 | data.write(handle, sizeof(audio_patch_handle_t)); |
| 921 | status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); |
| 922 | if (status != NO_ERROR || |
| 923 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 924 | return status; |
| 925 | } |
| 926 | reply.read(handle, sizeof(audio_patch_handle_t)); |
| 927 | return status; |
| 928 | } |
| 929 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle) |
| 930 | { |
| 931 | Parcel data, reply; |
| 932 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 933 | data.write(&handle, sizeof(audio_patch_handle_t)); |
| 934 | status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); |
| 935 | if (status != NO_ERROR) { |
| 936 | status = (status_t)reply.readInt32(); |
| 937 | } |
| 938 | return status; |
| 939 | } |
| 940 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 941 | struct audio_patch *patches) |
| 942 | { |
| 943 | if (num_patches == NULL || *num_patches == 0 || patches == NULL) { |
| 944 | return BAD_VALUE; |
| 945 | } |
| 946 | Parcel data, reply; |
| 947 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 948 | data.writeInt32(*num_patches); |
| 949 | status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); |
| 950 | if (status != NO_ERROR || |
| 951 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 952 | return status; |
| 953 | } |
| 954 | *num_patches = (unsigned int)reply.readInt32(); |
| 955 | reply.read(patches, *num_patches * sizeof(struct audio_patch)); |
| 956 | return status; |
| 957 | } |
| 958 | virtual status_t setAudioPortConfig(const struct audio_port_config *config) |
| 959 | { |
| 960 | if (config == NULL) { |
| 961 | return BAD_VALUE; |
| 962 | } |
| 963 | Parcel data, reply; |
| 964 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 965 | data.write(config, sizeof(struct audio_port_config)); |
| 966 | status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); |
| 967 | if (status != NO_ERROR) { |
| 968 | status = (status_t)reply.readInt32(); |
| 969 | } |
| 970 | return status; |
| 971 | } |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 972 | virtual audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId) |
| 973 | { |
| 974 | Parcel data, reply; |
| 975 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 976 | data.writeInt32(sessionId); |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 977 | status_t status = remote()->transact(GET_AUDIO_HW_SYNC_FOR_SESSION, data, &reply); |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 978 | if (status != NO_ERROR) { |
| 979 | return AUDIO_HW_SYNC_INVALID; |
| 980 | } |
| 981 | return (audio_hw_sync_t)reply.readInt32(); |
| 982 | } |
Eric Laurent | 72e3f39 | 2015-05-20 14:43:50 -0700 | [diff] [blame] | 983 | virtual status_t systemReady() |
| 984 | { |
| 985 | Parcel data, reply; |
| 986 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 987 | return remote()->transact(SYSTEM_READY, data, &reply, IBinder::FLAG_ONEWAY); |
| 988 | } |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 989 | virtual size_t frameCountHAL(audio_io_handle_t ioHandle) const |
| 990 | { |
| 991 | Parcel data, reply; |
| 992 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 993 | data.writeInt32((int32_t) ioHandle); |
| 994 | status_t status = remote()->transact(FRAME_COUNT_HAL, data, &reply); |
| 995 | if (status != NO_ERROR) { |
| 996 | return 0; |
| 997 | } |
| 998 | return reply.readInt64(); |
| 999 | } |
jiabin | 46a76fa | 2018-01-05 10:18:21 -0800 | [diff] [blame] | 1000 | virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones) |
| 1001 | { |
| 1002 | Parcel data, reply; |
| 1003 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
jiabin | 9ff780e | 2018-03-19 18:19:52 -0700 | [diff] [blame] | 1004 | status_t status = remote()->transact(GET_MICROPHONES, data, &reply); |
jiabin | 46a76fa | 2018-01-05 10:18:21 -0800 | [diff] [blame] | 1005 | if (status != NO_ERROR || |
| 1006 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 1007 | return status; |
| 1008 | } |
| 1009 | status = reply.readParcelableVector(microphones); |
| 1010 | return status; |
| 1011 | } |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 1012 | virtual status_t setAudioHalPids(const std::vector<pid_t>& pids) |
| 1013 | { |
| 1014 | Parcel data, reply; |
| 1015 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 1016 | data.writeInt32(pids.size()); |
| 1017 | for (auto pid : pids) { |
| 1018 | data.writeInt32(pid); |
| 1019 | } |
| 1020 | status_t status = remote()->transact(SET_AUDIO_HAL_PIDS, data, &reply); |
| 1021 | if (status != NO_ERROR) { |
| 1022 | return status; |
| 1023 | } |
| 1024 | return static_cast <status_t> (reply.readInt32()); |
| 1025 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1026 | }; |
| 1027 | |
| 1028 | IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger"); |
| 1029 | |
| 1030 | // ---------------------------------------------------------------------- |
| 1031 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1032 | status_t BnAudioFlinger::onTransact( |
| 1033 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 1034 | { |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1035 | // make sure transactions reserved to AudioPolicyManager do not come from other processes |
| 1036 | switch (code) { |
| 1037 | case SET_STREAM_VOLUME: |
| 1038 | case SET_STREAM_MUTE: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1039 | case OPEN_OUTPUT: |
| 1040 | case OPEN_DUPLICATE_OUTPUT: |
| 1041 | case CLOSE_OUTPUT: |
| 1042 | case SUSPEND_OUTPUT: |
| 1043 | case RESTORE_OUTPUT: |
| 1044 | case OPEN_INPUT: |
| 1045 | case CLOSE_INPUT: |
| 1046 | case INVALIDATE_STREAM: |
| 1047 | case SET_VOICE_VOLUME: |
| 1048 | case MOVE_EFFECTS: |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 1049 | case SET_EFFECT_SUSPENDED: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1050 | case LOAD_HW_MODULE: |
| 1051 | case LIST_AUDIO_PORTS: |
| 1052 | case GET_AUDIO_PORT: |
| 1053 | case CREATE_AUDIO_PATCH: |
| 1054 | case RELEASE_AUDIO_PATCH: |
| 1055 | case LIST_AUDIO_PATCHES: |
| 1056 | case SET_AUDIO_PORT_CONFIG: |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1057 | case SET_RECORD_SILENCED: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1058 | ALOGW("%s: transaction %d received from PID %d", |
| 1059 | __func__, code, IPCThreadState::self()->getCallingPid()); |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 1060 | // return status only for non void methods |
| 1061 | switch (code) { |
| 1062 | case SET_RECORD_SILENCED: |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 1063 | case SET_EFFECT_SUSPENDED: |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 1064 | break; |
| 1065 | default: |
| 1066 | reply->writeInt32(static_cast<int32_t> (INVALID_OPERATION)); |
| 1067 | break; |
| 1068 | } |
| 1069 | return OK; |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1070 | default: |
| 1071 | break; |
| 1072 | } |
| 1073 | |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1074 | // make sure the following transactions come from system components |
| 1075 | switch (code) { |
| 1076 | case SET_MASTER_VOLUME: |
| 1077 | case SET_MASTER_MUTE: |
| 1078 | case SET_MODE: |
| 1079 | case SET_MIC_MUTE: |
| 1080 | case SET_LOW_RAM_DEVICE: |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 1081 | case SYSTEM_READY: |
| 1082 | case SET_AUDIO_HAL_PIDS: { |
Andy Hung | 4ef19fa | 2018-05-15 19:35:29 -0700 | [diff] [blame] | 1083 | if (!isServiceUid(IPCThreadState::self()->getCallingUid())) { |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1084 | ALOGW("%s: transaction %d received from PID %d unauthorized UID %d", |
| 1085 | __func__, code, IPCThreadState::self()->getCallingPid(), |
| 1086 | IPCThreadState::self()->getCallingUid()); |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 1087 | // return status only for non void methods |
| 1088 | switch (code) { |
| 1089 | case SYSTEM_READY: |
| 1090 | break; |
| 1091 | default: |
| 1092 | reply->writeInt32(static_cast<int32_t> (INVALID_OPERATION)); |
| 1093 | break; |
| 1094 | } |
| 1095 | return OK; |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1096 | } |
Eric Laurent | 96c7eed | 2018-03-26 17:57:01 -0700 | [diff] [blame] | 1097 | } break; |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 1098 | default: |
| 1099 | break; |
| 1100 | } |
| 1101 | |
Glenn Kasten | 67f9570 | 2020-06-22 16:42:52 -0700 | [diff] [blame] | 1102 | // List of relevant events that trigger log merging. |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 1103 | // Log merging should activate during audio activity of any kind. This are considered the |
| 1104 | // most relevant events. |
| 1105 | // TODO should select more wisely the items from the list |
| 1106 | switch (code) { |
| 1107 | case CREATE_TRACK: |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1108 | case CREATE_RECORD: |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 1109 | case SET_MASTER_VOLUME: |
| 1110 | case SET_MASTER_MUTE: |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 1111 | case SET_MIC_MUTE: |
| 1112 | case SET_PARAMETERS: |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 1113 | case CREATE_EFFECT: |
| 1114 | case SYSTEM_READY: { |
| 1115 | requestLogMerge(); |
| 1116 | break; |
| 1117 | } |
| 1118 | default: |
| 1119 | break; |
| 1120 | } |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 1121 | |
Eric Laurent | 39b09b5 | 2018-06-29 12:24:40 -0700 | [diff] [blame] | 1122 | std::string tag("IAudioFlinger command " + std::to_string(code)); |
| 1123 | TimeCheck check(tag.c_str()); |
Eric Laurent | 3528c93 | 2018-02-23 17:17:22 -0800 | [diff] [blame] | 1124 | |
Eric Laurent | 14dc3cb | 2020-09-16 18:42:23 -0700 | [diff] [blame] | 1125 | // Make sure we connect to Audio Policy Service before calling into AudioFlinger: |
| 1126 | // - AudioFlinger can call into Audio Policy Service with its global mutex held |
| 1127 | // - If this is the first time Audio Policy Service is queried from inside audioserver process |
| 1128 | // this will trigger Audio Policy Manager initialization. |
| 1129 | // - Audio Policy Manager initialization calls into AudioFlinger which will try to lock |
| 1130 | // its global mutex and a deadlock will occur. |
| 1131 | if (IPCThreadState::self()->getCallingPid() != getpid()) { |
| 1132 | AudioSystem::get_audio_policy_service(); |
| 1133 | } |
| 1134 | |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1135 | switch (code) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1136 | case CREATE_TRACK: { |
| 1137 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1138 | |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 1139 | media::CreateTrackRequest input; |
| 1140 | if (data.readParcelable(&input) != NO_ERROR) { |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1141 | reply->writeInt32(DEAD_OBJECT); |
| 1142 | return NO_ERROR; |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 1143 | } |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1144 | |
| 1145 | status_t status; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 1146 | media::CreateTrackResponse output; |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1147 | |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 1148 | status = createTrack(input, output); |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1149 | |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 1150 | LOG_ALWAYS_FATAL_IF((output.audioTrack != 0) != (status == NO_ERROR)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1151 | reply->writeInt32(status); |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1152 | if (status != NO_ERROR) { |
| 1153 | return NO_ERROR; |
| 1154 | } |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1155 | output.writeToParcel(reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1156 | return NO_ERROR; |
| 1157 | } break; |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1158 | case CREATE_RECORD: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1159 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1160 | |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 1161 | media::CreateRecordRequest input; |
| 1162 | if (data.readParcelable(&input) != NO_ERROR) { |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1163 | reply->writeInt32(DEAD_OBJECT); |
| 1164 | return NO_ERROR; |
| 1165 | } |
| 1166 | |
| 1167 | status_t status; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 1168 | media::CreateRecordResponse output; |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1169 | |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 1170 | status = createRecord(input, output); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1171 | |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 1172 | LOG_ALWAYS_FATAL_IF((output.audioRecord != 0) != (status == NO_ERROR)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1173 | reply->writeInt32(status); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1174 | if (status != NO_ERROR) { |
| 1175 | return NO_ERROR; |
| 1176 | } |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1177 | output.writeToParcel(reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1178 | return NO_ERROR; |
| 1179 | } break; |
| 1180 | case SAMPLE_RATE: { |
| 1181 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1182 | reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1183 | return NO_ERROR; |
| 1184 | } break; |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 1185 | |
| 1186 | // RESERVED for channelCount() |
| 1187 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1188 | case FORMAT: { |
| 1189 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1190 | reply->writeInt32( format((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1191 | return NO_ERROR; |
| 1192 | } break; |
| 1193 | case FRAME_COUNT: { |
| 1194 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1195 | reply->writeInt64( frameCount((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1196 | return NO_ERROR; |
| 1197 | } break; |
| 1198 | case LATENCY: { |
| 1199 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1200 | reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1201 | return NO_ERROR; |
| 1202 | } break; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1203 | case SET_MASTER_VOLUME: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1204 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1205 | reply->writeInt32( setMasterVolume(data.readFloat()) ); |
| 1206 | return NO_ERROR; |
| 1207 | } break; |
| 1208 | case SET_MASTER_MUTE: { |
| 1209 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1210 | reply->writeInt32( setMasterMute(data.readInt32()) ); |
| 1211 | return NO_ERROR; |
| 1212 | } break; |
| 1213 | case MASTER_VOLUME: { |
| 1214 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1215 | reply->writeFloat( masterVolume() ); |
| 1216 | return NO_ERROR; |
| 1217 | } break; |
| 1218 | case MASTER_MUTE: { |
| 1219 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1220 | reply->writeInt32( masterMute() ); |
| 1221 | return NO_ERROR; |
| 1222 | } break; |
Richard Folke Tullberg | 3fae037 | 2017-01-13 09:04:25 +0100 | [diff] [blame] | 1223 | case SET_MASTER_BALANCE: { |
| 1224 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1225 | reply->writeInt32( setMasterBalance(data.readFloat()) ); |
| 1226 | return NO_ERROR; |
| 1227 | } break; |
| 1228 | case GET_MASTER_BALANCE: { |
| 1229 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1230 | float f; |
| 1231 | const status_t status = getMasterBalance(&f); |
| 1232 | reply->writeInt32((int32_t)status); |
| 1233 | if (status == NO_ERROR) { |
| 1234 | (void)reply->writeFloat(f); |
| 1235 | } |
| 1236 | return NO_ERROR; |
| 1237 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1238 | case SET_STREAM_VOLUME: { |
| 1239 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1240 | int stream = data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1241 | float volume = data.readFloat(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1242 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1243 | reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1244 | return NO_ERROR; |
| 1245 | } break; |
| 1246 | case SET_STREAM_MUTE: { |
| 1247 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1248 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1249 | reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1250 | return NO_ERROR; |
| 1251 | } break; |
| 1252 | case STREAM_VOLUME: { |
| 1253 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1254 | int stream = data.readInt32(); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 1255 | int output = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1256 | reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1257 | return NO_ERROR; |
| 1258 | } break; |
| 1259 | case STREAM_MUTE: { |
| 1260 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1261 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1262 | reply->writeInt32( streamMute((audio_stream_type_t) stream) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1263 | return NO_ERROR; |
| 1264 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1265 | case SET_MODE: { |
| 1266 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 1267 | audio_mode_t mode = (audio_mode_t) data.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1268 | reply->writeInt32( setMode(mode) ); |
| 1269 | return NO_ERROR; |
| 1270 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1271 | case SET_MIC_MUTE: { |
| 1272 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1273 | int state = data.readInt32(); |
| 1274 | reply->writeInt32( setMicMute(state) ); |
| 1275 | return NO_ERROR; |
| 1276 | } break; |
| 1277 | case GET_MIC_MUTE: { |
| 1278 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1279 | reply->writeInt32( getMicMute() ); |
| 1280 | return NO_ERROR; |
| 1281 | } break; |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1282 | case SET_RECORD_SILENCED: { |
| 1283 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 1284 | audio_port_handle_t portId = data.readInt32(); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1285 | bool silenced = data.readInt32() == 1; |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 1286 | setRecordSilenced(portId, silenced); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1287 | return NO_ERROR; |
| 1288 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1289 | case SET_PARAMETERS: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1290 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1291 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1292 | String8 keyValuePairs(data.readString8()); |
| 1293 | reply->writeInt32(setParameters(ioHandle, keyValuePairs)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1294 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1295 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1296 | case GET_PARAMETERS: { |
| 1297 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1298 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1299 | String8 keys(data.readString8()); |
| 1300 | reply->writeString8(getParameters(ioHandle, keys)); |
| 1301 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1302 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1303 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1304 | case REGISTER_CLIENT: { |
| 1305 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Ytai Ben-Tsvi | 10dc0a6 | 2020-09-18 11:31:55 -0700 | [diff] [blame] | 1306 | sp<media::IAudioFlingerClient> client = interface_cast<media::IAudioFlingerClient>( |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 1307 | data.readStrongBinder()); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1308 | registerClient(client); |
| 1309 | return NO_ERROR; |
| 1310 | } break; |
| 1311 | case GET_INPUTBUFFERSIZE: { |
| 1312 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1313 | uint32_t sampleRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 1314 | audio_format_t format = (audio_format_t) data.readInt32(); |
Mikhail Naganov | 5577303 | 2020-10-01 15:08:13 -0700 | [diff] [blame] | 1315 | audio_channel_mask_t channelMask = (audio_channel_mask_t) data.readInt32(); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1316 | reply->writeInt64( getInputBufferSize(sampleRate, format, channelMask) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1317 | return NO_ERROR; |
| 1318 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1319 | case OPEN_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1320 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1321 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1322 | audio_config_t config = {}; |
| 1323 | if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) { |
| 1324 | ALOGE("b/23905951"); |
| 1325 | } |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame] | 1326 | sp<DeviceDescriptorBase> device = new DeviceDescriptorBase(AUDIO_DEVICE_NONE); |
| 1327 | status_t status = NO_ERROR; |
| 1328 | if ((status = data.readParcelable(device.get())) != NO_ERROR) { |
| 1329 | reply->writeInt32((int32_t)status); |
| 1330 | return NO_ERROR; |
| 1331 | } |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 1332 | audio_output_flags_t flags = (audio_output_flags_t) data.readInt32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1333 | uint32_t latencyMs = 0; |
Wei Jia | 4cac44b | 2015-09-16 15:01:16 -0700 | [diff] [blame] | 1334 | audio_io_handle_t output = AUDIO_IO_HANDLE_NONE; |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame] | 1335 | status = openOutput(module, &output, &config, device, &latencyMs, flags); |
Glenn Kasten | 7074296 | 2014-02-18 08:00:47 -0800 | [diff] [blame] | 1336 | ALOGV("OPEN_OUTPUT output, %d", output); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1337 | reply->writeInt32((int32_t)status); |
| 1338 | if (status == NO_ERROR) { |
| 1339 | reply->writeInt32((int32_t)output); |
| 1340 | reply->write(&config, sizeof(audio_config_t)); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1341 | reply->writeInt32(latencyMs); |
| 1342 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1343 | return NO_ERROR; |
| 1344 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1345 | case OPEN_DUPLICATE_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1346 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1347 | audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32(); |
| 1348 | audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32(); |
| 1349 | reply->writeInt32((int32_t) openDuplicateOutput(output1, output2)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1350 | return NO_ERROR; |
| 1351 | } break; |
| 1352 | case CLOSE_OUTPUT: { |
| 1353 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1354 | reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1355 | return NO_ERROR; |
| 1356 | } break; |
| 1357 | case SUSPEND_OUTPUT: { |
| 1358 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1359 | reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1360 | return NO_ERROR; |
| 1361 | } break; |
| 1362 | case RESTORE_OUTPUT: { |
| 1363 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1364 | reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1365 | return NO_ERROR; |
| 1366 | } break; |
| 1367 | case OPEN_INPUT: { |
| 1368 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1369 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1370 | audio_io_handle_t input = (audio_io_handle_t)data.readInt32(); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1371 | audio_config_t config = {}; |
| 1372 | if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) { |
| 1373 | ALOGE("b/23905951"); |
| 1374 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1375 | audio_devices_t device = (audio_devices_t)data.readInt32(); |
| 1376 | String8 address(data.readString8()); |
| 1377 | audio_source_t source = (audio_source_t)data.readInt32(); |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 1378 | audio_input_flags_t flags = (audio_input_flags_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1379 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1380 | status_t status = openInput(module, &input, &config, |
| 1381 | &device, address, source, flags); |
| 1382 | reply->writeInt32((int32_t) status); |
| 1383 | if (status == NO_ERROR) { |
| 1384 | reply->writeInt32((int32_t) input); |
| 1385 | reply->write(&config, sizeof(audio_config_t)); |
| 1386 | reply->writeInt32(device); |
| 1387 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1388 | return NO_ERROR; |
| 1389 | } break; |
| 1390 | case CLOSE_INPUT: { |
| 1391 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1392 | reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1393 | return NO_ERROR; |
| 1394 | } break; |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1395 | case INVALIDATE_STREAM: { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1396 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1397 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 1398 | reply->writeInt32(invalidateStream(stream)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1399 | return NO_ERROR; |
| 1400 | } break; |
Eric Laurent | f0ee6f4 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 1401 | case SET_VOICE_VOLUME: { |
| 1402 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1403 | float volume = data.readFloat(); |
| 1404 | reply->writeInt32( setVoiceVolume(volume) ); |
| 1405 | return NO_ERROR; |
| 1406 | } break; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1407 | case GET_RENDER_POSITION: { |
| 1408 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1409 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1410 | uint32_t halFrames = 0; |
| 1411 | uint32_t dspFrames = 0; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1412 | status_t status = getRenderPosition(&halFrames, &dspFrames, output); |
| 1413 | reply->writeInt32(status); |
| 1414 | if (status == NO_ERROR) { |
| 1415 | reply->writeInt32(halFrames); |
| 1416 | reply->writeInt32(dspFrames); |
| 1417 | } |
| 1418 | return NO_ERROR; |
| 1419 | } |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1420 | case GET_INPUT_FRAMES_LOST: { |
| 1421 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1422 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 1423 | reply->writeInt32((int32_t) getInputFramesLost(ioHandle)); |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1424 | return NO_ERROR; |
| 1425 | } break; |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 1426 | case NEW_AUDIO_UNIQUE_ID: { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1427 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 1428 | reply->writeInt32(newAudioUniqueId((audio_unique_id_use_t) data.readInt32())); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1429 | return NO_ERROR; |
| 1430 | } break; |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1431 | case ACQUIRE_AUDIO_SESSION_ID: { |
| 1432 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1433 | audio_session_t audioSession = (audio_session_t) data.readInt32(); |
Andy Hung | 8b0bfd9 | 2019-12-23 13:11:11 -0800 | [diff] [blame] | 1434 | const pid_t pid = (pid_t)data.readInt32(); |
| 1435 | const uid_t uid = (uid_t)data.readInt32(); |
| 1436 | acquireAudioSessionId(audioSession, pid, uid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1437 | return NO_ERROR; |
| 1438 | } break; |
| 1439 | case RELEASE_AUDIO_SESSION_ID: { |
| 1440 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1441 | audio_session_t audioSession = (audio_session_t) data.readInt32(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 1442 | int pid = data.readInt32(); |
| 1443 | releaseAudioSessionId(audioSession, pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1444 | return NO_ERROR; |
| 1445 | } break; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1446 | case QUERY_NUM_EFFECTS: { |
| 1447 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1448 | uint32_t numEffects = 0; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1449 | status_t status = queryNumberEffects(&numEffects); |
| 1450 | reply->writeInt32(status); |
| 1451 | if (status == NO_ERROR) { |
| 1452 | reply->writeInt32((int32_t)numEffects); |
| 1453 | } |
| 1454 | return NO_ERROR; |
| 1455 | } |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1456 | case QUERY_EFFECT: { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1457 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1458 | effect_descriptor_t desc = {}; |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1459 | status_t status = queryEffect(data.readInt32(), &desc); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1460 | reply->writeInt32(status); |
| 1461 | if (status == NO_ERROR) { |
| 1462 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1463 | } |
| 1464 | return NO_ERROR; |
| 1465 | } |
| 1466 | case GET_EFFECT_DESCRIPTOR: { |
| 1467 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Andy Hung | f85d129 | 2019-08-21 14:45:41 -0700 | [diff] [blame] | 1468 | effect_uuid_t uuid = {}; |
| 1469 | if (data.read(&uuid, sizeof(effect_uuid_t)) != NO_ERROR) { |
| 1470 | android_errorWriteLog(0x534e4554, "139417189"); |
| 1471 | } |
| 1472 | effect_uuid_t type = {}; |
| 1473 | if (data.read(&type, sizeof(effect_uuid_t)) != NO_ERROR) { |
| 1474 | android_errorWriteLog(0x534e4554, "139417189"); |
| 1475 | } |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 1476 | uint32_t preferredTypeFlag = data.readUint32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1477 | effect_descriptor_t desc = {}; |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 1478 | status_t status = getEffectDescriptor(&uuid, &type, preferredTypeFlag, &desc); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1479 | reply->writeInt32(status); |
| 1480 | if (status == NO_ERROR) { |
| 1481 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1482 | } |
| 1483 | return NO_ERROR; |
| 1484 | } |
| 1485 | case CREATE_EFFECT: { |
| 1486 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 1487 | |
Ytai Ben-Tsvi | ce18294 | 2020-11-04 14:48:01 -0800 | [diff] [blame^] | 1488 | media::CreateEffectRequest request; |
| 1489 | media::CreateEffectResponse response; |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1490 | |
Ytai Ben-Tsvi | ce18294 | 2020-11-04 14:48:01 -0800 | [diff] [blame^] | 1491 | return data.readParcelable(&request) |
| 1492 | ?: reply->writeInt32(createEffect(request, &response)) |
| 1493 | ?: reply->writeParcelable(response); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1494 | } break; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1495 | case MOVE_EFFECTS: { |
| 1496 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1497 | audio_session_t session = (audio_session_t) data.readInt32(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1498 | audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32(); |
| 1499 | audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1500 | reply->writeInt32(moveEffects(session, srcOutput, dstOutput)); |
| 1501 | return NO_ERROR; |
| 1502 | } break; |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 1503 | case SET_EFFECT_SUSPENDED: { |
| 1504 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1505 | int effectId = data.readInt32(); |
| 1506 | audio_session_t sessionId = (audio_session_t) data.readInt32(); |
| 1507 | bool suspended = data.readInt32() == 1; |
| 1508 | setEffectSuspended(effectId, sessionId, suspended); |
| 1509 | return NO_ERROR; |
| 1510 | } break; |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1511 | case LOAD_HW_MODULE: { |
| 1512 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1513 | reply->writeInt32(loadHwModule(data.readCString())); |
| 1514 | return NO_ERROR; |
| 1515 | } break; |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1516 | case GET_PRIMARY_OUTPUT_SAMPLING_RATE: { |
| 1517 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1518 | reply->writeInt32(getPrimaryOutputSamplingRate()); |
| 1519 | return NO_ERROR; |
| 1520 | } break; |
| 1521 | case GET_PRIMARY_OUTPUT_FRAME_COUNT: { |
| 1522 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1523 | reply->writeInt64(getPrimaryOutputFrameCount()); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1524 | return NO_ERROR; |
| 1525 | } break; |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 1526 | case SET_LOW_RAM_DEVICE: { |
| 1527 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 1528 | int32_t isLowRamDevice; |
| 1529 | int64_t totalMemory; |
| 1530 | const status_t status = |
| 1531 | data.readInt32(&isLowRamDevice) ?: |
| 1532 | data.readInt64(&totalMemory) ?: |
| 1533 | setLowRamDevice(isLowRamDevice != 0, totalMemory); |
| 1534 | (void)reply->writeInt32(status); |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 1535 | return NO_ERROR; |
| 1536 | } break; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1537 | case LIST_AUDIO_PORTS: { |
| 1538 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1539 | unsigned int numPortsReq = data.readInt32(); |
| 1540 | if (numPortsReq > MAX_ITEMS_PER_LIST) { |
| 1541 | numPortsReq = MAX_ITEMS_PER_LIST; |
| 1542 | } |
| 1543 | unsigned int numPorts = numPortsReq; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1544 | struct audio_port *ports = |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1545 | (struct audio_port *)calloc(numPortsReq, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1546 | sizeof(struct audio_port)); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1547 | if (ports == NULL) { |
| 1548 | reply->writeInt32(NO_MEMORY); |
| 1549 | reply->writeInt32(0); |
| 1550 | return NO_ERROR; |
| 1551 | } |
| 1552 | status_t status = listAudioPorts(&numPorts, ports); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1553 | reply->writeInt32(status); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1554 | reply->writeInt32(numPorts); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1555 | if (status == NO_ERROR) { |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1556 | if (numPortsReq > numPorts) { |
| 1557 | numPortsReq = numPorts; |
| 1558 | } |
| 1559 | reply->write(ports, numPortsReq * sizeof(struct audio_port)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1560 | } |
| 1561 | free(ports); |
| 1562 | return NO_ERROR; |
| 1563 | } break; |
| 1564 | case GET_AUDIO_PORT: { |
| 1565 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
jiabin | b4fed19 | 2020-09-22 14:45:40 -0700 | [diff] [blame] | 1566 | struct audio_port_v7 port = {}; |
Eric Laurent | 4dacbc3 | 2020-10-07 13:48:21 -0700 | [diff] [blame] | 1567 | status_t status = data.read(&port, sizeof(struct audio_port)); |
| 1568 | if (status != NO_ERROR) { |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1569 | ALOGE("b/23905951"); |
Eric Laurent | 4dacbc3 | 2020-10-07 13:48:21 -0700 | [diff] [blame] | 1570 | return status; |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1571 | } |
Eric Laurent | 4dacbc3 | 2020-10-07 13:48:21 -0700 | [diff] [blame] | 1572 | status = AudioSanitizer::sanitizeAudioPort(&port); |
| 1573 | if (status == NO_ERROR) { |
| 1574 | status = getAudioPort(&port); |
| 1575 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1576 | reply->writeInt32(status); |
| 1577 | if (status == NO_ERROR) { |
jiabin | b4fed19 | 2020-09-22 14:45:40 -0700 | [diff] [blame] | 1578 | reply->write(&port, sizeof(struct audio_port_v7)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1579 | } |
| 1580 | return NO_ERROR; |
| 1581 | } break; |
| 1582 | case CREATE_AUDIO_PATCH: { |
| 1583 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1584 | struct audio_patch patch; |
Eric Laurent | 4dacbc3 | 2020-10-07 13:48:21 -0700 | [diff] [blame] | 1585 | status_t status = data.read(&patch, sizeof(struct audio_patch)); |
| 1586 | if (status != NO_ERROR) { |
| 1587 | return status; |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1588 | } |
Eric Laurent | 4dacbc3 | 2020-10-07 13:48:21 -0700 | [diff] [blame] | 1589 | audio_patch_handle_t handle = AUDIO_PATCH_HANDLE_NONE; |
| 1590 | status = data.read(&handle, sizeof(audio_patch_handle_t)); |
| 1591 | if (status != NO_ERROR) { |
| 1592 | ALOGE("b/23905951"); |
| 1593 | return status; |
| 1594 | } |
| 1595 | status = AudioSanitizer::sanitizeAudioPatch(&patch); |
| 1596 | if (status == NO_ERROR) { |
| 1597 | status = createAudioPatch(&patch, &handle); |
| 1598 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1599 | reply->writeInt32(status); |
| 1600 | if (status == NO_ERROR) { |
| 1601 | reply->write(&handle, sizeof(audio_patch_handle_t)); |
| 1602 | } |
| 1603 | return NO_ERROR; |
| 1604 | } break; |
| 1605 | case RELEASE_AUDIO_PATCH: { |
| 1606 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1607 | audio_patch_handle_t handle; |
| 1608 | data.read(&handle, sizeof(audio_patch_handle_t)); |
| 1609 | status_t status = releaseAudioPatch(handle); |
| 1610 | reply->writeInt32(status); |
| 1611 | return NO_ERROR; |
| 1612 | } break; |
| 1613 | case LIST_AUDIO_PATCHES: { |
| 1614 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1615 | unsigned int numPatchesReq = data.readInt32(); |
| 1616 | if (numPatchesReq > MAX_ITEMS_PER_LIST) { |
| 1617 | numPatchesReq = MAX_ITEMS_PER_LIST; |
| 1618 | } |
| 1619 | unsigned int numPatches = numPatchesReq; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1620 | struct audio_patch *patches = |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1621 | (struct audio_patch *)calloc(numPatchesReq, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1622 | sizeof(struct audio_patch)); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1623 | if (patches == NULL) { |
| 1624 | reply->writeInt32(NO_MEMORY); |
| 1625 | reply->writeInt32(0); |
| 1626 | return NO_ERROR; |
| 1627 | } |
| 1628 | status_t status = listAudioPatches(&numPatches, patches); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1629 | reply->writeInt32(status); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1630 | reply->writeInt32(numPatches); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1631 | if (status == NO_ERROR) { |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1632 | if (numPatchesReq > numPatches) { |
| 1633 | numPatchesReq = numPatches; |
| 1634 | } |
| 1635 | reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1636 | } |
| 1637 | free(patches); |
| 1638 | return NO_ERROR; |
| 1639 | } break; |
| 1640 | case SET_AUDIO_PORT_CONFIG: { |
| 1641 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1642 | struct audio_port_config config; |
Eric Laurent | 4dacbc3 | 2020-10-07 13:48:21 -0700 | [diff] [blame] | 1643 | status_t status = data.read(&config, sizeof(struct audio_port_config)); |
| 1644 | if (status != NO_ERROR) { |
| 1645 | return status; |
| 1646 | } |
| 1647 | status = AudioSanitizer::sanitizeAudioPortConfig(&config); |
| 1648 | if (status == NO_ERROR) { |
| 1649 | status = setAudioPortConfig(&config); |
| 1650 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1651 | reply->writeInt32(status); |
| 1652 | return NO_ERROR; |
| 1653 | } break; |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 1654 | case GET_AUDIO_HW_SYNC_FOR_SESSION: { |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 1655 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1656 | reply->writeInt32(getAudioHwSyncForSession((audio_session_t) data.readInt32())); |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 1657 | return NO_ERROR; |
| 1658 | } break; |
Eric Laurent | 72e3f39 | 2015-05-20 14:43:50 -0700 | [diff] [blame] | 1659 | case SYSTEM_READY: { |
| 1660 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1661 | systemReady(); |
| 1662 | return NO_ERROR; |
| 1663 | } break; |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 1664 | case FRAME_COUNT_HAL: { |
| 1665 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1666 | reply->writeInt64( frameCountHAL((audio_io_handle_t) data.readInt32()) ); |
| 1667 | return NO_ERROR; |
| 1668 | } break; |
jiabin | 9ff780e | 2018-03-19 18:19:52 -0700 | [diff] [blame] | 1669 | case GET_MICROPHONES: { |
jiabin | 46a76fa | 2018-01-05 10:18:21 -0800 | [diff] [blame] | 1670 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1671 | std::vector<media::MicrophoneInfo> microphones; |
| 1672 | status_t status = getMicrophones(µphones); |
| 1673 | reply->writeInt32(status); |
| 1674 | if (status == NO_ERROR) { |
| 1675 | reply->writeParcelableVector(microphones); |
| 1676 | } |
| 1677 | return NO_ERROR; |
| 1678 | } |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 1679 | case SET_AUDIO_HAL_PIDS: { |
| 1680 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1681 | std::vector<pid_t> pids; |
| 1682 | int32_t size; |
| 1683 | status_t status = data.readInt32(&size); |
| 1684 | if (status != NO_ERROR) { |
| 1685 | return status; |
| 1686 | } |
| 1687 | if (size < 0) { |
| 1688 | return BAD_VALUE; |
| 1689 | } |
| 1690 | if (size > MAX_ITEMS_PER_LIST) { |
| 1691 | size = MAX_ITEMS_PER_LIST; |
| 1692 | } |
| 1693 | for (int32_t i = 0; i < size; i++) { |
| 1694 | int32_t pid; |
| 1695 | status = data.readInt32(&pid); |
| 1696 | if (status != NO_ERROR) { |
| 1697 | return status; |
| 1698 | } |
| 1699 | pids.push_back(pid); |
| 1700 | } |
| 1701 | reply->writeInt32(setAudioHalPids(pids)); |
| 1702 | return NO_ERROR; |
| 1703 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1704 | default: |
| 1705 | return BBinder::onTransact(code, data, reply, flags); |
| 1706 | } |
| 1707 | } |
| 1708 | |
| 1709 | // ---------------------------------------------------------------------------- |
| 1710 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1711 | } // namespace android |