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