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