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