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