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