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