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