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