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