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