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, |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame^] | 65 | NEW_AUDIO_UNIQUE_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, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 77 | LIST_AUDIO_PORTS, |
| 78 | GET_AUDIO_PORT, |
| 79 | CREATE_AUDIO_PATCH, |
| 80 | RELEASE_AUDIO_PATCH, |
| 81 | LIST_AUDIO_PATCHES, |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 82 | SET_AUDIO_PORT_CONFIG, |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame^] | 83 | GET_AUDIO_HW_SYNC_FOR_SESSION, |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 84 | SYSTEM_READY, |
| 85 | FRAME_COUNT_HAL, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | }; |
| 87 | |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 88 | #define MAX_ITEMS_PER_LIST 1024 |
| 89 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | class BpAudioFlinger : public BpInterface<IAudioFlinger> |
| 91 | { |
| 92 | public: |
Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 93 | explicit BpAudioFlinger(const sp<IBinder>& impl) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | : BpInterface<IAudioFlinger>(impl) |
| 95 | { |
| 96 | } |
| 97 | |
| 98 | virtual sp<IAudioTrack> createTrack( |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 99 | audio_stream_type_t streamType, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | uint32_t sampleRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 101 | audio_format_t format, |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 102 | audio_channel_mask_t channelMask, |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 103 | size_t *pFrameCount, |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 104 | audio_output_flags_t *flags, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | const sp<IMemory>& sharedBuffer, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 106 | audio_io_handle_t output, |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 107 | pid_t pid, |
Glenn Kasten | 3acbd05 | 2012-02-28 10:39:56 -0800 | [diff] [blame] | 108 | pid_t tid, |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 109 | audio_session_t *sessionId, |
Marco Nelissen | 462fd2f | 2013-01-14 14:12:05 -0800 | [diff] [blame] | 110 | int clientUid, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 111 | status_t *status, |
| 112 | audio_port_handle_t portId) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | { |
| 114 | Parcel data, reply; |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 115 | sp<IAudioTrack> track; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 117 | data.writeInt32((int32_t) streamType); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | data.writeInt32(sampleRate); |
| 119 | data.writeInt32(format); |
Jean-Michel Trivi | 0d255b2 | 2011-05-24 15:53:33 -0700 | [diff] [blame] | 120 | data.writeInt32(channelMask); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 121 | size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0; |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 122 | data.writeInt64(frameCount); |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 123 | audio_output_flags_t lFlags = flags != NULL ? *flags : AUDIO_OUTPUT_FLAG_NONE; |
Glenn Kasten | e0b0717 | 2012-11-06 15:03:34 -0800 | [diff] [blame] | 124 | data.writeInt32(lFlags); |
Glenn Kasten | 2301acc | 2014-01-17 10:21:00 -0800 | [diff] [blame] | 125 | // haveSharedBuffer |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 126 | if (sharedBuffer != 0) { |
| 127 | data.writeInt32(true); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 128 | data.writeStrongBinder(IInterface::asBinder(sharedBuffer)); |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 129 | } else { |
| 130 | data.writeInt32(false); |
| 131 | } |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 132 | data.writeInt32((int32_t) output); |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 133 | data.writeInt32((int32_t) pid); |
Glenn Kasten | 3acbd05 | 2012-02-28 10:39:56 -0800 | [diff] [blame] | 134 | data.writeInt32((int32_t) tid); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 135 | audio_session_t lSessionId = AUDIO_SESSION_ALLOCATE; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 136 | if (sessionId != NULL) { |
| 137 | lSessionId = *sessionId; |
| 138 | } |
| 139 | data.writeInt32(lSessionId); |
Marco Nelissen | 462fd2f | 2013-01-14 14:12:05 -0800 | [diff] [blame] | 140 | data.writeInt32(clientUid); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 141 | data.writeInt32(portId); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply); |
| 143 | if (lStatus != NO_ERROR) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 144 | ALOGE("createTrack error: %s", strerror(-lStatus)); |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 145 | } else { |
Glenn Kasten | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame] | 146 | frameCount = reply.readInt64(); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 147 | if (pFrameCount != NULL) { |
| 148 | *pFrameCount = frameCount; |
| 149 | } |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 150 | lFlags = (audio_output_flags_t)reply.readInt32(); |
Glenn Kasten | e0b0717 | 2012-11-06 15:03:34 -0800 | [diff] [blame] | 151 | if (flags != NULL) { |
| 152 | *flags = lFlags; |
| 153 | } |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 154 | lSessionId = (audio_session_t) reply.readInt32(); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 155 | if (sessionId != NULL) { |
| 156 | *sessionId = lSessionId; |
| 157 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 158 | lStatus = reply.readInt32(); |
| 159 | track = interface_cast<IAudioTrack>(reply.readStrongBinder()); |
Glenn Kasten | 0cde076 | 2014-01-16 15:06:36 -0800 | [diff] [blame] | 160 | if (lStatus == NO_ERROR) { |
| 161 | if (track == 0) { |
| 162 | ALOGE("createTrack should have returned an IAudioTrack"); |
| 163 | lStatus = UNKNOWN_ERROR; |
| 164 | } |
| 165 | } else { |
| 166 | if (track != 0) { |
| 167 | ALOGE("createTrack returned an IAudioTrack but with status %d", lStatus); |
| 168 | track.clear(); |
| 169 | } |
| 170 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | } |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 172 | if (status != NULL) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | *status = lStatus; |
| 174 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 175 | return track; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | virtual sp<IAudioRecord> openRecord( |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 179 | audio_io_handle_t input, |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | uint32_t sampleRate, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 181 | audio_format_t format, |
Glenn Kasten | 28b76b3 | 2012-07-03 17:24:41 -0700 | [diff] [blame] | 182 | audio_channel_mask_t channelMask, |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 183 | const String16& opPackageName, |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 184 | size_t *pFrameCount, |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 185 | audio_input_flags_t *flags, |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 186 | pid_t pid, |
Glenn Kasten | 1879fff | 2012-07-11 15:36:59 -0700 | [diff] [blame] | 187 | pid_t tid, |
Jean-Michel Trivi | 4cb6683 | 2015-05-01 18:34:17 -0700 | [diff] [blame] | 188 | int clientUid, |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 189 | audio_session_t *sessionId, |
Glenn Kasten | 7df8c0b | 2014-07-03 12:23:29 -0700 | [diff] [blame] | 190 | size_t *notificationFrames, |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 191 | sp<IMemory>& cblk, |
| 192 | sp<IMemory>& buffers, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 193 | status_t *status, |
| 194 | audio_port_handle_t portId) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | { |
| 196 | Parcel data, reply; |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 197 | sp<IAudioRecord> record; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 198 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 199 | data.writeInt32((int32_t) input); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | data.writeInt32(sampleRate); |
| 201 | data.writeInt32(format); |
Jean-Michel Trivi | 0d255b2 | 2011-05-24 15:53:33 -0700 | [diff] [blame] | 202 | data.writeInt32(channelMask); |
Dianne Hackborn | eaa3470 | 2015-04-29 12:57:58 -0700 | [diff] [blame] | 203 | data.writeString16(opPackageName); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 204 | size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0; |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 205 | data.writeInt64(frameCount); |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 206 | audio_input_flags_t lFlags = flags != NULL ? *flags : AUDIO_INPUT_FLAG_NONE; |
Glenn Kasten | eeca326 | 2013-07-31 16:12:48 -0700 | [diff] [blame] | 207 | data.writeInt32(lFlags); |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 208 | data.writeInt32((int32_t) pid); |
Glenn Kasten | 1879fff | 2012-07-11 15:36:59 -0700 | [diff] [blame] | 209 | data.writeInt32((int32_t) tid); |
Jean-Michel Trivi | 4cb6683 | 2015-05-01 18:34:17 -0700 | [diff] [blame] | 210 | data.writeInt32((int32_t) clientUid); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 211 | audio_session_t lSessionId = AUDIO_SESSION_ALLOCATE; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 212 | if (sessionId != NULL) { |
| 213 | lSessionId = *sessionId; |
| 214 | } |
| 215 | data.writeInt32(lSessionId); |
Glenn Kasten | 7410591 | 2014-07-03 12:28:53 -0700 | [diff] [blame] | 216 | data.writeInt64(notificationFrames != NULL ? *notificationFrames : 0); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 217 | data.writeInt32(portId); |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 218 | cblk.clear(); |
| 219 | buffers.clear(); |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 220 | status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply); |
| 221 | if (lStatus != NO_ERROR) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 222 | ALOGE("openRecord error: %s", strerror(-lStatus)); |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 223 | } else { |
Glenn Kasten | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame] | 224 | frameCount = reply.readInt64(); |
Glenn Kasten | 74935e4 | 2013-12-19 08:56:45 -0800 | [diff] [blame] | 225 | if (pFrameCount != NULL) { |
| 226 | *pFrameCount = frameCount; |
| 227 | } |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 228 | lFlags = (audio_input_flags_t)reply.readInt32(); |
Glenn Kasten | eeca326 | 2013-07-31 16:12:48 -0700 | [diff] [blame] | 229 | if (flags != NULL) { |
| 230 | *flags = lFlags; |
| 231 | } |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 232 | lSessionId = (audio_session_t) reply.readInt32(); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 233 | if (sessionId != NULL) { |
| 234 | *sessionId = lSessionId; |
| 235 | } |
Glenn Kasten | 7df8c0b | 2014-07-03 12:23:29 -0700 | [diff] [blame] | 236 | size_t lNotificationFrames = (size_t) reply.readInt64(); |
| 237 | if (notificationFrames != NULL) { |
| 238 | *notificationFrames = lNotificationFrames; |
| 239 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 240 | lStatus = reply.readInt32(); |
| 241 | record = interface_cast<IAudioRecord>(reply.readStrongBinder()); |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 242 | cblk = interface_cast<IMemory>(reply.readStrongBinder()); |
| 243 | if (cblk != 0 && cblk->pointer() == NULL) { |
| 244 | cblk.clear(); |
| 245 | } |
| 246 | buffers = interface_cast<IMemory>(reply.readStrongBinder()); |
| 247 | if (buffers != 0 && buffers->pointer() == NULL) { |
| 248 | buffers.clear(); |
| 249 | } |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 250 | if (lStatus == NO_ERROR) { |
| 251 | if (record == 0) { |
| 252 | ALOGE("openRecord should have returned an IAudioRecord"); |
| 253 | lStatus = UNKNOWN_ERROR; |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 254 | } else if (cblk == 0) { |
| 255 | ALOGE("openRecord should have returned a cblk"); |
| 256 | lStatus = NO_MEMORY; |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 257 | } |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 258 | // buffers is permitted to be 0 |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 259 | } else { |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 260 | if (record != 0 || cblk != 0 || buffers != 0) { |
| 261 | ALOGE("openRecord returned an IAudioRecord, cblk, " |
| 262 | "or buffers but with status %d", lStatus); |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 263 | } |
| 264 | } |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 265 | if (lStatus != NO_ERROR) { |
| 266 | record.clear(); |
| 267 | cblk.clear(); |
| 268 | buffers.clear(); |
| 269 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 270 | } |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 271 | if (status != NULL) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 272 | *status = lStatus; |
| 273 | } |
Eric Laurent | 5841db7 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 274 | return record; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 275 | } |
| 276 | |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 277 | virtual uint32_t sampleRate(audio_io_handle_t ioHandle) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 278 | { |
| 279 | Parcel data, reply; |
| 280 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 281 | data.writeInt32((int32_t) ioHandle); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 282 | remote()->transact(SAMPLE_RATE, data, &reply); |
| 283 | return reply.readInt32(); |
| 284 | } |
| 285 | |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 286 | // RESERVED for channelCount() |
| 287 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 288 | 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] | 289 | { |
| 290 | Parcel data, reply; |
| 291 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 292 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 293 | remote()->transact(FORMAT, data, &reply); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 294 | return (audio_format_t) reply.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 295 | } |
| 296 | |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 297 | virtual size_t frameCount(audio_io_handle_t ioHandle) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | { |
| 299 | Parcel data, reply; |
| 300 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 2c073da | 2016-02-26 09:14:08 -0800 | [diff] [blame] | 301 | data.writeInt32((int32_t) ioHandle); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | remote()->transact(FRAME_COUNT, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 303 | return reply.readInt64(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 304 | } |
| 305 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 306 | 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] | 307 | { |
| 308 | Parcel data, reply; |
| 309 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 310 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 311 | remote()->transact(LATENCY, data, &reply); |
| 312 | return reply.readInt32(); |
| 313 | } |
| 314 | |
| 315 | virtual status_t setMasterVolume(float value) |
| 316 | { |
| 317 | Parcel data, reply; |
| 318 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 319 | data.writeFloat(value); |
| 320 | remote()->transact(SET_MASTER_VOLUME, data, &reply); |
| 321 | return reply.readInt32(); |
| 322 | } |
| 323 | |
| 324 | virtual status_t setMasterMute(bool muted) |
| 325 | { |
| 326 | Parcel data, reply; |
| 327 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 328 | data.writeInt32(muted); |
| 329 | remote()->transact(SET_MASTER_MUTE, data, &reply); |
| 330 | return reply.readInt32(); |
| 331 | } |
| 332 | |
| 333 | virtual float masterVolume() const |
| 334 | { |
| 335 | Parcel data, reply; |
| 336 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 337 | remote()->transact(MASTER_VOLUME, data, &reply); |
| 338 | return reply.readFloat(); |
| 339 | } |
| 340 | |
| 341 | virtual bool masterMute() const |
| 342 | { |
| 343 | Parcel data, reply; |
| 344 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 345 | remote()->transact(MASTER_MUTE, data, &reply); |
| 346 | return reply.readInt32(); |
| 347 | } |
| 348 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 349 | virtual status_t setStreamVolume(audio_stream_type_t stream, float value, |
| 350 | audio_io_handle_t output) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 351 | { |
| 352 | Parcel data, reply; |
| 353 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 354 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 355 | data.writeFloat(value); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 356 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 357 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 358 | return reply.readInt32(); |
| 359 | } |
| 360 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 361 | 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] | 362 | { |
| 363 | Parcel data, reply; |
| 364 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 365 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 366 | data.writeInt32(muted); |
| 367 | remote()->transact(SET_STREAM_MUTE, data, &reply); |
| 368 | return reply.readInt32(); |
| 369 | } |
| 370 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 371 | 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] | 372 | { |
| 373 | Parcel data, reply; |
| 374 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 375 | data.writeInt32((int32_t) stream); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 376 | data.writeInt32((int32_t) output); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 377 | remote()->transact(STREAM_VOLUME, data, &reply); |
| 378 | return reply.readFloat(); |
| 379 | } |
| 380 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 381 | virtual bool streamMute(audio_stream_type_t stream) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 382 | { |
| 383 | Parcel data, reply; |
| 384 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 385 | data.writeInt32((int32_t) stream); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | remote()->transact(STREAM_MUTE, data, &reply); |
| 387 | return reply.readInt32(); |
| 388 | } |
| 389 | |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 390 | virtual status_t setMode(audio_mode_t mode) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | { |
| 392 | Parcel data, reply; |
| 393 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 394 | data.writeInt32(mode); |
| 395 | remote()->transact(SET_MODE, data, &reply); |
| 396 | return reply.readInt32(); |
| 397 | } |
| 398 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | virtual status_t setMicMute(bool state) |
| 400 | { |
| 401 | Parcel data, reply; |
| 402 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 403 | data.writeInt32(state); |
| 404 | remote()->transact(SET_MIC_MUTE, data, &reply); |
| 405 | return reply.readInt32(); |
| 406 | } |
| 407 | |
| 408 | virtual bool getMicMute() const |
| 409 | { |
| 410 | Parcel data, reply; |
| 411 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 412 | remote()->transact(GET_MIC_MUTE, data, &reply); |
| 413 | return reply.readInt32(); |
| 414 | } |
| 415 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 416 | 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] | 417 | { |
| 418 | Parcel data, reply; |
| 419 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 420 | data.writeInt32((int32_t) ioHandle); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 421 | data.writeString8(keyValuePairs); |
| 422 | remote()->transact(SET_PARAMETERS, data, &reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 423 | return reply.readInt32(); |
| 424 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 425 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 426 | virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 427 | { |
| 428 | Parcel data, reply; |
| 429 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 430 | data.writeInt32((int32_t) ioHandle); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 431 | data.writeString8(keys); |
| 432 | remote()->transact(GET_PARAMETERS, data, &reply); |
| 433 | return reply.readString8(); |
| 434 | } |
| 435 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 436 | virtual void registerClient(const sp<IAudioFlingerClient>& client) |
| 437 | { |
| 438 | Parcel data, reply; |
| 439 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 440 | data.writeStrongBinder(IInterface::asBinder(client)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | remote()->transact(REGISTER_CLIENT, data, &reply); |
| 442 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 443 | |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 444 | virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, |
| 445 | audio_channel_mask_t channelMask) const |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 446 | { |
| 447 | Parcel data, reply; |
| 448 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 449 | data.writeInt32(sampleRate); |
| 450 | data.writeInt32(format); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 451 | data.writeInt32(channelMask); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | remote()->transact(GET_INPUTBUFFERSIZE, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 453 | return reply.readInt64(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 454 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 455 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 456 | virtual status_t openOutput(audio_module_handle_t module, |
| 457 | audio_io_handle_t *output, |
| 458 | audio_config_t *config, |
| 459 | audio_devices_t *devices, |
| 460 | const String8& address, |
| 461 | uint32_t *latencyMs, |
| 462 | audio_output_flags_t flags) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 463 | { |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 464 | if (output == NULL || config == NULL || devices == NULL || latencyMs == NULL) { |
| 465 | return BAD_VALUE; |
| 466 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | Parcel data, reply; |
| 468 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 469 | data.writeInt32(module); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 470 | data.write(config, sizeof(audio_config_t)); |
| 471 | data.writeInt32(*devices); |
| 472 | data.writeString8(address); |
Glenn Kasten | 18868c5 | 2012-03-07 09:15:37 -0800 | [diff] [blame] | 473 | data.writeInt32((int32_t) flags); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 474 | status_t status = remote()->transact(OPEN_OUTPUT, data, &reply); |
| 475 | if (status != NO_ERROR) { |
| 476 | *output = AUDIO_IO_HANDLE_NONE; |
| 477 | return status; |
Richard Fitzgerald | b1a270d | 2013-05-14 12:12:21 +0100 | [diff] [blame] | 478 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 479 | status = (status_t)reply.readInt32(); |
| 480 | if (status != NO_ERROR) { |
| 481 | *output = AUDIO_IO_HANDLE_NONE; |
| 482 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 483 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 484 | *output = (audio_io_handle_t)reply.readInt32(); |
| 485 | ALOGV("openOutput() returned output, %d", *output); |
| 486 | reply.read(config, sizeof(audio_config_t)); |
| 487 | *devices = (audio_devices_t)reply.readInt32(); |
| 488 | *latencyMs = reply.readInt32(); |
| 489 | return NO_ERROR; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 490 | } |
| 491 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 492 | virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, |
| 493 | audio_io_handle_t output2) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 494 | { |
| 495 | Parcel data, reply; |
| 496 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 497 | data.writeInt32((int32_t) output1); |
| 498 | data.writeInt32((int32_t) output2); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 499 | remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 500 | return (audio_io_handle_t) reply.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 501 | } |
| 502 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 503 | virtual status_t closeOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 504 | { |
| 505 | Parcel data, reply; |
| 506 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 507 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 508 | remote()->transact(CLOSE_OUTPUT, data, &reply); |
| 509 | return reply.readInt32(); |
| 510 | } |
| 511 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 512 | virtual status_t suspendOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 513 | { |
| 514 | Parcel data, reply; |
| 515 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 516 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 517 | remote()->transact(SUSPEND_OUTPUT, data, &reply); |
| 518 | return reply.readInt32(); |
| 519 | } |
| 520 | |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 521 | virtual status_t restoreOutput(audio_io_handle_t output) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 522 | { |
| 523 | Parcel data, reply; |
| 524 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 525 | data.writeInt32((int32_t) output); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 526 | remote()->transact(RESTORE_OUTPUT, data, &reply); |
| 527 | return reply.readInt32(); |
| 528 | } |
| 529 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 530 | virtual status_t openInput(audio_module_handle_t module, |
| 531 | audio_io_handle_t *input, |
| 532 | audio_config_t *config, |
| 533 | audio_devices_t *device, |
| 534 | const String8& address, |
| 535 | audio_source_t source, |
| 536 | audio_input_flags_t flags) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 537 | { |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 538 | if (input == NULL || config == NULL || device == NULL) { |
| 539 | return BAD_VALUE; |
| 540 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 541 | Parcel data, reply; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 542 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 543 | data.writeInt32(module); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 544 | data.writeInt32(*input); |
| 545 | data.write(config, sizeof(audio_config_t)); |
| 546 | data.writeInt32(*device); |
| 547 | data.writeString8(address); |
| 548 | data.writeInt32(source); |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 549 | data.writeInt32(flags); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 550 | status_t status = remote()->transact(OPEN_INPUT, data, &reply); |
| 551 | if (status != NO_ERROR) { |
| 552 | *input = AUDIO_IO_HANDLE_NONE; |
| 553 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 554 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 555 | status = (status_t)reply.readInt32(); |
| 556 | if (status != NO_ERROR) { |
| 557 | *input = AUDIO_IO_HANDLE_NONE; |
| 558 | return status; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 559 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 560 | *input = (audio_io_handle_t)reply.readInt32(); |
| 561 | reply.read(config, sizeof(audio_config_t)); |
| 562 | *device = (audio_devices_t)reply.readInt32(); |
| 563 | return NO_ERROR; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 564 | } |
| 565 | |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 566 | virtual status_t closeInput(int input) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 567 | { |
| 568 | Parcel data, reply; |
| 569 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 570 | data.writeInt32(input); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 571 | remote()->transact(CLOSE_INPUT, data, &reply); |
| 572 | return reply.readInt32(); |
| 573 | } |
| 574 | |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 575 | virtual status_t invalidateStream(audio_stream_type_t stream) |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 576 | { |
| 577 | Parcel data, reply; |
| 578 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 579 | data.writeInt32((int32_t) stream); |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 580 | remote()->transact(INVALIDATE_STREAM, data, &reply); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 581 | return reply.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 582 | } |
Eric Laurent | f0ee6f4 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 583 | |
| 584 | virtual status_t setVoiceVolume(float volume) |
| 585 | { |
| 586 | Parcel data, reply; |
| 587 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 588 | data.writeFloat(volume); |
| 589 | remote()->transact(SET_VOICE_VOLUME, data, &reply); |
| 590 | return reply.readInt32(); |
| 591 | } |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 592 | |
Kévin PETIT | 377b2ec | 2014-02-03 12:35:36 +0000 | [diff] [blame] | 593 | virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 594 | audio_io_handle_t output) const |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 595 | { |
| 596 | Parcel data, reply; |
| 597 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 598 | data.writeInt32((int32_t) output); |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 599 | remote()->transact(GET_RENDER_POSITION, data, &reply); |
| 600 | status_t status = reply.readInt32(); |
| 601 | if (status == NO_ERROR) { |
| 602 | uint32_t tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 603 | if (halFrames != NULL) { |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 604 | *halFrames = tmp; |
| 605 | } |
| 606 | tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 607 | if (dspFrames != NULL) { |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 608 | *dspFrames = tmp; |
| 609 | } |
| 610 | } |
| 611 | return status; |
| 612 | } |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 613 | |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 614 | virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 615 | { |
| 616 | Parcel data, reply; |
| 617 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 618 | data.writeInt32((int32_t) ioHandle); |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 619 | status_t status = remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply); |
| 620 | if (status != NO_ERROR) { |
| 621 | return 0; |
| 622 | } |
| 623 | return (uint32_t) reply.readInt32(); |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 624 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 625 | |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 626 | virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use) |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 627 | { |
| 628 | Parcel data, reply; |
| 629 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 630 | data.writeInt32((int32_t) use); |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame^] | 631 | status_t status = remote()->transact(NEW_AUDIO_UNIQUE_ID, data, &reply); |
| 632 | audio_unique_id_t id = AUDIO_UNIQUE_ID_ALLOCATE; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 633 | if (status == NO_ERROR) { |
| 634 | id = reply.readInt32(); |
| 635 | } |
| 636 | return id; |
| 637 | } |
| 638 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 639 | virtual void acquireAudioSessionId(audio_session_t audioSession, int pid) |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 640 | { |
| 641 | Parcel data, reply; |
| 642 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 643 | data.writeInt32(audioSession); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 644 | data.writeInt32(pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 645 | remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply); |
| 646 | } |
| 647 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 648 | virtual void releaseAudioSessionId(audio_session_t audioSession, int pid) |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 649 | { |
| 650 | Parcel data, reply; |
| 651 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 652 | data.writeInt32(audioSession); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 653 | data.writeInt32(pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 654 | remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply); |
| 655 | } |
| 656 | |
Glenn Kasten | f587ba5 | 2012-01-26 16:25:10 -0800 | [diff] [blame] | 657 | virtual status_t queryNumberEffects(uint32_t *numEffects) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 658 | { |
| 659 | Parcel data, reply; |
| 660 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 661 | status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply); |
| 662 | if (status != NO_ERROR) { |
| 663 | return status; |
| 664 | } |
| 665 | status = reply.readInt32(); |
| 666 | if (status != NO_ERROR) { |
| 667 | return status; |
| 668 | } |
Glenn Kasten | 9d1f02d | 2012-02-08 17:47:58 -0800 | [diff] [blame] | 669 | if (numEffects != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 670 | *numEffects = (uint32_t)reply.readInt32(); |
| 671 | } |
| 672 | return NO_ERROR; |
| 673 | } |
| 674 | |
Glenn Kasten | f587ba5 | 2012-01-26 16:25:10 -0800 | [diff] [blame] | 675 | virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 676 | { |
| 677 | if (pDescriptor == NULL) { |
| 678 | return BAD_VALUE; |
| 679 | } |
| 680 | Parcel data, reply; |
| 681 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 682 | data.writeInt32(index); |
| 683 | status_t status = remote()->transact(QUERY_EFFECT, data, &reply); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 684 | if (status != NO_ERROR) { |
| 685 | return status; |
| 686 | } |
| 687 | status = reply.readInt32(); |
| 688 | if (status != NO_ERROR) { |
| 689 | return status; |
| 690 | } |
| 691 | reply.read(pDescriptor, sizeof(effect_descriptor_t)); |
| 692 | return NO_ERROR; |
| 693 | } |
| 694 | |
Glenn Kasten | 5e92a78 | 2012-01-30 07:40:52 -0800 | [diff] [blame] | 695 | virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid, |
Glenn Kasten | f587ba5 | 2012-01-26 16:25:10 -0800 | [diff] [blame] | 696 | effect_descriptor_t *pDescriptor) const |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 697 | { |
| 698 | if (pUuid == NULL || pDescriptor == NULL) { |
| 699 | return BAD_VALUE; |
| 700 | } |
| 701 | Parcel data, reply; |
| 702 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 703 | data.write(pUuid, sizeof(effect_uuid_t)); |
| 704 | status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply); |
| 705 | if (status != NO_ERROR) { |
| 706 | return status; |
| 707 | } |
| 708 | status = reply.readInt32(); |
| 709 | if (status != NO_ERROR) { |
| 710 | return status; |
| 711 | } |
| 712 | reply.read(pDescriptor, sizeof(effect_descriptor_t)); |
| 713 | return NO_ERROR; |
| 714 | } |
| 715 | |
Glenn Kasten | 8d6cc84 | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 716 | virtual sp<IEffect> createEffect( |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 717 | effect_descriptor_t *pDesc, |
| 718 | const sp<IEffectClient>& client, |
| 719 | int32_t priority, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 720 | audio_io_handle_t output, |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 721 | audio_session_t sessionId, |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 722 | const String16& opPackageName, |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 723 | pid_t pid, |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 724 | status_t *status, |
| 725 | int *id, |
| 726 | int *enabled) |
| 727 | { |
| 728 | Parcel data, reply; |
| 729 | sp<IEffect> effect; |
| 730 | |
| 731 | if (pDesc == NULL) { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 732 | return effect; |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 733 | if (status != NULL) { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 734 | *status = BAD_VALUE; |
| 735 | } |
| 736 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 737 | |
| 738 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 739 | data.write(pDesc, sizeof(effect_descriptor_t)); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 740 | data.writeStrongBinder(IInterface::asBinder(client)); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 741 | data.writeInt32(priority); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 742 | data.writeInt32((int32_t) output); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 743 | data.writeInt32(sessionId); |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 744 | data.writeString16(opPackageName); |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 745 | data.writeInt32((int32_t) pid); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 746 | |
| 747 | status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply); |
| 748 | if (lStatus != NO_ERROR) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 749 | ALOGE("createEffect error: %s", strerror(-lStatus)); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 750 | } else { |
| 751 | lStatus = reply.readInt32(); |
| 752 | int tmp = reply.readInt32(); |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 753 | if (id != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 754 | *id = tmp; |
| 755 | } |
| 756 | tmp = reply.readInt32(); |
Glenn Kasten | a0d6833 | 2012-01-27 16:47:15 -0800 | [diff] [blame] | 757 | if (enabled != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 758 | *enabled = tmp; |
| 759 | } |
| 760 | effect = interface_cast<IEffect>(reply.readStrongBinder()); |
| 761 | reply.read(pDesc, sizeof(effect_descriptor_t)); |
| 762 | } |
Glenn Kasten | 507b286 | 2013-07-31 16:12:13 -0700 | [diff] [blame] | 763 | if (status != NULL) { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 764 | *status = lStatus; |
| 765 | } |
| 766 | |
| 767 | return effect; |
| 768 | } |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 769 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 770 | virtual status_t moveEffects(audio_session_t session, audio_io_handle_t srcOutput, |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 771 | audio_io_handle_t dstOutput) |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 772 | { |
| 773 | Parcel data, reply; |
| 774 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 775 | data.writeInt32(session); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 776 | data.writeInt32((int32_t) srcOutput); |
| 777 | data.writeInt32((int32_t) dstOutput); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 778 | remote()->transact(MOVE_EFFECTS, data, &reply); |
| 779 | return reply.readInt32(); |
| 780 | } |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 781 | |
| 782 | virtual audio_module_handle_t loadHwModule(const char *name) |
| 783 | { |
| 784 | Parcel data, reply; |
| 785 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 786 | data.writeCString(name); |
| 787 | remote()->transact(LOAD_HW_MODULE, data, &reply); |
| 788 | return (audio_module_handle_t) reply.readInt32(); |
| 789 | } |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 790 | |
Glenn Kasten | 3b16c76 | 2012-11-14 08:44:39 -0800 | [diff] [blame] | 791 | virtual uint32_t getPrimaryOutputSamplingRate() |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 792 | { |
| 793 | Parcel data, reply; |
| 794 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 795 | remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply); |
| 796 | return reply.readInt32(); |
| 797 | } |
| 798 | |
Glenn Kasten | e33054e | 2012-11-14 12:54:39 -0800 | [diff] [blame] | 799 | virtual size_t getPrimaryOutputFrameCount() |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 800 | { |
| 801 | Parcel data, reply; |
| 802 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 803 | remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 804 | return reply.readInt64(); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 805 | } |
| 806 | |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 807 | virtual status_t setLowRamDevice(bool isLowRamDevice) |
| 808 | { |
| 809 | Parcel data, reply; |
| 810 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 811 | data.writeInt32((int) isLowRamDevice); |
| 812 | remote()->transact(SET_LOW_RAM_DEVICE, data, &reply); |
| 813 | return reply.readInt32(); |
| 814 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 815 | virtual status_t listAudioPorts(unsigned int *num_ports, |
| 816 | struct audio_port *ports) |
| 817 | { |
| 818 | if (num_ports == NULL || *num_ports == 0 || ports == NULL) { |
| 819 | return BAD_VALUE; |
| 820 | } |
| 821 | Parcel data, reply; |
| 822 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 823 | data.writeInt32(*num_ports); |
| 824 | status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply); |
| 825 | if (status != NO_ERROR || |
| 826 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 827 | return status; |
| 828 | } |
| 829 | *num_ports = (unsigned int)reply.readInt32(); |
| 830 | reply.read(ports, *num_ports * sizeof(struct audio_port)); |
| 831 | return status; |
| 832 | } |
| 833 | virtual status_t getAudioPort(struct audio_port *port) |
| 834 | { |
| 835 | if (port == NULL) { |
| 836 | return BAD_VALUE; |
| 837 | } |
| 838 | Parcel data, reply; |
| 839 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 840 | data.write(port, sizeof(struct audio_port)); |
| 841 | status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply); |
| 842 | if (status != NO_ERROR || |
| 843 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 844 | return status; |
| 845 | } |
| 846 | reply.read(port, sizeof(struct audio_port)); |
| 847 | return status; |
| 848 | } |
| 849 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 850 | audio_patch_handle_t *handle) |
| 851 | { |
| 852 | if (patch == NULL || handle == NULL) { |
| 853 | return BAD_VALUE; |
| 854 | } |
| 855 | Parcel data, reply; |
| 856 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 857 | data.write(patch, sizeof(struct audio_patch)); |
| 858 | data.write(handle, sizeof(audio_patch_handle_t)); |
| 859 | status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply); |
| 860 | if (status != NO_ERROR || |
| 861 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 862 | return status; |
| 863 | } |
| 864 | reply.read(handle, sizeof(audio_patch_handle_t)); |
| 865 | return status; |
| 866 | } |
| 867 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle) |
| 868 | { |
| 869 | Parcel data, reply; |
| 870 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 871 | data.write(&handle, sizeof(audio_patch_handle_t)); |
| 872 | status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply); |
| 873 | if (status != NO_ERROR) { |
| 874 | status = (status_t)reply.readInt32(); |
| 875 | } |
| 876 | return status; |
| 877 | } |
| 878 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 879 | struct audio_patch *patches) |
| 880 | { |
| 881 | if (num_patches == NULL || *num_patches == 0 || patches == NULL) { |
| 882 | return BAD_VALUE; |
| 883 | } |
| 884 | Parcel data, reply; |
| 885 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 886 | data.writeInt32(*num_patches); |
| 887 | status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply); |
| 888 | if (status != NO_ERROR || |
| 889 | (status = (status_t)reply.readInt32()) != NO_ERROR) { |
| 890 | return status; |
| 891 | } |
| 892 | *num_patches = (unsigned int)reply.readInt32(); |
| 893 | reply.read(patches, *num_patches * sizeof(struct audio_patch)); |
| 894 | return status; |
| 895 | } |
| 896 | virtual status_t setAudioPortConfig(const struct audio_port_config *config) |
| 897 | { |
| 898 | if (config == NULL) { |
| 899 | return BAD_VALUE; |
| 900 | } |
| 901 | Parcel data, reply; |
| 902 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 903 | data.write(config, sizeof(struct audio_port_config)); |
| 904 | status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply); |
| 905 | if (status != NO_ERROR) { |
| 906 | status = (status_t)reply.readInt32(); |
| 907 | } |
| 908 | return status; |
| 909 | } |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 910 | virtual audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId) |
| 911 | { |
| 912 | Parcel data, reply; |
| 913 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 914 | data.writeInt32(sessionId); |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame^] | 915 | status_t status = remote()->transact(GET_AUDIO_HW_SYNC_FOR_SESSION, data, &reply); |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 916 | if (status != NO_ERROR) { |
| 917 | return AUDIO_HW_SYNC_INVALID; |
| 918 | } |
| 919 | return (audio_hw_sync_t)reply.readInt32(); |
| 920 | } |
Eric Laurent | 72e3f39 | 2015-05-20 14:43:50 -0700 | [diff] [blame] | 921 | virtual status_t systemReady() |
| 922 | { |
| 923 | Parcel data, reply; |
| 924 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 925 | return remote()->transact(SYSTEM_READY, data, &reply, IBinder::FLAG_ONEWAY); |
| 926 | } |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 927 | virtual size_t frameCountHAL(audio_io_handle_t ioHandle) const |
| 928 | { |
| 929 | Parcel data, reply; |
| 930 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 931 | data.writeInt32((int32_t) ioHandle); |
| 932 | status_t status = remote()->transact(FRAME_COUNT_HAL, data, &reply); |
| 933 | if (status != NO_ERROR) { |
| 934 | return 0; |
| 935 | } |
| 936 | return reply.readInt64(); |
| 937 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 938 | }; |
| 939 | |
| 940 | IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger"); |
| 941 | |
| 942 | // ---------------------------------------------------------------------- |
| 943 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 944 | status_t BnAudioFlinger::onTransact( |
| 945 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 946 | { |
Nicolas Roulet | dcdfaec | 2017-02-14 10:18:39 -0800 | [diff] [blame] | 947 | // Whitelist of relevant events to trigger log merging. |
| 948 | // Log merging should activate during audio activity of any kind. This are considered the |
| 949 | // most relevant events. |
| 950 | // TODO should select more wisely the items from the list |
| 951 | switch (code) { |
| 952 | case CREATE_TRACK: |
| 953 | case OPEN_RECORD: |
| 954 | case SET_MASTER_VOLUME: |
| 955 | case SET_MASTER_MUTE: |
| 956 | case SET_STREAM_VOLUME: |
| 957 | case SET_STREAM_MUTE: |
| 958 | case SET_MIC_MUTE: |
| 959 | case SET_PARAMETERS: |
| 960 | case OPEN_INPUT: |
| 961 | case SET_VOICE_VOLUME: |
| 962 | case CREATE_EFFECT: |
| 963 | case SYSTEM_READY: { |
| 964 | requestLogMerge(); |
| 965 | break; |
| 966 | } |
| 967 | default: |
| 968 | break; |
| 969 | } |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 970 | switch (code) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 971 | case CREATE_TRACK: { |
| 972 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 973 | int streamType = data.readInt32(); |
| 974 | uint32_t sampleRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 975 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 976 | audio_channel_mask_t channelMask = data.readInt32(); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 977 | size_t frameCount = data.readInt64(); |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 978 | audio_output_flags_t flags = (audio_output_flags_t) data.readInt32(); |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 979 | bool haveSharedBuffer = data.readInt32() != 0; |
| 980 | sp<IMemory> buffer; |
| 981 | if (haveSharedBuffer) { |
| 982 | buffer = interface_cast<IMemory>(data.readStrongBinder()); |
| 983 | } |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 984 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 985 | pid_t pid = (pid_t) data.readInt32(); |
Glenn Kasten | 3acbd05 | 2012-02-28 10:39:56 -0800 | [diff] [blame] | 986 | pid_t tid = (pid_t) data.readInt32(); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 987 | audio_session_t sessionId = (audio_session_t) data.readInt32(); |
Marco Nelissen | 462fd2f | 2013-01-14 14:12:05 -0800 | [diff] [blame] | 988 | int clientUid = data.readInt32(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 989 | audio_port_handle_t portId = (audio_port_handle_t) data.readInt32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 990 | status_t status = NO_ERROR; |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 991 | sp<IAudioTrack> track; |
| 992 | if ((haveSharedBuffer && (buffer == 0)) || |
| 993 | ((buffer != 0) && (buffer->pointer() == NULL))) { |
| 994 | ALOGW("CREATE_TRACK: cannot retrieve shared memory"); |
| 995 | status = DEAD_OBJECT; |
| 996 | } else { |
| 997 | track = createTrack( |
| 998 | (audio_stream_type_t) streamType, sampleRate, format, |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 999 | channelMask, &frameCount, &flags, buffer, output, pid, tid, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1000 | &sessionId, clientUid, &status, portId); |
Glenn Kasten | 0cde076 | 2014-01-16 15:06:36 -0800 | [diff] [blame] | 1001 | LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR)); |
Eric Laurent | 3d00aa6 | 2013-09-24 09:53:27 -0700 | [diff] [blame] | 1002 | } |
Glenn Kasten | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame] | 1003 | reply->writeInt64(frameCount); |
Glenn Kasten | e0b0717 | 2012-11-06 15:03:34 -0800 | [diff] [blame] | 1004 | reply->writeInt32(flags); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1005 | reply->writeInt32(sessionId); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1006 | reply->writeInt32(status); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 1007 | reply->writeStrongBinder(IInterface::asBinder(track)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1008 | return NO_ERROR; |
| 1009 | } break; |
| 1010 | case OPEN_RECORD: { |
| 1011 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1012 | 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] | 1013 | uint32_t sampleRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 1014 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 1015 | audio_channel_mask_t channelMask = data.readInt32(); |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 1016 | const String16& opPackageName = data.readString16(); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1017 | size_t frameCount = data.readInt64(); |
Eric Laurent | 0506778 | 2016-06-01 18:27:28 -0700 | [diff] [blame] | 1018 | audio_input_flags_t flags = (audio_input_flags_t) data.readInt32(); |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 1019 | pid_t pid = (pid_t) data.readInt32(); |
Glenn Kasten | 1879fff | 2012-07-11 15:36:59 -0700 | [diff] [blame] | 1020 | pid_t tid = (pid_t) data.readInt32(); |
Jean-Michel Trivi | 4cb6683 | 2015-05-01 18:34:17 -0700 | [diff] [blame] | 1021 | int clientUid = data.readInt32(); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1022 | audio_session_t sessionId = (audio_session_t) data.readInt32(); |
Glenn Kasten | 7410591 | 2014-07-03 12:28:53 -0700 | [diff] [blame] | 1023 | size_t notificationFrames = data.readInt64(); |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1024 | audio_port_handle_t portId = (audio_port_handle_t) data.readInt32(); |
Glenn Kasten | d776ac6 | 2014-05-07 09:16:09 -0700 | [diff] [blame] | 1025 | sp<IMemory> cblk; |
| 1026 | sp<IMemory> buffers; |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1027 | status_t status = NO_ERROR; |
Glenn Kasten | 8d6cc84 | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 1028 | sp<IAudioRecord> record = openRecord(input, |
Haynes Mathew George | 9ea77cd | 2016-04-06 17:07:48 -0700 | [diff] [blame] | 1029 | sampleRate, format, channelMask, opPackageName, &frameCount, &flags, |
| 1030 | pid, tid, clientUid, &sessionId, ¬ificationFrames, cblk, buffers, |
Eric Laurent | 20b9ef0 | 2016-12-05 11:03:16 -0800 | [diff] [blame] | 1031 | &status, portId); |
Glenn Kasten | e93cf2c | 2013-09-24 11:52:37 -0700 | [diff] [blame] | 1032 | LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR)); |
Glenn Kasten | b53fc4e | 2014-05-02 08:03:58 -0700 | [diff] [blame] | 1033 | reply->writeInt64(frameCount); |
Glenn Kasten | eeca326 | 2013-07-31 16:12:48 -0700 | [diff] [blame] | 1034 | reply->writeInt32(flags); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1035 | reply->writeInt32(sessionId); |
Glenn Kasten | 7df8c0b | 2014-07-03 12:23:29 -0700 | [diff] [blame] | 1036 | reply->writeInt64(notificationFrames); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1037 | reply->writeInt32(status); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 1038 | reply->writeStrongBinder(IInterface::asBinder(record)); |
| 1039 | reply->writeStrongBinder(IInterface::asBinder(cblk)); |
| 1040 | reply->writeStrongBinder(IInterface::asBinder(buffers)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1041 | return NO_ERROR; |
| 1042 | } break; |
| 1043 | case SAMPLE_RATE: { |
| 1044 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1045 | reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1046 | return NO_ERROR; |
| 1047 | } break; |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 1048 | |
| 1049 | // RESERVED for channelCount() |
| 1050 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1051 | case FORMAT: { |
| 1052 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1053 | reply->writeInt32( format((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1054 | return NO_ERROR; |
| 1055 | } break; |
| 1056 | case FRAME_COUNT: { |
| 1057 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1058 | reply->writeInt64( frameCount((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1059 | return NO_ERROR; |
| 1060 | } break; |
| 1061 | case LATENCY: { |
| 1062 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1063 | reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1064 | return NO_ERROR; |
| 1065 | } break; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1066 | case SET_MASTER_VOLUME: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1067 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1068 | reply->writeInt32( setMasterVolume(data.readFloat()) ); |
| 1069 | return NO_ERROR; |
| 1070 | } break; |
| 1071 | case SET_MASTER_MUTE: { |
| 1072 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1073 | reply->writeInt32( setMasterMute(data.readInt32()) ); |
| 1074 | return NO_ERROR; |
| 1075 | } break; |
| 1076 | case MASTER_VOLUME: { |
| 1077 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1078 | reply->writeFloat( masterVolume() ); |
| 1079 | return NO_ERROR; |
| 1080 | } break; |
| 1081 | case MASTER_MUTE: { |
| 1082 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1083 | reply->writeInt32( masterMute() ); |
| 1084 | return NO_ERROR; |
| 1085 | } break; |
| 1086 | case SET_STREAM_VOLUME: { |
| 1087 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1088 | int stream = data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1089 | float volume = data.readFloat(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1090 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1091 | 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] | 1092 | return NO_ERROR; |
| 1093 | } break; |
| 1094 | case SET_STREAM_MUTE: { |
| 1095 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1096 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1097 | 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] | 1098 | return NO_ERROR; |
| 1099 | } break; |
| 1100 | case STREAM_VOLUME: { |
| 1101 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1102 | int stream = data.readInt32(); |
Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 1103 | int output = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1104 | reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1105 | return NO_ERROR; |
| 1106 | } break; |
| 1107 | case STREAM_MUTE: { |
| 1108 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1109 | int stream = data.readInt32(); |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 1110 | reply->writeInt32( streamMute((audio_stream_type_t) stream) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1111 | return NO_ERROR; |
| 1112 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1113 | case SET_MODE: { |
| 1114 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 1115 | audio_mode_t mode = (audio_mode_t) data.readInt32(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1116 | reply->writeInt32( setMode(mode) ); |
| 1117 | return NO_ERROR; |
| 1118 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1119 | case SET_MIC_MUTE: { |
| 1120 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1121 | int state = data.readInt32(); |
| 1122 | reply->writeInt32( setMicMute(state) ); |
| 1123 | return NO_ERROR; |
| 1124 | } break; |
| 1125 | case GET_MIC_MUTE: { |
| 1126 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1127 | reply->writeInt32( getMicMute() ); |
| 1128 | return NO_ERROR; |
| 1129 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1130 | case SET_PARAMETERS: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1131 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1132 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1133 | String8 keyValuePairs(data.readString8()); |
| 1134 | reply->writeInt32(setParameters(ioHandle, keyValuePairs)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1135 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1136 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1137 | case GET_PARAMETERS: { |
| 1138 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1139 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1140 | String8 keys(data.readString8()); |
| 1141 | reply->writeString8(getParameters(ioHandle, keys)); |
| 1142 | return NO_ERROR; |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1143 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1144 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1145 | case REGISTER_CLIENT: { |
| 1146 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 1147 | sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>( |
| 1148 | data.readStrongBinder()); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1149 | registerClient(client); |
| 1150 | return NO_ERROR; |
| 1151 | } break; |
| 1152 | case GET_INPUTBUFFERSIZE: { |
| 1153 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1154 | uint32_t sampleRate = data.readInt32(); |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 1155 | audio_format_t format = (audio_format_t) data.readInt32(); |
Glenn Kasten | dd8104c | 2012-07-02 12:42:44 -0700 | [diff] [blame] | 1156 | audio_channel_mask_t channelMask = data.readInt32(); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1157 | reply->writeInt64( getInputBufferSize(sampleRate, format, channelMask) ); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1158 | return NO_ERROR; |
| 1159 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1160 | case OPEN_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1161 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1162 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1163 | audio_config_t config = {}; |
| 1164 | if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) { |
| 1165 | ALOGE("b/23905951"); |
| 1166 | } |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1167 | audio_devices_t devices = (audio_devices_t)data.readInt32(); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1168 | String8 address(data.readString8()); |
Eric Laurent | 0ca3cf9 | 2012-04-18 09:24:29 -0700 | [diff] [blame] | 1169 | audio_output_flags_t flags = (audio_output_flags_t) data.readInt32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1170 | uint32_t latencyMs = 0; |
Wei Jia | 4cac44b | 2015-09-16 15:01:16 -0700 | [diff] [blame] | 1171 | audio_io_handle_t output = AUDIO_IO_HANDLE_NONE; |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1172 | status_t status = openOutput(module, &output, &config, |
| 1173 | &devices, address, &latencyMs, flags); |
Glenn Kasten | 7074296 | 2014-02-18 08:00:47 -0800 | [diff] [blame] | 1174 | ALOGV("OPEN_OUTPUT output, %d", output); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1175 | reply->writeInt32((int32_t)status); |
| 1176 | if (status == NO_ERROR) { |
| 1177 | reply->writeInt32((int32_t)output); |
| 1178 | reply->write(&config, sizeof(audio_config_t)); |
| 1179 | reply->writeInt32(devices); |
| 1180 | reply->writeInt32(latencyMs); |
| 1181 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1182 | return NO_ERROR; |
| 1183 | } break; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1184 | case OPEN_DUPLICATE_OUTPUT: { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1185 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1186 | audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32(); |
| 1187 | audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32(); |
| 1188 | reply->writeInt32((int32_t) openDuplicateOutput(output1, output2)); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1189 | return NO_ERROR; |
| 1190 | } break; |
| 1191 | case CLOSE_OUTPUT: { |
| 1192 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1193 | reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1194 | return NO_ERROR; |
| 1195 | } break; |
| 1196 | case SUSPEND_OUTPUT: { |
| 1197 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1198 | reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1199 | return NO_ERROR; |
| 1200 | } break; |
| 1201 | case RESTORE_OUTPUT: { |
| 1202 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1203 | reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1204 | return NO_ERROR; |
| 1205 | } break; |
| 1206 | case OPEN_INPUT: { |
| 1207 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1208 | audio_module_handle_t module = (audio_module_handle_t)data.readInt32(); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1209 | audio_io_handle_t input = (audio_io_handle_t)data.readInt32(); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1210 | audio_config_t config = {}; |
| 1211 | if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) { |
| 1212 | ALOGE("b/23905951"); |
| 1213 | } |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1214 | audio_devices_t device = (audio_devices_t)data.readInt32(); |
| 1215 | String8 address(data.readString8()); |
| 1216 | audio_source_t source = (audio_source_t)data.readInt32(); |
Glenn Kasten | ec40d28 | 2014-07-15 15:31:26 -0700 | [diff] [blame] | 1217 | audio_input_flags_t flags = (audio_input_flags_t) data.readInt32(); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1218 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 1219 | status_t status = openInput(module, &input, &config, |
| 1220 | &device, address, source, flags); |
| 1221 | reply->writeInt32((int32_t) status); |
| 1222 | if (status == NO_ERROR) { |
| 1223 | reply->writeInt32((int32_t) input); |
| 1224 | reply->write(&config, sizeof(audio_config_t)); |
| 1225 | reply->writeInt32(device); |
| 1226 | } |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1227 | return NO_ERROR; |
| 1228 | } break; |
| 1229 | case CLOSE_INPUT: { |
| 1230 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1231 | reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32())); |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1232 | return NO_ERROR; |
| 1233 | } break; |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1234 | case INVALIDATE_STREAM: { |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1235 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d2304db | 2014-02-03 07:40:31 -0800 | [diff] [blame] | 1236 | audio_stream_type_t stream = (audio_stream_type_t) data.readInt32(); |
| 1237 | reply->writeInt32(invalidateStream(stream)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1238 | return NO_ERROR; |
| 1239 | } break; |
Eric Laurent | f0ee6f4 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 1240 | case SET_VOICE_VOLUME: { |
| 1241 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1242 | float volume = data.readFloat(); |
| 1243 | reply->writeInt32( setVoiceVolume(volume) ); |
| 1244 | return NO_ERROR; |
| 1245 | } break; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1246 | case GET_RENDER_POSITION: { |
| 1247 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1248 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1249 | uint32_t halFrames = 0; |
| 1250 | uint32_t dspFrames = 0; |
Eric Laurent | 342e9cf | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 1251 | status_t status = getRenderPosition(&halFrames, &dspFrames, output); |
| 1252 | reply->writeInt32(status); |
| 1253 | if (status == NO_ERROR) { |
| 1254 | reply->writeInt32(halFrames); |
| 1255 | reply->writeInt32(dspFrames); |
| 1256 | } |
| 1257 | return NO_ERROR; |
| 1258 | } |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1259 | case GET_INPUT_FRAMES_LOST: { |
| 1260 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1261 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | 5f972c0 | 2014-01-13 09:59:31 -0800 | [diff] [blame] | 1262 | reply->writeInt32((int32_t) getInputFramesLost(ioHandle)); |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1263 | return NO_ERROR; |
| 1264 | } break; |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame^] | 1265 | case NEW_AUDIO_UNIQUE_ID: { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1266 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 1267 | reply->writeInt32(newAudioUniqueId((audio_unique_id_use_t) data.readInt32())); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1268 | return NO_ERROR; |
| 1269 | } break; |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1270 | case ACQUIRE_AUDIO_SESSION_ID: { |
| 1271 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1272 | audio_session_t audioSession = (audio_session_t) data.readInt32(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 1273 | int pid = data.readInt32(); |
| 1274 | acquireAudioSessionId(audioSession, pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1275 | return NO_ERROR; |
| 1276 | } break; |
| 1277 | case RELEASE_AUDIO_SESSION_ID: { |
| 1278 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1279 | audio_session_t audioSession = (audio_session_t) data.readInt32(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 1280 | int pid = data.readInt32(); |
| 1281 | releaseAudioSessionId(audioSession, pid); |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1282 | return NO_ERROR; |
| 1283 | } break; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1284 | case QUERY_NUM_EFFECTS: { |
| 1285 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1286 | uint32_t numEffects = 0; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1287 | status_t status = queryNumberEffects(&numEffects); |
| 1288 | reply->writeInt32(status); |
| 1289 | if (status == NO_ERROR) { |
| 1290 | reply->writeInt32((int32_t)numEffects); |
| 1291 | } |
| 1292 | return NO_ERROR; |
| 1293 | } |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1294 | case QUERY_EFFECT: { |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1295 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1296 | effect_descriptor_t desc = {}; |
Eric Laurent | ffe9c25 | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 1297 | status_t status = queryEffect(data.readInt32(), &desc); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1298 | reply->writeInt32(status); |
| 1299 | if (status == NO_ERROR) { |
| 1300 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1301 | } |
| 1302 | return NO_ERROR; |
| 1303 | } |
| 1304 | case GET_EFFECT_DESCRIPTOR: { |
| 1305 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1306 | effect_uuid_t uuid; |
| 1307 | data.read(&uuid, sizeof(effect_uuid_t)); |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1308 | effect_descriptor_t desc = {}; |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1309 | status_t status = getEffectDescriptor(&uuid, &desc); |
| 1310 | reply->writeInt32(status); |
| 1311 | if (status == NO_ERROR) { |
| 1312 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1313 | } |
| 1314 | return NO_ERROR; |
| 1315 | } |
| 1316 | case CREATE_EFFECT: { |
| 1317 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1318 | effect_descriptor_t desc = {}; |
| 1319 | if (data.read(&desc, sizeof(effect_descriptor_t)) != NO_ERROR) { |
| 1320 | ALOGE("b/23905951"); |
| 1321 | } |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1322 | sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder()); |
| 1323 | int32_t priority = data.readInt32(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1324 | audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1325 | audio_session_t sessionId = (audio_session_t) data.readInt32(); |
Svet Ganov | be71aa2 | 2015-04-28 12:06:02 -0700 | [diff] [blame] | 1326 | const String16 opPackageName = data.readString16(); |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 1327 | pid_t pid = (pid_t)data.readInt32(); |
| 1328 | |
Wei Jia | 983dca3 | 2015-09-10 09:47:29 -0700 | [diff] [blame] | 1329 | status_t status = NO_ERROR; |
| 1330 | int id = 0; |
| 1331 | int enabled = 0; |
Eric Laurent | 05bca2f | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 1332 | |
Glenn Kasten | 8d6cc84 | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 1333 | sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId, |
Eric Laurent | b643627 | 2016-12-07 19:24:50 -0800 | [diff] [blame] | 1334 | opPackageName, pid, &status, &id, &enabled); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1335 | reply->writeInt32(status); |
| 1336 | reply->writeInt32(id); |
| 1337 | reply->writeInt32(enabled); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 1338 | reply->writeStrongBinder(IInterface::asBinder(effect)); |
Eric Laurent | be916aa | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 1339 | reply->write(&desc, sizeof(effect_descriptor_t)); |
| 1340 | return NO_ERROR; |
| 1341 | } break; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1342 | case MOVE_EFFECTS: { |
| 1343 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1344 | audio_session_t session = (audio_session_t) data.readInt32(); |
Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 1345 | audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32(); |
| 1346 | audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32(); |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 1347 | reply->writeInt32(moveEffects(session, srcOutput, dstOutput)); |
| 1348 | return NO_ERROR; |
| 1349 | } break; |
Eric Laurent | a4c5a55 | 2012-03-29 10:12:40 -0700 | [diff] [blame] | 1350 | case LOAD_HW_MODULE: { |
| 1351 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1352 | reply->writeInt32(loadHwModule(data.readCString())); |
| 1353 | return NO_ERROR; |
| 1354 | } break; |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1355 | case GET_PRIMARY_OUTPUT_SAMPLING_RATE: { |
| 1356 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1357 | reply->writeInt32(getPrimaryOutputSamplingRate()); |
| 1358 | return NO_ERROR; |
| 1359 | } break; |
| 1360 | case GET_PRIMARY_OUTPUT_FRAME_COUNT: { |
| 1361 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1362 | reply->writeInt64(getPrimaryOutputFrameCount()); |
Glenn Kasten | cc0f1cf | 2012-09-24 11:27:18 -0700 | [diff] [blame] | 1363 | return NO_ERROR; |
| 1364 | } break; |
Glenn Kasten | 4182c4e | 2013-07-15 14:45:07 -0700 | [diff] [blame] | 1365 | case SET_LOW_RAM_DEVICE: { |
| 1366 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1367 | bool isLowRamDevice = data.readInt32() != 0; |
| 1368 | reply->writeInt32(setLowRamDevice(isLowRamDevice)); |
| 1369 | return NO_ERROR; |
| 1370 | } break; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1371 | case LIST_AUDIO_PORTS: { |
| 1372 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1373 | unsigned int numPortsReq = data.readInt32(); |
| 1374 | if (numPortsReq > MAX_ITEMS_PER_LIST) { |
| 1375 | numPortsReq = MAX_ITEMS_PER_LIST; |
| 1376 | } |
| 1377 | unsigned int numPorts = numPortsReq; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1378 | struct audio_port *ports = |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1379 | (struct audio_port *)calloc(numPortsReq, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1380 | sizeof(struct audio_port)); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1381 | if (ports == NULL) { |
| 1382 | reply->writeInt32(NO_MEMORY); |
| 1383 | reply->writeInt32(0); |
| 1384 | return NO_ERROR; |
| 1385 | } |
| 1386 | status_t status = listAudioPorts(&numPorts, ports); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1387 | reply->writeInt32(status); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1388 | reply->writeInt32(numPorts); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1389 | if (status == NO_ERROR) { |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1390 | if (numPortsReq > numPorts) { |
| 1391 | numPortsReq = numPorts; |
| 1392 | } |
| 1393 | reply->write(ports, numPortsReq * sizeof(struct audio_port)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1394 | } |
| 1395 | free(ports); |
| 1396 | return NO_ERROR; |
| 1397 | } break; |
| 1398 | case GET_AUDIO_PORT: { |
| 1399 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1400 | struct audio_port port = {}; |
| 1401 | if (data.read(&port, sizeof(struct audio_port)) != NO_ERROR) { |
| 1402 | ALOGE("b/23905951"); |
| 1403 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1404 | status_t status = getAudioPort(&port); |
| 1405 | reply->writeInt32(status); |
| 1406 | if (status == NO_ERROR) { |
| 1407 | reply->write(&port, sizeof(struct audio_port)); |
| 1408 | } |
| 1409 | return NO_ERROR; |
| 1410 | } break; |
| 1411 | case CREATE_AUDIO_PATCH: { |
| 1412 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1413 | struct audio_patch patch; |
| 1414 | data.read(&patch, sizeof(struct audio_patch)); |
Glenn Kasten | a13cde9 | 2016-03-28 15:26:02 -0700 | [diff] [blame] | 1415 | audio_patch_handle_t handle = AUDIO_PATCH_HANDLE_NONE; |
Wei Jia | e995e47 | 2015-09-09 09:48:34 -0700 | [diff] [blame] | 1416 | if (data.read(&handle, sizeof(audio_patch_handle_t)) != NO_ERROR) { |
| 1417 | ALOGE("b/23905951"); |
| 1418 | } |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1419 | status_t status = createAudioPatch(&patch, &handle); |
| 1420 | reply->writeInt32(status); |
| 1421 | if (status == NO_ERROR) { |
| 1422 | reply->write(&handle, sizeof(audio_patch_handle_t)); |
| 1423 | } |
| 1424 | return NO_ERROR; |
| 1425 | } break; |
| 1426 | case RELEASE_AUDIO_PATCH: { |
| 1427 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1428 | audio_patch_handle_t handle; |
| 1429 | data.read(&handle, sizeof(audio_patch_handle_t)); |
| 1430 | status_t status = releaseAudioPatch(handle); |
| 1431 | reply->writeInt32(status); |
| 1432 | return NO_ERROR; |
| 1433 | } break; |
| 1434 | case LIST_AUDIO_PATCHES: { |
| 1435 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1436 | unsigned int numPatchesReq = data.readInt32(); |
| 1437 | if (numPatchesReq > MAX_ITEMS_PER_LIST) { |
| 1438 | numPatchesReq = MAX_ITEMS_PER_LIST; |
| 1439 | } |
| 1440 | unsigned int numPatches = numPatchesReq; |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1441 | struct audio_patch *patches = |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1442 | (struct audio_patch *)calloc(numPatchesReq, |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1443 | sizeof(struct audio_patch)); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1444 | if (patches == NULL) { |
| 1445 | reply->writeInt32(NO_MEMORY); |
| 1446 | reply->writeInt32(0); |
| 1447 | return NO_ERROR; |
| 1448 | } |
| 1449 | status_t status = listAudioPatches(&numPatches, patches); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1450 | reply->writeInt32(status); |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1451 | reply->writeInt32(numPatches); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1452 | if (status == NO_ERROR) { |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 1453 | if (numPatchesReq > numPatches) { |
| 1454 | numPatchesReq = numPatches; |
| 1455 | } |
| 1456 | reply->write(patches, numPatchesReq * sizeof(struct audio_patch)); |
Eric Laurent | 4b12340 | 2014-04-11 09:22:20 -0700 | [diff] [blame] | 1457 | } |
| 1458 | free(patches); |
| 1459 | return NO_ERROR; |
| 1460 | } break; |
| 1461 | case SET_AUDIO_PORT_CONFIG: { |
| 1462 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1463 | struct audio_port_config config; |
| 1464 | data.read(&config, sizeof(struct audio_port_config)); |
| 1465 | status_t status = setAudioPortConfig(&config); |
| 1466 | reply->writeInt32(status); |
| 1467 | return NO_ERROR; |
| 1468 | } break; |
Glenn Kasten | 9eae036 | 2016-04-19 09:09:14 -0700 | [diff] [blame^] | 1469 | case GET_AUDIO_HW_SYNC_FOR_SESSION: { |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 1470 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 1471 | reply->writeInt32(getAudioHwSyncForSession((audio_session_t) data.readInt32())); |
Eric Laurent | 93c3d41 | 2014-08-01 14:48:35 -0700 | [diff] [blame] | 1472 | return NO_ERROR; |
| 1473 | } break; |
Eric Laurent | 72e3f39 | 2015-05-20 14:43:50 -0700 | [diff] [blame] | 1474 | case SYSTEM_READY: { |
| 1475 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1476 | systemReady(); |
| 1477 | return NO_ERROR; |
| 1478 | } break; |
Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 1479 | case FRAME_COUNT_HAL: { |
| 1480 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 1481 | reply->writeInt64( frameCountHAL((audio_io_handle_t) data.readInt32()) ); |
| 1482 | return NO_ERROR; |
| 1483 | } break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1484 | default: |
| 1485 | return BBinder::onTransact(code, data, reply, flags); |
| 1486 | } |
| 1487 | } |
| 1488 | |
| 1489 | // ---------------------------------------------------------------------------- |
| 1490 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1491 | } // namespace android |