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