Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | ** |
| 3 | ** Copyright 2007, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "IAudioFlinger" |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | #include <utils/Log.h> |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <sys/types.h> |
| 24 | |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 25 | #include <binder/Parcel.h> |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
| 27 | #include <media/IAudioFlinger.h> |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | enum { |
| 32 | CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION, |
| 33 | OPEN_RECORD, |
| 34 | SAMPLE_RATE, |
Glenn Kasten | 5876f2f | 2012-11-30 10:52:16 -0800 | [diff] [blame] | 35 | RESERVED, // obsolete, was CHANNEL_COUNT |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | FORMAT, |
| 37 | FRAME_COUNT, |
| 38 | LATENCY, |
| 39 | SET_MASTER_VOLUME, |
| 40 | SET_MASTER_MUTE, |
| 41 | MASTER_VOLUME, |
| 42 | MASTER_MUTE, |
| 43 | SET_STREAM_VOLUME, |
| 44 | SET_STREAM_MUTE, |
| 45 | STREAM_VOLUME, |
| 46 | STREAM_MUTE, |
| 47 | SET_MODE, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | SET_MIC_MUTE, |
| 49 | GET_MIC_MUTE, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 50 | SET_PARAMETERS, |
| 51 | GET_PARAMETERS, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | REGISTER_CLIENT, |
| 53 | GET_INPUTBUFFERSIZE, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 54 | OPEN_OUTPUT, |
| 55 | OPEN_DUPLICATE_OUTPUT, |
| 56 | CLOSE_OUTPUT, |
| 57 | SUSPEND_OUTPUT, |
| 58 | RESTORE_OUTPUT, |
| 59 | OPEN_INPUT, |
| 60 | CLOSE_INPUT, |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 61 | INVALIDATE_STREAM, |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 62 | SET_VOICE_VOLUME, |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 63 | GET_RENDER_POSITION, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 64 | GET_INPUT_FRAMES_LOST, |
| 65 | NEW_AUDIO_SESSION_ID, |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 66 | ACQUIRE_AUDIO_SESSION_ID, |
| 67 | RELEASE_AUDIO_SESSION_ID, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 68 | QUERY_NUM_EFFECTS, |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 69 | QUERY_EFFECT, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 70 | GET_EFFECT_DESCRIPTOR, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 71 | CREATE_EFFECT, |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 72 | MOVE_EFFECTS, |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 73 | LOAD_HW_MODULE, |
| 74 | GET_PRIMARY_OUTPUT_SAMPLING_RATE, |
| 75 | GET_PRIMARY_OUTPUT_FRAME_COUNT, |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 76 | SET_LOW_RAM_DEVICE, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | class BpAudioFlinger : public BpInterface<IAudioFlinger> |
| 80 | { |
| 81 | public: |
| 82 | BpAudioFlinger(const sp<IBinder>& impl) |
| 83 | : BpInterface<IAudioFlinger>(impl) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | virtual sp<IAudioTrack> createTrack( |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 88 | audio_stream_type_t streamType, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | uint32_t sampleRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 90 | audio_format_t format, |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 91 | audio_channel_mask_t channelMask, |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 92 | size_t *pFrameCount, |
Glenn Kasten | e0b0717 | 2012-11-06 15:03:34 -0800 | [diff] [blame] | 93 | track_flags_t *flags, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | const sp<IMemory>& sharedBuffer, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 95 | audio_io_handle_t output, |
Glenn Kasten | 3acbd05 | 2012-02-28 10:39:56 -0800 | [diff] [blame] | 96 | pid_t tid, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 97 | int *sessionId, |
Marco Nelissen | 462fd2f | 2013-01-14 14:12:05 -0800 | [diff] [blame] | 98 | int clientUid, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | status_t *status) |
| 100 | { |
| 101 | Parcel data, reply; |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 102 | sp<IAudioTrack> track; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 104 | data.writeInt32((int32_t) streamType); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | data.writeInt32(sampleRate); |
| 106 | data.writeInt32(format); |
Jean-Michel Trivi | 0d255b2 | 2011-05-24 15:53:33 -0700 | [diff] [blame] | 107 | data.writeInt32(channelMask); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 108 | size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0; |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 109 | data.writeInt64(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); |
Glenn Kasten | 2301acc | 2014-01-17 10:21:00 -0800 | [diff] [blame] | 112 | // haveSharedBuffer |
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 | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame^] | 131 | frameCount = reply.readInt64(); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 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 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 143 | lStatus = reply.readInt32(); |
| 144 | track = interface_cast<IAudioTrack>(reply.readStrongBinder()); |
Glenn Kasten | 0cde076 | 2014-01-16 15:06:36 -0800 | [diff] [blame] | 145 | if (lStatus == NO_ERROR) { |
| 146 | if (track == 0) { |
| 147 | ALOGE("createTrack should have returned an IAudioTrack"); |
| 148 | lStatus = UNKNOWN_ERROR; |
| 149 | } |
| 150 | } else { |
| 151 | if (track != 0) { |
| 152 | ALOGE("createTrack returned an IAudioTrack but with status %d", lStatus); |
| 153 | track.clear(); |
| 154 | } |
| 155 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | } |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 157 | if (status != NULL) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | *status = lStatus; |
| 159 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 160 | return track; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | virtual sp<IAudioRecord> openRecord( |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 164 | audio_io_handle_t input, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 165 | uint32_t sampleRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 166 | audio_format_t format, |
Glenn Kasten | 28b76b3 | 2012-07-03 17:24:41 -0700 | [diff] [blame] | 167 | audio_channel_mask_t channelMask, |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 168 | size_t *pFrameCount, |
Glenn Kasten | eeca326 | 2013-07-31 16:12:48 -0700 | [diff] [blame] | 169 | track_flags_t *flags, |
Glenn Kasten | 1879fff | 2012-07-11 15:36:59 -0700 | [diff] [blame] | 170 | pid_t tid, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 171 | int *sessionId, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | status_t *status) |
| 173 | { |
| 174 | Parcel data, reply; |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 175 | sp<IAudioRecord> record; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 177 | data.writeInt32((int32_t) input); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 178 | data.writeInt32(sampleRate); |
| 179 | data.writeInt32(format); |
Jean-Michel Trivi | 0d255b2 | 2011-05-24 15:53:33 -0700 | [diff] [blame] | 180 | data.writeInt32(channelMask); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 181 | size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0; |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 182 | data.writeInt64(frameCount); |
Glenn Kasten | eeca326 | 2013-07-31 16:12:48 -0700 | [diff] [blame] | 183 | track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT; |
| 184 | data.writeInt32(lFlags); |
Glenn Kasten | 1879fff | 2012-07-11 15:36:59 -0700 | [diff] [blame] | 185 | data.writeInt32((int32_t) tid); |
Glenn Kasten | aea7ea0 | 2013-06-26 09:25:47 -0700 | [diff] [blame] | 186 | int lSessionId = AUDIO_SESSION_ALLOCATE; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 187 | if (sessionId != NULL) { |
| 188 | lSessionId = *sessionId; |
| 189 | } |
| 190 | data.writeInt32(lSessionId); |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 191 | status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply); |
| 192 | if (lStatus != NO_ERROR) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 193 | ALOGE("openRecord error: %s", strerror(-lStatus)); |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 194 | } else { |
Glenn Kasten | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame^] | 195 | frameCount = reply.readInt64(); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 196 | if (pFrameCount != NULL) { |
| 197 | *pFrameCount = frameCount; |
| 198 | } |
Glenn Kasten | eeca326 | 2013-07-31 16:12:48 -0700 | [diff] [blame] | 199 | lFlags = reply.readInt32(); |
| 200 | if (flags != NULL) { |
| 201 | *flags = lFlags; |
| 202 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 203 | lSessionId = reply.readInt32(); |
| 204 | if (sessionId != NULL) { |
| 205 | *sessionId = lSessionId; |
| 206 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 207 | lStatus = reply.readInt32(); |
| 208 | record = interface_cast<IAudioRecord>(reply.readStrongBinder()); |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 209 | if (lStatus == NO_ERROR) { |
| 210 | if (record == 0) { |
| 211 | ALOGE("openRecord should have returned an IAudioRecord"); |
| 212 | lStatus = UNKNOWN_ERROR; |
| 213 | } |
| 214 | } else { |
| 215 | if (record != 0) { |
| 216 | ALOGE("openRecord returned an IAudioRecord but with status %d", lStatus); |
| 217 | record.clear(); |
| 218 | } |
| 219 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 220 | } |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 221 | if (status != NULL) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 222 | *status = lStatus; |
| 223 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 224 | return record; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | } |
| 226 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 227 | 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] | 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(SAMPLE_RATE, data, &reply); |
| 233 | return reply.readInt32(); |
| 234 | } |
| 235 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 236 | 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] | 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(FORMAT, data, &reply); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 242 | return (audio_format_t) reply.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 243 | } |
| 244 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 245 | 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] | 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(FRAME_COUNT, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 251 | return reply.readInt64(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 254 | 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] | 255 | { |
| 256 | Parcel data, reply; |
| 257 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 258 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | remote()->transact(LATENCY, data, &reply); |
| 260 | return reply.readInt32(); |
| 261 | } |
| 262 | |
| 263 | virtual status_t setMasterVolume(float value) |
| 264 | { |
| 265 | Parcel data, reply; |
| 266 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 267 | data.writeFloat(value); |
| 268 | remote()->transact(SET_MASTER_VOLUME, data, &reply); |
| 269 | return reply.readInt32(); |
| 270 | } |
| 271 | |
| 272 | virtual status_t setMasterMute(bool muted) |
| 273 | { |
| 274 | Parcel data, reply; |
| 275 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 276 | data.writeInt32(muted); |
| 277 | remote()->transact(SET_MASTER_MUTE, data, &reply); |
| 278 | return reply.readInt32(); |
| 279 | } |
| 280 | |
| 281 | virtual float masterVolume() const |
| 282 | { |
| 283 | Parcel data, reply; |
| 284 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 285 | remote()->transact(MASTER_VOLUME, data, &reply); |
| 286 | return reply.readFloat(); |
| 287 | } |
| 288 | |
| 289 | virtual bool masterMute() const |
| 290 | { |
| 291 | Parcel data, reply; |
| 292 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 293 | remote()->transact(MASTER_MUTE, data, &reply); |
| 294 | return reply.readInt32(); |
| 295 | } |
| 296 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 297 | virtual status_t setStreamVolume(audio_stream_type_t stream, float value, |
| 298 | audio_io_handle_t output) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 299 | { |
| 300 | Parcel data, reply; |
| 301 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 302 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 303 | data.writeFloat(value); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 304 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 305 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 306 | return reply.readInt32(); |
| 307 | } |
| 308 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 309 | 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] | 310 | { |
| 311 | Parcel data, reply; |
| 312 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 313 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 314 | data.writeInt32(muted); |
| 315 | remote()->transact(SET_STREAM_MUTE, data, &reply); |
| 316 | return reply.readInt32(); |
| 317 | } |
| 318 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 319 | 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] | 320 | { |
| 321 | Parcel data, reply; |
| 322 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 323 | data.writeInt32((int32_t) stream); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 324 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | remote()->transact(STREAM_VOLUME, data, &reply); |
| 326 | return reply.readFloat(); |
| 327 | } |
| 328 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 329 | virtual bool streamMute(audio_stream_type_t stream) const |
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()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 333 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 334 | remote()->transact(STREAM_MUTE, data, &reply); |
| 335 | return reply.readInt32(); |
| 336 | } |
| 337 | |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 338 | virtual status_t setMode(audio_mode_t mode) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 339 | { |
| 340 | Parcel data, reply; |
| 341 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 342 | data.writeInt32(mode); |
| 343 | remote()->transact(SET_MODE, data, &reply); |
| 344 | return reply.readInt32(); |
| 345 | } |
| 346 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 347 | virtual status_t setMicMute(bool state) |
| 348 | { |
| 349 | Parcel data, reply; |
| 350 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 351 | data.writeInt32(state); |
| 352 | remote()->transact(SET_MIC_MUTE, data, &reply); |
| 353 | return reply.readInt32(); |
| 354 | } |
| 355 | |
| 356 | virtual bool getMicMute() const |
| 357 | { |
| 358 | Parcel data, reply; |
| 359 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 360 | remote()->transact(GET_MIC_MUTE, data, &reply); |
| 361 | return reply.readInt32(); |
| 362 | } |
| 363 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 364 | 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] | 365 | { |
| 366 | Parcel data, reply; |
| 367 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 368 | data.writeInt32((int32_t) ioHandle); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 369 | data.writeString8(keyValuePairs); |
| 370 | remote()->transact(SET_PARAMETERS, data, &reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 371 | return reply.readInt32(); |
| 372 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 373 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 374 | virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 375 | { |
| 376 | Parcel data, reply; |
| 377 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 378 | data.writeInt32((int32_t) ioHandle); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 379 | data.writeString8(keys); |
| 380 | remote()->transact(GET_PARAMETERS, data, &reply); |
| 381 | return reply.readString8(); |
| 382 | } |
| 383 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 384 | virtual void registerClient(const sp<IAudioFlingerClient>& client) |
| 385 | { |
| 386 | Parcel data, reply; |
| 387 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 388 | data.writeStrongBinder(client->asBinder()); |
| 389 | remote()->transact(REGISTER_CLIENT, data, &reply); |
| 390 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 391 | |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 392 | virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, |
| 393 | audio_channel_mask_t channelMask) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 394 | { |
| 395 | Parcel data, reply; |
| 396 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 397 | data.writeInt32(sampleRate); |
| 398 | data.writeInt32(format); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 399 | data.writeInt32(channelMask); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 400 | remote()->transact(GET_INPUTBUFFERSIZE, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 401 | return reply.readInt64(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 403 | |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 404 | virtual audio_io_handle_t openOutput(audio_module_handle_t module, |
| 405 | audio_devices_t *pDevices, |
| 406 | uint32_t *pSamplingRate, |
| 407 | audio_format_t *pFormat, |
| 408 | audio_channel_mask_t *pChannelMask, |
| 409 | uint32_t *pLatencyMs, |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 410 | audio_output_flags_t flags, |
| 411 | const audio_offload_info_t *offloadInfo) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 412 | { |
| 413 | Parcel data, reply; |
Glenn Kasten | 45faf7e | 2014-01-17 10:23:01 -0800 | [diff] [blame] | 414 | audio_devices_t devices = pDevices != NULL ? *pDevices : AUDIO_DEVICE_NONE; |
Glenn Kasten | 7c5977f | 2013-07-02 14:17:22 -0700 | [diff] [blame] | 415 | uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0; |
| 416 | audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT; |
| 417 | audio_channel_mask_t channelMask = pChannelMask != NULL ? |
| 418 | *pChannelMask : (audio_channel_mask_t)0; |
| 419 | uint32_t latency = pLatencyMs != NULL ? *pLatencyMs : 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 420 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 421 | data.writeInt32(module); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 422 | data.writeInt32(devices); |
| 423 | data.writeInt32(samplingRate); |
| 424 | data.writeInt32(format); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 425 | data.writeInt32(channelMask); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 426 | data.writeInt32(latency); |
Glenn Kasten | 18868c5 | 2012-03-07 09:15:37 -0800 | [diff] [blame] | 427 | data.writeInt32((int32_t) flags); |
Glenn Kasten | 2301acc | 2014-01-17 10:21:00 -0800 | [diff] [blame] | 428 | // hasOffloadInfo |
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 | 45faf7e | 2014-01-17 10:23:01 -0800 | [diff] [blame] | 506 | audio_devices_t devices = pDevices != NULL ? *pDevices : AUDIO_DEVICE_NONE; |
Glenn Kasten | 7c5977f | 2013-07-02 14:17:22 -0700 | [diff] [blame] | 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); |
Glenn Kasten | 85d109a | 2014-01-17 10:25:08 -0800 | [diff] [blame] | 604 | int id = AUDIO_SESSION_ALLOCATE; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 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); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 772 | return reply.readInt64(); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 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 | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 800 | size_t frameCount = data.readInt64(); |
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(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 811 | status_t status; |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 812 | sp<IAudioTrack> track; |
| 813 | if ((haveSharedBuffer && (buffer == 0)) || |
| 814 | ((buffer != 0) && (buffer->pointer() == NULL))) { |
| 815 | ALOGW("CREATE_TRACK: cannot retrieve shared memory"); |
| 816 | status = DEAD_OBJECT; |
| 817 | } else { |
| 818 | track = createTrack( |
| 819 | (audio_stream_type_t) streamType, sampleRate, format, |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 820 | channelMask, &frameCount, &flags, buffer, output, tid, |
Glenn Kasten | c5a1742 | 2014-03-13 14:59:59 -0700 | [diff] [blame] | 821 | &sessionId, clientUid, &status); |
Glenn Kasten | 0cde076 | 2014-01-16 15:06:36 -0800 | [diff] [blame] | 822 | LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR)); |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 823 | } |
Glenn Kasten | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame^] | 824 | reply->writeInt64(frameCount); |
Glenn Kasten | e0b0717 | 2012-11-06 15:03:34 -0800 | [diff] [blame] | 825 | reply->writeInt32(flags); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 826 | reply->writeInt32(sessionId); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 827 | reply->writeInt32(status); |
| 828 | reply->writeStrongBinder(track->asBinder()); |
| 829 | return NO_ERROR; |
| 830 | } break; |
| 831 | case OPEN_RECORD: { |
| 832 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 833 | 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] | 834 | uint32_t sampleRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 835 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 836 | audio_channel_mask_t channelMask = data.readInt32(); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 837 | size_t frameCount = data.readInt64(); |
Glenn Kasten | a075db4 | 2012-03-06 11:22:44 -0800 | [diff] [blame] | 838 | track_flags_t flags = (track_flags_t) data.readInt32(); |
Glenn Kasten | 1879fff | 2012-07-11 15:36:59 -0700 | [diff] [blame] | 839 | pid_t tid = (pid_t) data.readInt32(); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 840 | int sessionId = data.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 841 | status_t status; |
Glenn Kasten | 8d6cc84 | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 842 | sp<IAudioRecord> record = openRecord(input, |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 843 | sampleRate, format, channelMask, &frameCount, &flags, tid, &sessionId, &status); |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 844 | LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR)); |
Glenn Kasten | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame^] | 845 | reply->writeInt64(frameCount); |
Glenn Kasten | eeca326 | 2013-07-31 16:12:48 -0700 | [diff] [blame] | 846 | reply->writeInt32(flags); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 847 | reply->writeInt32(sessionId); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 848 | reply->writeInt32(status); |
| 849 | reply->writeStrongBinder(record->asBinder()); |
| 850 | return NO_ERROR; |
| 851 | } break; |
| 852 | case SAMPLE_RATE: { |
| 853 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 854 | reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 855 | return NO_ERROR; |
| 856 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 857 | case FORMAT: { |
| 858 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 859 | reply->writeInt32( format((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 860 | return NO_ERROR; |
| 861 | } break; |
| 862 | case FRAME_COUNT: { |
| 863 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 864 | reply->writeInt64( frameCount((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | return NO_ERROR; |
| 866 | } break; |
| 867 | case LATENCY: { |
| 868 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 869 | reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 870 | return NO_ERROR; |
| 871 | } break; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 872 | case SET_MASTER_VOLUME: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 873 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 874 | reply->writeInt32( setMasterVolume(data.readFloat()) ); |
| 875 | return NO_ERROR; |
| 876 | } break; |
| 877 | case SET_MASTER_MUTE: { |
| 878 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 879 | reply->writeInt32( setMasterMute(data.readInt32()) ); |
| 880 | return NO_ERROR; |
| 881 | } break; |
| 882 | case MASTER_VOLUME: { |
| 883 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 884 | reply->writeFloat( masterVolume() ); |
| 885 | return NO_ERROR; |
| 886 | } break; |
| 887 | case MASTER_MUTE: { |
| 888 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 889 | reply->writeInt32( masterMute() ); |
| 890 | return NO_ERROR; |
| 891 | } break; |
| 892 | case SET_STREAM_VOLUME: { |
| 893 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 894 | int stream = data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 895 | float volume = data.readFloat(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 896 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 897 | 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] | 898 | return NO_ERROR; |
| 899 | } break; |
| 900 | case SET_STREAM_MUTE: { |
| 901 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 902 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 903 | 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] | 904 | return NO_ERROR; |
| 905 | } break; |
| 906 | case STREAM_VOLUME: { |
| 907 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 908 | int stream = data.readInt32(); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 909 | int output = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 910 | reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 911 | return NO_ERROR; |
| 912 | } break; |
| 913 | case STREAM_MUTE: { |
| 914 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 915 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 916 | reply->writeInt32( streamMute((audio_stream_type_t) stream) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 917 | return NO_ERROR; |
| 918 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 919 | case SET_MODE: { |
| 920 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 921 | audio_mode_t mode = (audio_mode_t) data.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 922 | reply->writeInt32( setMode(mode) ); |
| 923 | return NO_ERROR; |
| 924 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 925 | case SET_MIC_MUTE: { |
| 926 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 927 | int state = data.readInt32(); |
| 928 | reply->writeInt32( setMicMute(state) ); |
| 929 | return NO_ERROR; |
| 930 | } break; |
| 931 | case GET_MIC_MUTE: { |
| 932 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 933 | reply->writeInt32( getMicMute() ); |
| 934 | return NO_ERROR; |
| 935 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 936 | case SET_PARAMETERS: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 937 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 938 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 939 | String8 keyValuePairs(data.readString8()); |
| 940 | reply->writeInt32(setParameters(ioHandle, keyValuePairs)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 941 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 942 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 943 | case GET_PARAMETERS: { |
| 944 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 945 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 946 | String8 keys(data.readString8()); |
| 947 | reply->writeString8(getParameters(ioHandle, keys)); |
| 948 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 949 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 950 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 951 | case REGISTER_CLIENT: { |
| 952 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 953 | sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>( |
| 954 | data.readStrongBinder()); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 955 | registerClient(client); |
| 956 | return NO_ERROR; |
| 957 | } break; |
| 958 | case GET_INPUTBUFFERSIZE: { |
| 959 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 960 | uint32_t sampleRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 961 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 962 | audio_channel_mask_t channelMask = data.readInt32(); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 963 | reply->writeInt64( getInputBufferSize(sampleRate, format, channelMask) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 964 | return NO_ERROR; |
| 965 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 966 | case OPEN_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 967 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 968 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
| 969 | audio_devices_t devices = (audio_devices_t)data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 970 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 971 | audio_format_t format = (audio_format_t) data.readInt32(); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 972 | audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 973 | uint32_t latency = data.readInt32(); |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 974 | audio_output_flags_t flags = (audio_output_flags_t) data.readInt32(); |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 975 | bool hasOffloadInfo = data.readInt32() != 0; |
| 976 | audio_offload_info_t offloadInfo; |
| 977 | if (hasOffloadInfo) { |
| 978 | data.read(&offloadInfo, sizeof(audio_offload_info_t)); |
| 979 | } |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 980 | audio_io_handle_t output = openOutput(module, |
| 981 | &devices, |
| 982 | &samplingRate, |
| 983 | &format, |
| 984 | &channelMask, |
| 985 | &latency, |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 986 | flags, |
| 987 | hasOffloadInfo ? &offloadInfo : NULL); |
Glenn Kasten | 7074296 | 2014-02-18 08:00:47 -0800 | [diff] [blame] | 988 | ALOGV("OPEN_OUTPUT output, %d", output); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 989 | reply->writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 990 | reply->writeInt32(devices); |
| 991 | reply->writeInt32(samplingRate); |
| 992 | reply->writeInt32(format); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 993 | reply->writeInt32(channelMask); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 994 | reply->writeInt32(latency); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 995 | return NO_ERROR; |
| 996 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 997 | case OPEN_DUPLICATE_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 998 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 999 | audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32(); |
| 1000 | audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32(); |
| 1001 | reply->writeInt32((int32_t) openDuplicateOutput(output1, output2)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1002 | return NO_ERROR; |
| 1003 | } break; |
| 1004 | case CLOSE_OUTPUT: { |
| 1005 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1006 | reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1007 | return NO_ERROR; |
| 1008 | } break; |
| 1009 | case SUSPEND_OUTPUT: { |
| 1010 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1011 | reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1012 | return NO_ERROR; |
| 1013 | } break; |
| 1014 | case RESTORE_OUTPUT: { |
| 1015 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1016 | reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1017 | return NO_ERROR; |
| 1018 | } break; |
| 1019 | case OPEN_INPUT: { |
| 1020 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1021 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
| 1022 | audio_devices_t devices = (audio_devices_t)data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1023 | uint32_t samplingRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 1024 | audio_format_t format = (audio_format_t) data.readInt32(); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1025 | audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1026 | |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1027 | audio_io_handle_t input = openInput(module, |
| 1028 | &devices, |
| 1029 | &samplingRate, |
| 1030 | &format, |
| 1031 | &channelMask); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1032 | reply->writeInt32((int32_t) input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1033 | reply->writeInt32(devices); |
| 1034 | reply->writeInt32(samplingRate); |
| 1035 | reply->writeInt32(format); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1036 | reply->writeInt32(channelMask); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1037 | return NO_ERROR; |
| 1038 | } break; |
| 1039 | case CLOSE_INPUT: { |
| 1040 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1041 | reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1042 | return NO_ERROR; |
| 1043 | } break; |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1044 | case INVALIDATE_STREAM: { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1045 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1046 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 1047 | reply->writeInt32(invalidateStream(stream)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1048 | return NO_ERROR; |
| 1049 | } break; |
Eric Laurent | f0ee6f4 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 1050 | case SET_VOICE_VOLUME: { |
| 1051 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1052 | float volume = data.readFloat(); |
| 1053 | reply->writeInt32( setVoiceVolume(volume) ); |
| 1054 | return NO_ERROR; |
| 1055 | } break; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1056 | case GET_RENDER_POSITION: { |
| 1057 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1058 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Kévin PETIT | 377b2ec | 2014-02-03 12:35:36 +0000 | [diff] [blame] | 1059 | uint32_t halFrames; |
| 1060 | uint32_t dspFrames; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1061 | status_t status = getRenderPosition(&halFrames, &dspFrames, output); |
| 1062 | reply->writeInt32(status); |
| 1063 | if (status == NO_ERROR) { |
| 1064 | reply->writeInt32(halFrames); |
| 1065 | reply->writeInt32(dspFrames); |
| 1066 | } |
| 1067 | return NO_ERROR; |
| 1068 | } |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1069 | case GET_INPUT_FRAMES_LOST: { |
| 1070 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1071 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 1072 | reply->writeInt32((int32_t) getInputFramesLost(ioHandle)); |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1073 | return NO_ERROR; |
| 1074 | } break; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1075 | case NEW_AUDIO_SESSION_ID: { |
| 1076 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1077 | reply->writeInt32(newAudioSessionId()); |
| 1078 | return NO_ERROR; |
| 1079 | } break; |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1080 | case ACQUIRE_AUDIO_SESSION_ID: { |
| 1081 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1082 | int audioSession = data.readInt32(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 1083 | int pid = data.readInt32(); |
| 1084 | acquireAudioSessionId(audioSession, pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1085 | return NO_ERROR; |
| 1086 | } break; |
| 1087 | case RELEASE_AUDIO_SESSION_ID: { |
| 1088 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1089 | int audioSession = data.readInt32(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 1090 | int pid = data.readInt32(); |
| 1091 | releaseAudioSessionId(audioSession, pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1092 | return NO_ERROR; |
| 1093 | } break; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1094 | case QUERY_NUM_EFFECTS: { |
| 1095 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1096 | uint32_t numEffects; |
| 1097 | status_t status = queryNumberEffects(&numEffects); |
| 1098 | reply->writeInt32(status); |
| 1099 | if (status == NO_ERROR) { |
| 1100 | reply->writeInt32((int32_t)numEffects); |
| 1101 | } |
| 1102 | return NO_ERROR; |
| 1103 | } |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1104 | case QUERY_EFFECT: { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1105 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1106 | effect_descriptor_t desc; |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1107 | status_t status = queryEffect(data.readInt32(), &desc); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 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 GET_EFFECT_DESCRIPTOR: { |
| 1115 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1116 | effect_uuid_t uuid; |
| 1117 | data.read(&uuid, sizeof(effect_uuid_t)); |
| 1118 | effect_descriptor_t desc; |
| 1119 | status_t status = getEffectDescriptor(&uuid, &desc); |
| 1120 | reply->writeInt32(status); |
| 1121 | if (status == NO_ERROR) { |
| 1122 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1123 | } |
| 1124 | return NO_ERROR; |
| 1125 | } |
| 1126 | case CREATE_EFFECT: { |
| 1127 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1128 | effect_descriptor_t desc; |
| 1129 | data.read(&desc, sizeof(effect_descriptor_t)); |
| 1130 | sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder()); |
| 1131 | int32_t priority = data.readInt32(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1132 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1133 | int sessionId = data.readInt32(); |
| 1134 | status_t status; |
| 1135 | int id; |
| 1136 | int enabled; |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1137 | |
Glenn Kasten | 8d6cc84 | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 1138 | sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId, |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 1139 | &status, &id, &enabled); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1140 | reply->writeInt32(status); |
| 1141 | reply->writeInt32(id); |
| 1142 | reply->writeInt32(enabled); |
| 1143 | reply->writeStrongBinder(effect->asBinder()); |
| 1144 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1145 | return NO_ERROR; |
| 1146 | } break; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1147 | case MOVE_EFFECTS: { |
| 1148 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1149 | int session = data.readInt32(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1150 | audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32(); |
| 1151 | audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1152 | reply->writeInt32(moveEffects(session, srcOutput, dstOutput)); |
| 1153 | return NO_ERROR; |
| 1154 | } break; |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1155 | case LOAD_HW_MODULE: { |
| 1156 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1157 | reply->writeInt32(loadHwModule(data.readCString())); |
| 1158 | return NO_ERROR; |
| 1159 | } break; |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1160 | case GET_PRIMARY_OUTPUT_SAMPLING_RATE: { |
| 1161 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1162 | reply->writeInt32(getPrimaryOutputSamplingRate()); |
| 1163 | return NO_ERROR; |
| 1164 | } break; |
| 1165 | case GET_PRIMARY_OUTPUT_FRAME_COUNT: { |
| 1166 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1167 | reply->writeInt64(getPrimaryOutputFrameCount()); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1168 | return NO_ERROR; |
| 1169 | } break; |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 1170 | case SET_LOW_RAM_DEVICE: { |
| 1171 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1172 | bool isLowRamDevice = data.readInt32() != 0; |
| 1173 | reply->writeInt32(setLowRamDevice(isLowRamDevice)); |
| 1174 | return NO_ERROR; |
| 1175 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1176 | default: |
| 1177 | return BBinder::onTransact(code, data, reply, flags); |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | // ---------------------------------------------------------------------------- |
| 1182 | |
| 1183 | }; // namespace android |