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