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