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