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