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