Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | ** |
| 3 | ** Copyright 2007, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "IAudioFlinger" |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | #include <utils/Log.h> |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <sys/types.h> |
| 24 | |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 25 | #include <binder/IPCThreadState.h> |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 26 | #include <binder/Parcel.h> |
Andy Hung | 4ef19fa | 2018-05-15 19:35:29 -0700 | [diff] [blame] | 27 | #include <mediautils/ServiceUtilities.h> |
Marco Nelissen | cf90b49 | 2019-09-26 11:20:54 -0700 | [diff] [blame] | 28 | #include <mediautils/TimeCheck.h> |
Steven Moreland | 25a9e55 | 2017-04-17 14:30:39 -0700 | [diff] [blame] | 29 | #include "IAudioFlinger.h" |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | enum { |
| 34 | CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION, |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 35 | CREATE_RECORD, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | SAMPLE_RATE, |
Glenn Kasten | 5876f2f | 2012-11-30 10:52:16 -0800 | [diff] [blame] | 37 | RESERVED, // obsolete, was CHANNEL_COUNT |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | FORMAT, |
| 39 | FRAME_COUNT, |
| 40 | LATENCY, |
| 41 | SET_MASTER_VOLUME, |
| 42 | SET_MASTER_MUTE, |
| 43 | MASTER_VOLUME, |
| 44 | MASTER_MUTE, |
| 45 | SET_STREAM_VOLUME, |
| 46 | SET_STREAM_MUTE, |
| 47 | STREAM_VOLUME, |
| 48 | STREAM_MUTE, |
| 49 | SET_MODE, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | SET_MIC_MUTE, |
| 51 | GET_MIC_MUTE, |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 52 | SET_RECORD_SILENCED, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 53 | SET_PARAMETERS, |
| 54 | GET_PARAMETERS, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | REGISTER_CLIENT, |
| 56 | GET_INPUTBUFFERSIZE, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 57 | OPEN_OUTPUT, |
| 58 | OPEN_DUPLICATE_OUTPUT, |
| 59 | CLOSE_OUTPUT, |
| 60 | SUSPEND_OUTPUT, |
| 61 | RESTORE_OUTPUT, |
| 62 | OPEN_INPUT, |
| 63 | CLOSE_INPUT, |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 64 | INVALIDATE_STREAM, |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 65 | SET_VOICE_VOLUME, |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 66 | GET_RENDER_POSITION, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 67 | GET_INPUT_FRAMES_LOST, |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 68 | NEW_AUDIO_UNIQUE_ID, |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 69 | ACQUIRE_AUDIO_SESSION_ID, |
| 70 | RELEASE_AUDIO_SESSION_ID, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 71 | QUERY_NUM_EFFECTS, |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 72 | QUERY_EFFECT, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 73 | GET_EFFECT_DESCRIPTOR, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 74 | CREATE_EFFECT, |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 75 | MOVE_EFFECTS, |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 76 | LOAD_HW_MODULE, |
| 77 | GET_PRIMARY_OUTPUT_SAMPLING_RATE, |
| 78 | GET_PRIMARY_OUTPUT_FRAME_COUNT, |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 79 | SET_LOW_RAM_DEVICE, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 80 | LIST_AUDIO_PORTS, |
| 81 | GET_AUDIO_PORT, |
| 82 | CREATE_AUDIO_PATCH, |
| 83 | RELEASE_AUDIO_PATCH, |
| 84 | LIST_AUDIO_PATCHES, |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 85 | SET_AUDIO_PORT_CONFIG, |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 86 | GET_AUDIO_HW_SYNC_FOR_SESSION, |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 87 | SYSTEM_READY, |
| 88 | FRAME_COUNT_HAL, |
jiabin | 9ff780e | 2018-03-19 18:19:52 -0700 | [diff] [blame] | 89 | GET_MICROPHONES, |
Richard Folke Tullberg | 3fae037 | 2017-01-13 09:04:25 +0100 | [diff] [blame] | 90 | SET_MASTER_BALANCE, |
| 91 | GET_MASTER_BALANCE, |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 92 | SET_EFFECT_SUSPENDED, |
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 | |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 343 | virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced) |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 344 | { |
| 345 | Parcel data, reply; |
| 346 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 347 | data.writeInt32(portId); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 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, |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame^] | 395 | const sp<DeviceDescriptorBase>& device, |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 396 | uint32_t *latencyMs, |
| 397 | audio_output_flags_t flags) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 398 | { |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame^] | 399 | if (output == nullptr || config == nullptr || device == nullptr || latencyMs == nullptr) { |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 400 | return BAD_VALUE; |
| 401 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | Parcel data, reply; |
| 403 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 404 | data.writeInt32(module); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 405 | data.write(config, sizeof(audio_config_t)); |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame^] | 406 | data.writeParcelable(*device); |
Glenn Kasten | 18868c5 | 2012-03-07 09:15:37 -0800 | [diff] [blame] | 407 | data.writeInt32((int32_t) flags); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 408 | status_t status = remote()->transact(OPEN_OUTPUT, data, &reply); |
| 409 | if (status != NO_ERROR) { |
| 410 | *output = AUDIO_IO_HANDLE_NONE; |
| 411 | return status; |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 412 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 413 | status = (status_t)reply.readInt32(); |
| 414 | if (status != NO_ERROR) { |
| 415 | *output = AUDIO_IO_HANDLE_NONE; |
| 416 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 417 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 418 | *output = (audio_io_handle_t)reply.readInt32(); |
| 419 | ALOGV("openOutput() returned output, %d", *output); |
| 420 | reply.read(config, sizeof(audio_config_t)); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 421 | *latencyMs = reply.readInt32(); |
| 422 | return NO_ERROR; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 423 | } |
| 424 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 425 | virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, |
| 426 | audio_io_handle_t output2) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 427 | { |
| 428 | Parcel data, reply; |
| 429 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 430 | data.writeInt32((int32_t) output1); |
| 431 | data.writeInt32((int32_t) output2); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 432 | remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 433 | return (audio_io_handle_t) reply.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 434 | } |
| 435 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 436 | virtual status_t closeOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 437 | { |
| 438 | Parcel data, reply; |
| 439 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 440 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 441 | remote()->transact(CLOSE_OUTPUT, data, &reply); |
| 442 | return reply.readInt32(); |
| 443 | } |
| 444 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 445 | virtual status_t suspendOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 446 | { |
| 447 | Parcel data, reply; |
| 448 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 449 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 450 | remote()->transact(SUSPEND_OUTPUT, data, &reply); |
| 451 | return reply.readInt32(); |
| 452 | } |
| 453 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 454 | virtual status_t restoreOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 455 | { |
| 456 | Parcel data, reply; |
| 457 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 458 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 459 | remote()->transact(RESTORE_OUTPUT, data, &reply); |
| 460 | return reply.readInt32(); |
| 461 | } |
| 462 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 463 | virtual status_t openInput(audio_module_handle_t module, |
| 464 | audio_io_handle_t *input, |
| 465 | audio_config_t *config, |
| 466 | audio_devices_t *device, |
| 467 | const String8& address, |
| 468 | audio_source_t source, |
| 469 | audio_input_flags_t flags) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 470 | { |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 471 | if (input == NULL || config == NULL || device == NULL) { |
| 472 | return BAD_VALUE; |
| 473 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 474 | Parcel data, reply; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 475 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 476 | data.writeInt32(module); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 477 | data.writeInt32(*input); |
| 478 | data.write(config, sizeof(audio_config_t)); |
| 479 | data.writeInt32(*device); |
| 480 | data.writeString8(address); |
| 481 | data.writeInt32(source); |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 482 | data.writeInt32(flags); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 483 | status_t status = remote()->transact(OPEN_INPUT, data, &reply); |
| 484 | if (status != NO_ERROR) { |
| 485 | *input = AUDIO_IO_HANDLE_NONE; |
| 486 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 487 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 488 | status = (status_t)reply.readInt32(); |
| 489 | if (status != NO_ERROR) { |
| 490 | *input = AUDIO_IO_HANDLE_NONE; |
| 491 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 492 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 493 | *input = (audio_io_handle_t)reply.readInt32(); |
| 494 | reply.read(config, sizeof(audio_config_t)); |
| 495 | *device = (audio_devices_t)reply.readInt32(); |
| 496 | return NO_ERROR; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 497 | } |
| 498 | |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 499 | virtual status_t closeInput(int input) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 500 | { |
| 501 | Parcel data, reply; |
| 502 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 503 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 504 | remote()->transact(CLOSE_INPUT, data, &reply); |
| 505 | return reply.readInt32(); |
| 506 | } |
| 507 | |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 508 | virtual status_t invalidateStream(audio_stream_type_t stream) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 509 | { |
| 510 | Parcel data, reply; |
| 511 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 512 | data.writeInt32((int32_t) stream); |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 513 | remote()->transact(INVALIDATE_STREAM, data, &reply); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 514 | return reply.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | } |
Eric Laurent | f0ee6f4 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 516 | |
| 517 | virtual status_t setVoiceVolume(float volume) |
| 518 | { |
| 519 | Parcel data, reply; |
| 520 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 521 | data.writeFloat(volume); |
| 522 | remote()->transact(SET_VOICE_VOLUME, data, &reply); |
| 523 | return reply.readInt32(); |
| 524 | } |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 525 | |
Kévin PETIT | 377b2ec | 2014-02-03 12:35:36 +0000 | [diff] [blame] | 526 | virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 527 | audio_io_handle_t output) const |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 528 | { |
| 529 | Parcel data, reply; |
| 530 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 531 | data.writeInt32((int32_t) output); |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 532 | remote()->transact(GET_RENDER_POSITION, data, &reply); |
| 533 | status_t status = reply.readInt32(); |
| 534 | if (status == NO_ERROR) { |
| 535 | uint32_t tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 536 | if (halFrames != NULL) { |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 537 | *halFrames = tmp; |
| 538 | } |
| 539 | tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 540 | if (dspFrames != NULL) { |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 541 | *dspFrames = tmp; |
| 542 | } |
| 543 | } |
| 544 | return status; |
| 545 | } |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 546 | |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 547 | virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 548 | { |
| 549 | Parcel data, reply; |
| 550 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 551 | data.writeInt32((int32_t) ioHandle); |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 552 | status_t status = remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply); |
| 553 | if (status != NO_ERROR) { |
| 554 | return 0; |
| 555 | } |
| 556 | return (uint32_t) reply.readInt32(); |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 557 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 558 | |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 559 | virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use) |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 560 | { |
| 561 | Parcel data, reply; |
| 562 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 563 | data.writeInt32((int32_t) use); |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 564 | status_t status = remote()->transact(NEW_AUDIO_UNIQUE_ID, data, &reply); |
| 565 | audio_unique_id_t id = AUDIO_UNIQUE_ID_ALLOCATE; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 566 | if (status == NO_ERROR) { |
| 567 | id = reply.readInt32(); |
| 568 | } |
| 569 | return id; |
| 570 | } |
| 571 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 572 | virtual void acquireAudioSessionId(audio_session_t audioSession, int pid) |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 573 | { |
| 574 | Parcel data, reply; |
| 575 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 576 | data.writeInt32(audioSession); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 577 | data.writeInt32(pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 578 | remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply); |
| 579 | } |
| 580 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 581 | virtual void releaseAudioSessionId(audio_session_t audioSession, int pid) |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 582 | { |
| 583 | Parcel data, reply; |
| 584 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 585 | data.writeInt32(audioSession); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 586 | data.writeInt32(pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 587 | remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply); |
| 588 | } |
| 589 | |
Glenn Kasten | f587ba5 | 2012-01-26 16:25:10 -0800 | [diff] [blame] | 590 | virtual status_t queryNumberEffects(uint32_t *numEffects) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 591 | { |
| 592 | Parcel data, reply; |
| 593 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 594 | status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply); |
| 595 | if (status != NO_ERROR) { |
| 596 | return status; |
| 597 | } |
| 598 | status = reply.readInt32(); |
| 599 | if (status != NO_ERROR) { |
| 600 | return status; |
| 601 | } |
Glenn Kasten | 9d1f02d | 2012-02-08 17:47:58 -0800 | [diff] [blame] | 602 | if (numEffects != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 603 | *numEffects = (uint32_t)reply.readInt32(); |
| 604 | } |
| 605 | return NO_ERROR; |
| 606 | } |
| 607 | |
Glenn Kasten | f587ba5 | 2012-01-26 16:25:10 -0800 | [diff] [blame] | 608 | virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 609 | { |
| 610 | if (pDescriptor == NULL) { |
| 611 | return BAD_VALUE; |
| 612 | } |
| 613 | Parcel data, reply; |
| 614 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 615 | data.writeInt32(index); |
| 616 | status_t status = remote()->transact(QUERY_EFFECT, data, &reply); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 617 | if (status != NO_ERROR) { |
| 618 | return status; |
| 619 | } |
| 620 | status = reply.readInt32(); |
| 621 | if (status != NO_ERROR) { |
| 622 | return status; |
| 623 | } |
| 624 | reply.read(pDescriptor, sizeof(effect_descriptor_t)); |
| 625 | return NO_ERROR; |
| 626 | } |
| 627 | |
Glenn Kasten | 5e92a78 | 2012-01-30 07:40:52 -0800 | [diff] [blame] | 628 | virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid, |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 629 | const effect_uuid_t *pType, |
| 630 | uint32_t preferredTypeFlag, |
| 631 | effect_descriptor_t *pDescriptor) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 632 | { |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 633 | if (pUuid == NULL || pType == NULL || pDescriptor == NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 634 | return BAD_VALUE; |
| 635 | } |
| 636 | Parcel data, reply; |
| 637 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 638 | data.write(pUuid, sizeof(effect_uuid_t)); |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 639 | data.write(pType, sizeof(effect_uuid_t)); |
| 640 | data.writeUint32(preferredTypeFlag); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 641 | status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply); |
| 642 | if (status != NO_ERROR) { |
| 643 | return status; |
| 644 | } |
| 645 | status = reply.readInt32(); |
| 646 | if (status != NO_ERROR) { |
| 647 | return status; |
| 648 | } |
| 649 | reply.read(pDescriptor, sizeof(effect_descriptor_t)); |
| 650 | return NO_ERROR; |
| 651 | } |
| 652 | |
Glenn Kasten | 8d6cc84 | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 653 | virtual sp<IEffect> createEffect( |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 654 | effect_descriptor_t *pDesc, |
| 655 | const sp<IEffectClient>& client, |
| 656 | int32_t priority, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 657 | audio_io_handle_t output, |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 658 | audio_session_t sessionId, |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 659 | const String16& opPackageName, |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 660 | pid_t pid, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 661 | status_t *status, |
| 662 | int *id, |
| 663 | int *enabled) |
| 664 | { |
| 665 | Parcel data, reply; |
| 666 | sp<IEffect> effect; |
| 667 | |
| 668 | if (pDesc == NULL) { |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 669 | if (status != NULL) { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 670 | *status = BAD_VALUE; |
| 671 | } |
Eric Laurent | b2fe78f | 2018-08-02 17:56:11 -0700 | [diff] [blame] | 672 | return effect; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 673 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 674 | |
| 675 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 676 | data.write(pDesc, sizeof(effect_descriptor_t)); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 677 | data.writeStrongBinder(IInterface::asBinder(client)); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 678 | data.writeInt32(priority); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 679 | data.writeInt32((int32_t) output); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 680 | data.writeInt32(sessionId); |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 681 | data.writeString16(opPackageName); |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 682 | data.writeInt32((int32_t) pid); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 683 | |
| 684 | status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply); |
| 685 | if (lStatus != NO_ERROR) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 686 | ALOGE("createEffect error: %s", strerror(-lStatus)); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 687 | } else { |
| 688 | lStatus = reply.readInt32(); |
| 689 | int tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 690 | if (id != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 691 | *id = tmp; |
| 692 | } |
| 693 | tmp = reply.readInt32(); |
Glenn Kasten | a0d6833 | 2012-01-27 16:47:15 -0800 | [diff] [blame] | 694 | if (enabled != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 695 | *enabled = tmp; |
| 696 | } |
| 697 | effect = interface_cast<IEffect>(reply.readStrongBinder()); |
| 698 | reply.read(pDesc, sizeof(effect_descriptor_t)); |
| 699 | } |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 700 | if (status != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 701 | *status = lStatus; |
| 702 | } |
| 703 | |
| 704 | return effect; |
| 705 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 706 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 707 | 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] | 708 | audio_io_handle_t dstOutput) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 709 | { |
| 710 | Parcel data, reply; |
| 711 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 712 | data.writeInt32(session); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 713 | data.writeInt32((int32_t) srcOutput); |
| 714 | data.writeInt32((int32_t) dstOutput); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 715 | remote()->transact(MOVE_EFFECTS, data, &reply); |
| 716 | return reply.readInt32(); |
| 717 | } |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 718 | |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 719 | virtual void setEffectSuspended(int effectId, |
| 720 | audio_session_t sessionId, |
| 721 | bool suspended) |
| 722 | { |
| 723 | Parcel data, reply; |
| 724 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 725 | data.writeInt32(effectId); |
| 726 | data.writeInt32(sessionId); |
| 727 | data.writeInt32(suspended ? 1 : 0); |
| 728 | remote()->transact(SET_EFFECT_SUSPENDED, data, &reply); |
| 729 | } |
| 730 | |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 731 | virtual audio_module_handle_t loadHwModule(const char *name) |
| 732 | { |
| 733 | Parcel data, reply; |
| 734 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 735 | data.writeCString(name); |
| 736 | remote()->transact(LOAD_HW_MODULE, data, &reply); |
| 737 | return (audio_module_handle_t) reply.readInt32(); |
| 738 | } |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 739 | |
Glenn Kasten | 3b16c76 | 2012-11-14 08:44:39 -0800 | [diff] [blame] | 740 | virtual uint32_t getPrimaryOutputSamplingRate() |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 741 | { |
| 742 | Parcel data, reply; |
| 743 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 744 | remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply); |
| 745 | return reply.readInt32(); |
| 746 | } |
| 747 | |
Glenn Kasten | e33054e | 2012-11-14 12:54:39 -0800 | [diff] [blame] | 748 | virtual size_t getPrimaryOutputFrameCount() |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 749 | { |
| 750 | Parcel data, reply; |
| 751 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 752 | remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 753 | return reply.readInt64(); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 756 | virtual status_t setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) override |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 757 | { |
| 758 | Parcel data, reply; |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 759 | |
| 760 | static_assert(NO_ERROR == 0, "NO_ERROR must be 0"); |
| 761 | return data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()) |
| 762 | ?: data.writeInt32((int) isLowRamDevice) |
| 763 | ?: data.writeInt64(totalMemory) |
| 764 | ?: remote()->transact(SET_LOW_RAM_DEVICE, data, &reply) |
| 765 | ?: reply.readInt32(); |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 766 | } |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 767 | |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 768 | virtual status_t listAudioPorts(unsigned int *num_ports, |
| 769 | struct audio_port *ports) |
| 770 | { |
| 771 | if (num_ports == NULL || *num_ports == 0 || ports == NULL) { |
| 772 | return BAD_VALUE; |
| 773 | } |
| 774 | Parcel data, reply; |
| 775 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 776 | data.writeInt32(*num_ports); |
| 777 | status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); |
| 778 | if (status != NO_ERROR || |
| 779 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 780 | return status; |
| 781 | } |
| 782 | *num_ports = (unsigned int)reply.readInt32(); |
| 783 | reply.read(ports, *num_ports * sizeof(struct audio_port)); |
| 784 | return status; |
| 785 | } |
| 786 | virtual status_t getAudioPort(struct audio_port *port) |
| 787 | { |
| 788 | if (port == NULL) { |
| 789 | return BAD_VALUE; |
| 790 | } |
| 791 | Parcel data, reply; |
| 792 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 793 | data.write(port, sizeof(struct audio_port)); |
| 794 | status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); |
| 795 | if (status != NO_ERROR || |
| 796 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 797 | return status; |
| 798 | } |
| 799 | reply.read(port, sizeof(struct audio_port)); |
| 800 | return status; |
| 801 | } |
| 802 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 803 | audio_patch_handle_t *handle) |
| 804 | { |
| 805 | if (patch == NULL || handle == NULL) { |
| 806 | return BAD_VALUE; |
| 807 | } |
| 808 | Parcel data, reply; |
| 809 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 810 | data.write(patch, sizeof(struct audio_patch)); |
| 811 | data.write(handle, sizeof(audio_patch_handle_t)); |
| 812 | status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); |
| 813 | if (status != NO_ERROR || |
| 814 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 815 | return status; |
| 816 | } |
| 817 | reply.read(handle, sizeof(audio_patch_handle_t)); |
| 818 | return status; |
| 819 | } |
| 820 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle) |
| 821 | { |
| 822 | Parcel data, reply; |
| 823 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 824 | data.write(&handle, sizeof(audio_patch_handle_t)); |
| 825 | status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); |
| 826 | if (status != NO_ERROR) { |
| 827 | status = (status_t)reply.readInt32(); |
| 828 | } |
| 829 | return status; |
| 830 | } |
| 831 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 832 | struct audio_patch *patches) |
| 833 | { |
| 834 | if (num_patches == NULL || *num_patches == 0 || patches == NULL) { |
| 835 | return BAD_VALUE; |
| 836 | } |
| 837 | Parcel data, reply; |
| 838 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 839 | data.writeInt32(*num_patches); |
| 840 | status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); |
| 841 | if (status != NO_ERROR || |
| 842 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 843 | return status; |
| 844 | } |
| 845 | *num_patches = (unsigned int)reply.readInt32(); |
| 846 | reply.read(patches, *num_patches * sizeof(struct audio_patch)); |
| 847 | return status; |
| 848 | } |
| 849 | virtual status_t setAudioPortConfig(const struct audio_port_config *config) |
| 850 | { |
| 851 | if (config == NULL) { |
| 852 | return BAD_VALUE; |
| 853 | } |
| 854 | Parcel data, reply; |
| 855 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 856 | data.write(config, sizeof(struct audio_port_config)); |
| 857 | status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); |
| 858 | if (status != NO_ERROR) { |
| 859 | status = (status_t)reply.readInt32(); |
| 860 | } |
| 861 | return status; |
| 862 | } |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 863 | virtual audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId) |
| 864 | { |
| 865 | Parcel data, reply; |
| 866 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 867 | data.writeInt32(sessionId); |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 868 | 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] | 869 | if (status != NO_ERROR) { |
| 870 | return AUDIO_HW_SYNC_INVALID; |
| 871 | } |
| 872 | return (audio_hw_sync_t)reply.readInt32(); |
| 873 | } |
Eric Laurent | 72e3f39 | 2015-05-20 14:43:50 -0700 | [diff] [blame] | 874 | virtual status_t systemReady() |
| 875 | { |
| 876 | Parcel data, reply; |
| 877 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 878 | return remote()->transact(SYSTEM_READY, data, &reply, IBinder::FLAG_ONEWAY); |
| 879 | } |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 880 | virtual size_t frameCountHAL(audio_io_handle_t ioHandle) const |
| 881 | { |
| 882 | Parcel data, reply; |
| 883 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 884 | data.writeInt32((int32_t) ioHandle); |
| 885 | status_t status = remote()->transact(FRAME_COUNT_HAL, data, &reply); |
| 886 | if (status != NO_ERROR) { |
| 887 | return 0; |
| 888 | } |
| 889 | return reply.readInt64(); |
| 890 | } |
jiabin | 46a76fa | 2018-01-05 10:18:21 -0800 | [diff] [blame] | 891 | virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones) |
| 892 | { |
| 893 | Parcel data, reply; |
| 894 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
jiabin | 9ff780e | 2018-03-19 18:19:52 -0700 | [diff] [blame] | 895 | status_t status = remote()->transact(GET_MICROPHONES, data, &reply); |
jiabin | 46a76fa | 2018-01-05 10:18:21 -0800 | [diff] [blame] | 896 | if (status != NO_ERROR || |
| 897 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 898 | return status; |
| 899 | } |
| 900 | status = reply.readParcelableVector(microphones); |
| 901 | return status; |
| 902 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 903 | }; |
| 904 | |
| 905 | IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger"); |
| 906 | |
| 907 | // ---------------------------------------------------------------------- |
| 908 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 909 | status_t BnAudioFlinger::onTransact( |
| 910 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 911 | { |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 912 | // make sure transactions reserved to AudioPolicyManager do not come from other processes |
| 913 | switch (code) { |
| 914 | case SET_STREAM_VOLUME: |
| 915 | case SET_STREAM_MUTE: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 916 | case OPEN_OUTPUT: |
| 917 | case OPEN_DUPLICATE_OUTPUT: |
| 918 | case CLOSE_OUTPUT: |
| 919 | case SUSPEND_OUTPUT: |
| 920 | case RESTORE_OUTPUT: |
| 921 | case OPEN_INPUT: |
| 922 | case CLOSE_INPUT: |
| 923 | case INVALIDATE_STREAM: |
| 924 | case SET_VOICE_VOLUME: |
| 925 | case MOVE_EFFECTS: |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 926 | case SET_EFFECT_SUSPENDED: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 927 | case LOAD_HW_MODULE: |
| 928 | case LIST_AUDIO_PORTS: |
| 929 | case GET_AUDIO_PORT: |
| 930 | case CREATE_AUDIO_PATCH: |
| 931 | case RELEASE_AUDIO_PATCH: |
| 932 | case LIST_AUDIO_PATCHES: |
| 933 | case SET_AUDIO_PORT_CONFIG: |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 934 | case SET_RECORD_SILENCED: |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 935 | ALOGW("%s: transaction %d received from PID %d", |
| 936 | __func__, code, IPCThreadState::self()->getCallingPid()); |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 937 | // return status only for non void methods |
| 938 | switch (code) { |
| 939 | case SET_RECORD_SILENCED: |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 940 | case SET_EFFECT_SUSPENDED: |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 941 | break; |
| 942 | default: |
| 943 | reply->writeInt32(static_cast<int32_t> (INVALID_OPERATION)); |
| 944 | break; |
| 945 | } |
| 946 | return OK; |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 947 | default: |
| 948 | break; |
| 949 | } |
| 950 | |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 951 | // make sure the following transactions come from system components |
| 952 | switch (code) { |
| 953 | case SET_MASTER_VOLUME: |
| 954 | case SET_MASTER_MUTE: |
| 955 | case SET_MODE: |
| 956 | case SET_MIC_MUTE: |
| 957 | case SET_LOW_RAM_DEVICE: |
Eric Laurent | 96c7eed | 2018-03-26 17:57:01 -0700 | [diff] [blame] | 958 | case SYSTEM_READY: { |
Andy Hung | 4ef19fa | 2018-05-15 19:35:29 -0700 | [diff] [blame] | 959 | if (!isServiceUid(IPCThreadState::self()->getCallingUid())) { |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 960 | ALOGW("%s: transaction %d received from PID %d unauthorized UID %d", |
| 961 | __func__, code, IPCThreadState::self()->getCallingPid(), |
| 962 | IPCThreadState::self()->getCallingUid()); |
Eric Laurent | ef92bff | 2018-04-26 10:44:50 -0700 | [diff] [blame] | 963 | // return status only for non void methods |
| 964 | switch (code) { |
| 965 | case SYSTEM_READY: |
| 966 | break; |
| 967 | default: |
| 968 | reply->writeInt32(static_cast<int32_t> (INVALID_OPERATION)); |
| 969 | break; |
| 970 | } |
| 971 | return OK; |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 972 | } |
Eric Laurent | 96c7eed | 2018-03-26 17:57:01 -0700 | [diff] [blame] | 973 | } break; |
Eric Laurent | 4980df2 | 2018-01-26 18:04:09 -0800 | [diff] [blame] | 974 | default: |
| 975 | break; |
| 976 | } |
| 977 | |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 978 | // Whitelist of relevant events to trigger log merging. |
| 979 | // Log merging should activate during audio activity of any kind. This are considered the |
| 980 | // most relevant events. |
| 981 | // TODO should select more wisely the items from the list |
| 982 | switch (code) { |
| 983 | case CREATE_TRACK: |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 984 | case CREATE_RECORD: |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 985 | case SET_MASTER_VOLUME: |
| 986 | case SET_MASTER_MUTE: |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 987 | case SET_MIC_MUTE: |
| 988 | case SET_PARAMETERS: |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 989 | case CREATE_EFFECT: |
| 990 | case SYSTEM_READY: { |
| 991 | requestLogMerge(); |
| 992 | break; |
| 993 | } |
| 994 | default: |
| 995 | break; |
| 996 | } |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 997 | |
Eric Laurent | 39b09b5 | 2018-06-29 12:24:40 -0700 | [diff] [blame] | 998 | std::string tag("IAudioFlinger command " + std::to_string(code)); |
| 999 | TimeCheck check(tag.c_str()); |
Eric Laurent | 3528c93 | 2018-02-23 17:17:22 -0800 | [diff] [blame] | 1000 | |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1001 | switch (code) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1002 | case CREATE_TRACK: { |
| 1003 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1004 | |
| 1005 | CreateTrackInput input; |
| 1006 | if (input.readFromParcel((Parcel*)&data) != NO_ERROR) { |
| 1007 | reply->writeInt32(DEAD_OBJECT); |
| 1008 | return NO_ERROR; |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 1009 | } |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1010 | |
| 1011 | status_t status; |
| 1012 | CreateTrackOutput output; |
| 1013 | |
| 1014 | sp<IAudioTrack> track= createTrack(input, |
| 1015 | output, |
| 1016 | &status); |
| 1017 | |
| 1018 | LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1019 | reply->writeInt32(status); |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1020 | if (status != NO_ERROR) { |
| 1021 | return NO_ERROR; |
| 1022 | } |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 1023 | reply->writeStrongBinder(IInterface::asBinder(track)); |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 1024 | output.writeToParcel(reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1025 | return NO_ERROR; |
| 1026 | } break; |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1027 | case CREATE_RECORD: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1028 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1029 | |
| 1030 | CreateRecordInput input; |
| 1031 | if (input.readFromParcel((Parcel*)&data) != NO_ERROR) { |
| 1032 | reply->writeInt32(DEAD_OBJECT); |
| 1033 | return NO_ERROR; |
| 1034 | } |
| 1035 | |
| 1036 | status_t status; |
| 1037 | CreateRecordOutput output; |
| 1038 | |
| 1039 | sp<media::IAudioRecord> record = createRecord(input, |
| 1040 | output, |
| 1041 | &status); |
| 1042 | |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 1043 | LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1044 | reply->writeInt32(status); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1045 | if (status != NO_ERROR) { |
| 1046 | return NO_ERROR; |
| 1047 | } |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 1048 | reply->writeStrongBinder(IInterface::asBinder(record)); |
Eric Laurent | f14db3c | 2017-12-08 14:20:36 -0800 | [diff] [blame] | 1049 | output.writeToParcel(reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1050 | return NO_ERROR; |
| 1051 | } break; |
| 1052 | case SAMPLE_RATE: { |
| 1053 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1054 | reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1055 | return NO_ERROR; |
| 1056 | } break; |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 1057 | |
| 1058 | // RESERVED for channelCount() |
| 1059 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1060 | case FORMAT: { |
| 1061 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1062 | reply->writeInt32( format((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1063 | return NO_ERROR; |
| 1064 | } break; |
| 1065 | case FRAME_COUNT: { |
| 1066 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1067 | reply->writeInt64( frameCount((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1068 | return NO_ERROR; |
| 1069 | } break; |
| 1070 | case LATENCY: { |
| 1071 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1072 | reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1073 | return NO_ERROR; |
| 1074 | } break; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1075 | case SET_MASTER_VOLUME: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1076 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1077 | reply->writeInt32( setMasterVolume(data.readFloat()) ); |
| 1078 | return NO_ERROR; |
| 1079 | } break; |
| 1080 | case SET_MASTER_MUTE: { |
| 1081 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1082 | reply->writeInt32( setMasterMute(data.readInt32()) ); |
| 1083 | return NO_ERROR; |
| 1084 | } break; |
| 1085 | case MASTER_VOLUME: { |
| 1086 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1087 | reply->writeFloat( masterVolume() ); |
| 1088 | return NO_ERROR; |
| 1089 | } break; |
| 1090 | case MASTER_MUTE: { |
| 1091 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1092 | reply->writeInt32( masterMute() ); |
| 1093 | return NO_ERROR; |
| 1094 | } break; |
Richard Folke Tullberg | 3fae037 | 2017-01-13 09:04:25 +0100 | [diff] [blame] | 1095 | case SET_MASTER_BALANCE: { |
| 1096 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1097 | reply->writeInt32( setMasterBalance(data.readFloat()) ); |
| 1098 | return NO_ERROR; |
| 1099 | } break; |
| 1100 | case GET_MASTER_BALANCE: { |
| 1101 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1102 | float f; |
| 1103 | const status_t status = getMasterBalance(&f); |
| 1104 | reply->writeInt32((int32_t)status); |
| 1105 | if (status == NO_ERROR) { |
| 1106 | (void)reply->writeFloat(f); |
| 1107 | } |
| 1108 | return NO_ERROR; |
| 1109 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1110 | case SET_STREAM_VOLUME: { |
| 1111 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1112 | int stream = data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1113 | float volume = data.readFloat(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1114 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1115 | 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] | 1116 | return NO_ERROR; |
| 1117 | } break; |
| 1118 | case SET_STREAM_MUTE: { |
| 1119 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1120 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1121 | 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] | 1122 | return NO_ERROR; |
| 1123 | } break; |
| 1124 | case STREAM_VOLUME: { |
| 1125 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1126 | int stream = data.readInt32(); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 1127 | int output = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1128 | reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1129 | return NO_ERROR; |
| 1130 | } break; |
| 1131 | case STREAM_MUTE: { |
| 1132 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1133 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1134 | reply->writeInt32( streamMute((audio_stream_type_t) stream) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1135 | return NO_ERROR; |
| 1136 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1137 | case SET_MODE: { |
| 1138 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 1139 | audio_mode_t mode = (audio_mode_t) data.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1140 | reply->writeInt32( setMode(mode) ); |
| 1141 | return NO_ERROR; |
| 1142 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1143 | case SET_MIC_MUTE: { |
| 1144 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1145 | int state = data.readInt32(); |
| 1146 | reply->writeInt32( setMicMute(state) ); |
| 1147 | return NO_ERROR; |
| 1148 | } break; |
| 1149 | case GET_MIC_MUTE: { |
| 1150 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1151 | reply->writeInt32( getMicMute() ); |
| 1152 | return NO_ERROR; |
| 1153 | } break; |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1154 | case SET_RECORD_SILENCED: { |
| 1155 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 1156 | audio_port_handle_t portId = data.readInt32(); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1157 | bool silenced = data.readInt32() == 1; |
Eric Laurent | 5ada82e | 2019-08-29 17:53:54 -0700 | [diff] [blame] | 1158 | setRecordSilenced(portId, silenced); |
Svet Ganov | f4ddfef | 2018-01-16 07:37:58 -0800 | [diff] [blame] | 1159 | return NO_ERROR; |
| 1160 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1161 | case SET_PARAMETERS: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1162 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1163 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1164 | String8 keyValuePairs(data.readString8()); |
| 1165 | reply->writeInt32(setParameters(ioHandle, keyValuePairs)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1166 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1167 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1168 | case GET_PARAMETERS: { |
| 1169 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1170 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1171 | String8 keys(data.readString8()); |
| 1172 | reply->writeString8(getParameters(ioHandle, keys)); |
| 1173 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1174 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1175 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1176 | case REGISTER_CLIENT: { |
| 1177 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 1178 | sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>( |
| 1179 | data.readStrongBinder()); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1180 | registerClient(client); |
| 1181 | return NO_ERROR; |
| 1182 | } break; |
| 1183 | case GET_INPUTBUFFERSIZE: { |
| 1184 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1185 | uint32_t sampleRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 1186 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 1187 | audio_channel_mask_t channelMask = data.readInt32(); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1188 | reply->writeInt64( getInputBufferSize(sampleRate, format, channelMask) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1189 | return NO_ERROR; |
| 1190 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1191 | case OPEN_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1192 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1193 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1194 | audio_config_t config = {}; |
| 1195 | if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) { |
| 1196 | ALOGE("b/23905951"); |
| 1197 | } |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame^] | 1198 | sp<DeviceDescriptorBase> device = new DeviceDescriptorBase(AUDIO_DEVICE_NONE); |
| 1199 | status_t status = NO_ERROR; |
| 1200 | if ((status = data.readParcelable(device.get())) != NO_ERROR) { |
| 1201 | reply->writeInt32((int32_t)status); |
| 1202 | return NO_ERROR; |
| 1203 | } |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 1204 | audio_output_flags_t flags = (audio_output_flags_t) data.readInt32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1205 | uint32_t latencyMs = 0; |
Wei Jia | 4cac44b | 2015-09-16 15:01:16 -0700 | [diff] [blame] | 1206 | audio_io_handle_t output = AUDIO_IO_HANDLE_NONE; |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame^] | 1207 | status = openOutput(module, &output, &config, device, &latencyMs, flags); |
Glenn Kasten | 7074296 | 2014-02-18 08:00:47 -0800 | [diff] [blame] | 1208 | ALOGV("OPEN_OUTPUT output, %d", output); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1209 | reply->writeInt32((int32_t)status); |
| 1210 | if (status == NO_ERROR) { |
| 1211 | reply->writeInt32((int32_t)output); |
| 1212 | reply->write(&config, sizeof(audio_config_t)); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1213 | reply->writeInt32(latencyMs); |
| 1214 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1215 | return NO_ERROR; |
| 1216 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1217 | case OPEN_DUPLICATE_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1218 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1219 | audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32(); |
| 1220 | audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32(); |
| 1221 | reply->writeInt32((int32_t) openDuplicateOutput(output1, output2)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1222 | return NO_ERROR; |
| 1223 | } break; |
| 1224 | case CLOSE_OUTPUT: { |
| 1225 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1226 | reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1227 | return NO_ERROR; |
| 1228 | } break; |
| 1229 | case SUSPEND_OUTPUT: { |
| 1230 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1231 | reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1232 | return NO_ERROR; |
| 1233 | } break; |
| 1234 | case RESTORE_OUTPUT: { |
| 1235 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1236 | reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1237 | return NO_ERROR; |
| 1238 | } break; |
| 1239 | case OPEN_INPUT: { |
| 1240 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1241 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1242 | audio_io_handle_t input = (audio_io_handle_t)data.readInt32(); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1243 | audio_config_t config = {}; |
| 1244 | if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) { |
| 1245 | ALOGE("b/23905951"); |
| 1246 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1247 | audio_devices_t device = (audio_devices_t)data.readInt32(); |
| 1248 | String8 address(data.readString8()); |
| 1249 | audio_source_t source = (audio_source_t)data.readInt32(); |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 1250 | audio_input_flags_t flags = (audio_input_flags_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1251 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1252 | status_t status = openInput(module, &input, &config, |
| 1253 | &device, address, source, flags); |
| 1254 | reply->writeInt32((int32_t) status); |
| 1255 | if (status == NO_ERROR) { |
| 1256 | reply->writeInt32((int32_t) input); |
| 1257 | reply->write(&config, sizeof(audio_config_t)); |
| 1258 | reply->writeInt32(device); |
| 1259 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1260 | return NO_ERROR; |
| 1261 | } break; |
| 1262 | case CLOSE_INPUT: { |
| 1263 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1264 | reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1265 | return NO_ERROR; |
| 1266 | } break; |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1267 | case INVALIDATE_STREAM: { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1268 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1269 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 1270 | reply->writeInt32(invalidateStream(stream)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1271 | return NO_ERROR; |
| 1272 | } break; |
Eric Laurent | f0ee6f4 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 1273 | case SET_VOICE_VOLUME: { |
| 1274 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1275 | float volume = data.readFloat(); |
| 1276 | reply->writeInt32( setVoiceVolume(volume) ); |
| 1277 | return NO_ERROR; |
| 1278 | } break; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1279 | case GET_RENDER_POSITION: { |
| 1280 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1281 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1282 | uint32_t halFrames = 0; |
| 1283 | uint32_t dspFrames = 0; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1284 | status_t status = getRenderPosition(&halFrames, &dspFrames, output); |
| 1285 | reply->writeInt32(status); |
| 1286 | if (status == NO_ERROR) { |
| 1287 | reply->writeInt32(halFrames); |
| 1288 | reply->writeInt32(dspFrames); |
| 1289 | } |
| 1290 | return NO_ERROR; |
| 1291 | } |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1292 | case GET_INPUT_FRAMES_LOST: { |
| 1293 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1294 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 1295 | reply->writeInt32((int32_t) getInputFramesLost(ioHandle)); |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1296 | return NO_ERROR; |
| 1297 | } break; |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 1298 | case NEW_AUDIO_UNIQUE_ID: { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1299 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 1300 | reply->writeInt32(newAudioUniqueId((audio_unique_id_use_t) data.readInt32())); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1301 | return NO_ERROR; |
| 1302 | } break; |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1303 | case ACQUIRE_AUDIO_SESSION_ID: { |
| 1304 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1305 | audio_session_t audioSession = (audio_session_t) data.readInt32(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 1306 | int pid = data.readInt32(); |
| 1307 | acquireAudioSessionId(audioSession, pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1308 | return NO_ERROR; |
| 1309 | } break; |
| 1310 | case RELEASE_AUDIO_SESSION_ID: { |
| 1311 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1312 | audio_session_t audioSession = (audio_session_t) data.readInt32(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 1313 | int pid = data.readInt32(); |
| 1314 | releaseAudioSessionId(audioSession, pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1315 | return NO_ERROR; |
| 1316 | } break; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1317 | case QUERY_NUM_EFFECTS: { |
| 1318 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1319 | uint32_t numEffects = 0; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1320 | status_t status = queryNumberEffects(&numEffects); |
| 1321 | reply->writeInt32(status); |
| 1322 | if (status == NO_ERROR) { |
| 1323 | reply->writeInt32((int32_t)numEffects); |
| 1324 | } |
| 1325 | return NO_ERROR; |
| 1326 | } |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1327 | case QUERY_EFFECT: { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1328 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1329 | effect_descriptor_t desc = {}; |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1330 | status_t status = queryEffect(data.readInt32(), &desc); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1331 | reply->writeInt32(status); |
| 1332 | if (status == NO_ERROR) { |
| 1333 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1334 | } |
| 1335 | return NO_ERROR; |
| 1336 | } |
| 1337 | case GET_EFFECT_DESCRIPTOR: { |
| 1338 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Andy Hung | f85d129 | 2019-08-21 14:45:41 -0700 | [diff] [blame] | 1339 | effect_uuid_t uuid = {}; |
| 1340 | if (data.read(&uuid, sizeof(effect_uuid_t)) != NO_ERROR) { |
| 1341 | android_errorWriteLog(0x534e4554, "139417189"); |
| 1342 | } |
| 1343 | effect_uuid_t type = {}; |
| 1344 | if (data.read(&type, sizeof(effect_uuid_t)) != NO_ERROR) { |
| 1345 | android_errorWriteLog(0x534e4554, "139417189"); |
| 1346 | } |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 1347 | uint32_t preferredTypeFlag = data.readUint32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1348 | effect_descriptor_t desc = {}; |
Ari Hausman-Cohen | 2046ec7 | 2018-04-24 14:00:55 -0700 | [diff] [blame] | 1349 | status_t status = getEffectDescriptor(&uuid, &type, preferredTypeFlag, &desc); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1350 | reply->writeInt32(status); |
| 1351 | if (status == NO_ERROR) { |
| 1352 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1353 | } |
| 1354 | return NO_ERROR; |
| 1355 | } |
| 1356 | case CREATE_EFFECT: { |
| 1357 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1358 | effect_descriptor_t desc = {}; |
| 1359 | if (data.read(&desc, sizeof(effect_descriptor_t)) != NO_ERROR) { |
| 1360 | ALOGE("b/23905951"); |
| 1361 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1362 | sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder()); |
| 1363 | int32_t priority = data.readInt32(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1364 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1365 | audio_session_t sessionId = (audio_session_t) data.readInt32(); |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 1366 | const String16 opPackageName = data.readString16(); |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 1367 | pid_t pid = (pid_t)data.readInt32(); |
| 1368 | |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1369 | status_t status = NO_ERROR; |
| 1370 | int id = 0; |
| 1371 | int enabled = 0; |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1372 | |
Glenn Kasten | 8d6cc84 | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 1373 | sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId, |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 1374 | opPackageName, pid, &status, &id, &enabled); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1375 | reply->writeInt32(status); |
| 1376 | reply->writeInt32(id); |
| 1377 | reply->writeInt32(enabled); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 1378 | reply->writeStrongBinder(IInterface::asBinder(effect)); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1379 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1380 | return NO_ERROR; |
| 1381 | } break; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1382 | case MOVE_EFFECTS: { |
| 1383 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1384 | audio_session_t session = (audio_session_t) data.readInt32(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1385 | audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32(); |
| 1386 | audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1387 | reply->writeInt32(moveEffects(session, srcOutput, dstOutput)); |
| 1388 | return NO_ERROR; |
| 1389 | } break; |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 1390 | case SET_EFFECT_SUSPENDED: { |
| 1391 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1392 | int effectId = data.readInt32(); |
| 1393 | audio_session_t sessionId = (audio_session_t) data.readInt32(); |
| 1394 | bool suspended = data.readInt32() == 1; |
| 1395 | setEffectSuspended(effectId, sessionId, suspended); |
| 1396 | return NO_ERROR; |
| 1397 | } break; |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1398 | case LOAD_HW_MODULE: { |
| 1399 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1400 | reply->writeInt32(loadHwModule(data.readCString())); |
| 1401 | return NO_ERROR; |
| 1402 | } break; |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1403 | case GET_PRIMARY_OUTPUT_SAMPLING_RATE: { |
| 1404 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1405 | reply->writeInt32(getPrimaryOutputSamplingRate()); |
| 1406 | return NO_ERROR; |
| 1407 | } break; |
| 1408 | case GET_PRIMARY_OUTPUT_FRAME_COUNT: { |
| 1409 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1410 | reply->writeInt64(getPrimaryOutputFrameCount()); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1411 | return NO_ERROR; |
| 1412 | } break; |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 1413 | case SET_LOW_RAM_DEVICE: { |
| 1414 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Andy Hung | 6f248bb | 2018-01-23 14:04:37 -0800 | [diff] [blame] | 1415 | int32_t isLowRamDevice; |
| 1416 | int64_t totalMemory; |
| 1417 | const status_t status = |
| 1418 | data.readInt32(&isLowRamDevice) ?: |
| 1419 | data.readInt64(&totalMemory) ?: |
| 1420 | setLowRamDevice(isLowRamDevice != 0, totalMemory); |
| 1421 | (void)reply->writeInt32(status); |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 1422 | return NO_ERROR; |
| 1423 | } break; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1424 | case LIST_AUDIO_PORTS: { |
| 1425 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1426 | unsigned int numPortsReq = data.readInt32(); |
| 1427 | if (numPortsReq > MAX_ITEMS_PER_LIST) { |
| 1428 | numPortsReq = MAX_ITEMS_PER_LIST; |
| 1429 | } |
| 1430 | unsigned int numPorts = numPortsReq; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1431 | struct audio_port *ports = |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1432 | (struct audio_port *)calloc(numPortsReq, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1433 | sizeof(struct audio_port)); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1434 | if (ports == NULL) { |
| 1435 | reply->writeInt32(NO_MEMORY); |
| 1436 | reply->writeInt32(0); |
| 1437 | return NO_ERROR; |
| 1438 | } |
| 1439 | status_t status = listAudioPorts(&numPorts, ports); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1440 | reply->writeInt32(status); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1441 | reply->writeInt32(numPorts); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1442 | if (status == NO_ERROR) { |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1443 | if (numPortsReq > numPorts) { |
| 1444 | numPortsReq = numPorts; |
| 1445 | } |
| 1446 | reply->write(ports, numPortsReq * sizeof(struct audio_port)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1447 | } |
| 1448 | free(ports); |
| 1449 | return NO_ERROR; |
| 1450 | } break; |
| 1451 | case GET_AUDIO_PORT: { |
| 1452 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1453 | struct audio_port port = {}; |
| 1454 | if (data.read(&port, sizeof(struct audio_port)) != NO_ERROR) { |
| 1455 | ALOGE("b/23905951"); |
| 1456 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1457 | status_t status = getAudioPort(&port); |
| 1458 | reply->writeInt32(status); |
| 1459 | if (status == NO_ERROR) { |
| 1460 | reply->write(&port, sizeof(struct audio_port)); |
| 1461 | } |
| 1462 | return NO_ERROR; |
| 1463 | } break; |
| 1464 | case CREATE_AUDIO_PATCH: { |
| 1465 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1466 | struct audio_patch patch; |
| 1467 | data.read(&patch, sizeof(struct audio_patch)); |
Glenn Kasten | a13cde9 | 2016-03-28 15:26:02 -0700 | [diff] [blame] | 1468 | audio_patch_handle_t handle = AUDIO_PATCH_HANDLE_NONE; |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1469 | if (data.read(&handle, sizeof(audio_patch_handle_t)) != NO_ERROR) { |
| 1470 | ALOGE("b/23905951"); |
| 1471 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1472 | status_t status = createAudioPatch(&patch, &handle); |
| 1473 | reply->writeInt32(status); |
| 1474 | if (status == NO_ERROR) { |
| 1475 | reply->write(&handle, sizeof(audio_patch_handle_t)); |
| 1476 | } |
| 1477 | return NO_ERROR; |
| 1478 | } break; |
| 1479 | case RELEASE_AUDIO_PATCH: { |
| 1480 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1481 | audio_patch_handle_t handle; |
| 1482 | data.read(&handle, sizeof(audio_patch_handle_t)); |
| 1483 | status_t status = releaseAudioPatch(handle); |
| 1484 | reply->writeInt32(status); |
| 1485 | return NO_ERROR; |
| 1486 | } break; |
| 1487 | case LIST_AUDIO_PATCHES: { |
| 1488 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1489 | unsigned int numPatchesReq = data.readInt32(); |
| 1490 | if (numPatchesReq > MAX_ITEMS_PER_LIST) { |
| 1491 | numPatchesReq = MAX_ITEMS_PER_LIST; |
| 1492 | } |
| 1493 | unsigned int numPatches = numPatchesReq; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1494 | struct audio_patch *patches = |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1495 | (struct audio_patch *)calloc(numPatchesReq, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1496 | sizeof(struct audio_patch)); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1497 | if (patches == NULL) { |
| 1498 | reply->writeInt32(NO_MEMORY); |
| 1499 | reply->writeInt32(0); |
| 1500 | return NO_ERROR; |
| 1501 | } |
| 1502 | status_t status = listAudioPatches(&numPatches, patches); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1503 | reply->writeInt32(status); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1504 | reply->writeInt32(numPatches); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1505 | if (status == NO_ERROR) { |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1506 | if (numPatchesReq > numPatches) { |
| 1507 | numPatchesReq = numPatches; |
| 1508 | } |
| 1509 | reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1510 | } |
| 1511 | free(patches); |
| 1512 | return NO_ERROR; |
| 1513 | } break; |
| 1514 | case SET_AUDIO_PORT_CONFIG: { |
| 1515 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1516 | struct audio_port_config config; |
| 1517 | data.read(&config, sizeof(struct audio_port_config)); |
| 1518 | status_t status = setAudioPortConfig(&config); |
| 1519 | reply->writeInt32(status); |
| 1520 | return NO_ERROR; |
| 1521 | } break; |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame] | 1522 | case GET_AUDIO_HW_SYNC_FOR_SESSION: { |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 1523 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1524 | reply->writeInt32(getAudioHwSyncForSession((audio_session_t) data.readInt32())); |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 1525 | return NO_ERROR; |
| 1526 | } break; |
Eric Laurent | 72e3f39 | 2015-05-20 14:43:50 -0700 | [diff] [blame] | 1527 | case SYSTEM_READY: { |
| 1528 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1529 | systemReady(); |
| 1530 | return NO_ERROR; |
| 1531 | } break; |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 1532 | case FRAME_COUNT_HAL: { |
| 1533 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1534 | reply->writeInt64( frameCountHAL((audio_io_handle_t) data.readInt32()) ); |
| 1535 | return NO_ERROR; |
| 1536 | } break; |
jiabin | 9ff780e | 2018-03-19 18:19:52 -0700 | [diff] [blame] | 1537 | case GET_MICROPHONES: { |
jiabin | 46a76fa | 2018-01-05 10:18:21 -0800 | [diff] [blame] | 1538 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1539 | std::vector<media::MicrophoneInfo> microphones; |
| 1540 | status_t status = getMicrophones(µphones); |
| 1541 | reply->writeInt32(status); |
| 1542 | if (status == NO_ERROR) { |
| 1543 | reply->writeParcelableVector(microphones); |
| 1544 | } |
| 1545 | return NO_ERROR; |
| 1546 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1547 | default: |
| 1548 | return BBinder::onTransact(code, data, reply, flags); |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | // ---------------------------------------------------------------------------- |
| 1553 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1554 | } // namespace android |