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