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