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