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