Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 17 | #define LOG_TAG "AAudio" |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | #include <utils/Log.h> |
| 20 | |
Phil Burk | a4eb0d8 | 2017-04-12 15:44:06 -0700 | [diff] [blame] | 21 | #include <aaudio/AAudio.h> |
Phil Burk | 2ac035f | 2017-06-23 14:51:14 -0700 | [diff] [blame] | 22 | #include <binder/IPCThreadState.h> |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 23 | |
| 24 | #include "binding/AudioEndpointParcelable.h" |
| 25 | #include "binding/AAudioStreamRequest.h" |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 26 | #include "binding/AAudioServiceDefinitions.h" |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 27 | #include "binding/AAudioStreamConfiguration.h" |
| 28 | #include "binding/IAAudioService.h" |
| 29 | #include "utility/AAudioUtilities.h" |
| 30 | |
| 31 | namespace android { |
| 32 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 33 | using aaudio::aaudio_handle_t; |
| 34 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 35 | /** |
| 36 | * This is used by the AAudio Client to talk to the AAudio Service. |
| 37 | * |
| 38 | * The order of parameters in the Parcels must match with code in AAudioService.cpp. |
| 39 | */ |
| 40 | class BpAAudioService : public BpInterface<IAAudioService> |
| 41 | { |
| 42 | public: |
| 43 | explicit BpAAudioService(const sp<IBinder>& impl) |
| 44 | : BpInterface<IAAudioService>(impl) |
| 45 | { |
| 46 | } |
| 47 | |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 48 | void registerClient(const sp<IAAudioClient>& client) override |
| 49 | { |
| 50 | Parcel data, reply; |
| 51 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 52 | data.writeStrongBinder(IInterface::asBinder(client)); |
| 53 | remote()->transact(REGISTER_CLIENT, data, &reply); |
| 54 | } |
| 55 | |
| 56 | aaudio_handle_t openStream(const aaudio::AAudioStreamRequest &request, |
| 57 | aaudio::AAudioStreamConfiguration &configurationOutput) override { |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 58 | Parcel data, reply; |
| 59 | // send command |
| 60 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 61 | // request.dump(); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 62 | request.writeToParcel(&data); |
| 63 | status_t err = remote()->transact(OPEN_STREAM, data, &reply); |
| 64 | if (err != NO_ERROR) { |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 65 | ALOGE("BpAAudioService::client openStream transact failed %d", err); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 66 | return AAudioConvert_androidToAAudioResult(err); |
| 67 | } |
| 68 | // parse reply |
| 69 | aaudio_handle_t stream; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 70 | err = reply.readInt32(&stream); |
| 71 | if (err != NO_ERROR) { |
| 72 | ALOGE("BpAAudioService::client transact(OPEN_STREAM) readInt %d", err); |
| 73 | return AAudioConvert_androidToAAudioResult(err); |
| 74 | } else if (stream < 0) { |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 75 | return stream; |
| 76 | } |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 77 | err = configurationOutput.readFromParcel(&reply); |
| 78 | if (err != NO_ERROR) { |
| 79 | ALOGE("BpAAudioService::client openStream readFromParcel failed %d", err); |
| 80 | closeStream(stream); |
| 81 | return AAudioConvert_androidToAAudioResult(err); |
| 82 | } |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 83 | return stream; |
| 84 | } |
| 85 | |
| 86 | virtual aaudio_result_t closeStream(aaudio_handle_t streamHandle) override { |
| 87 | Parcel data, reply; |
| 88 | // send command |
| 89 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 90 | data.writeInt32(streamHandle); |
| 91 | status_t err = remote()->transact(CLOSE_STREAM, data, &reply); |
| 92 | if (err != NO_ERROR) { |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 93 | ALOGE("BpAAudioService::client closeStream transact failed %d", err); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 94 | return AAudioConvert_androidToAAudioResult(err); |
| 95 | } |
| 96 | // parse reply |
| 97 | aaudio_result_t res; |
| 98 | reply.readInt32(&res); |
| 99 | return res; |
| 100 | } |
| 101 | |
| 102 | virtual aaudio_result_t getStreamDescription(aaudio_handle_t streamHandle, |
| 103 | aaudio::AudioEndpointParcelable &parcelable) { |
| 104 | Parcel data, reply; |
| 105 | // send command |
| 106 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 107 | data.writeInt32(streamHandle); |
| 108 | status_t err = remote()->transact(GET_STREAM_DESCRIPTION, data, &reply); |
| 109 | if (err != NO_ERROR) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 110 | ALOGE("BpAAudioService::client transact(GET_STREAM_DESCRIPTION) returns %d", err); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 111 | return AAudioConvert_androidToAAudioResult(err); |
| 112 | } |
| 113 | // parse reply |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 114 | aaudio_result_t result; |
| 115 | err = reply.readInt32(&result); |
| 116 | if (err != NO_ERROR) { |
| 117 | ALOGE("BpAAudioService::client transact(GET_STREAM_DESCRIPTION) readInt %d", err); |
| 118 | return AAudioConvert_androidToAAudioResult(err); |
| 119 | } else if (result != AAUDIO_OK) { |
| 120 | ALOGE("BpAAudioService::client GET_STREAM_DESCRIPTION passed result %d", result); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 121 | return result; |
| 122 | } |
Phil Burk | a5891f4 | 2018-03-12 17:21:11 -0700 | [diff] [blame] | 123 | err = parcelable.readFromParcel(&reply); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 124 | if (err != NO_ERROR) { |
| 125 | ALOGE("BpAAudioService::client transact(GET_STREAM_DESCRIPTION) read endpoint %d", err); |
| 126 | return AAudioConvert_androidToAAudioResult(err); |
| 127 | } |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 128 | return result; |
| 129 | } |
| 130 | |
| 131 | // TODO should we wait for a reply? |
| 132 | virtual aaudio_result_t startStream(aaudio_handle_t streamHandle) override { |
| 133 | Parcel data, reply; |
| 134 | // send command |
| 135 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 136 | data.writeInt32(streamHandle); |
| 137 | status_t err = remote()->transact(START_STREAM, data, &reply); |
| 138 | if (err != NO_ERROR) { |
| 139 | return AAudioConvert_androidToAAudioResult(err); |
| 140 | } |
| 141 | // parse reply |
| 142 | aaudio_result_t res; |
| 143 | reply.readInt32(&res); |
| 144 | return res; |
| 145 | } |
| 146 | |
| 147 | virtual aaudio_result_t pauseStream(aaudio_handle_t streamHandle) override { |
| 148 | Parcel data, reply; |
| 149 | // send command |
| 150 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 151 | data.writeInt32(streamHandle); |
| 152 | status_t err = remote()->transact(PAUSE_STREAM, data, &reply); |
| 153 | if (err != NO_ERROR) { |
| 154 | return AAudioConvert_androidToAAudioResult(err); |
| 155 | } |
| 156 | // parse reply |
| 157 | aaudio_result_t res; |
| 158 | reply.readInt32(&res); |
| 159 | return res; |
| 160 | } |
| 161 | |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 162 | virtual aaudio_result_t stopStream(aaudio_handle_t streamHandle) override { |
| 163 | Parcel data, reply; |
| 164 | // send command |
| 165 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 166 | data.writeInt32(streamHandle); |
| 167 | status_t err = remote()->transact(STOP_STREAM, data, &reply); |
| 168 | if (err != NO_ERROR) { |
| 169 | return AAudioConvert_androidToAAudioResult(err); |
| 170 | } |
| 171 | // parse reply |
| 172 | aaudio_result_t res; |
| 173 | reply.readInt32(&res); |
| 174 | return res; |
| 175 | } |
| 176 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 177 | virtual aaudio_result_t flushStream(aaudio_handle_t streamHandle) override { |
| 178 | Parcel data, reply; |
| 179 | // send command |
| 180 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 181 | data.writeInt32(streamHandle); |
| 182 | status_t err = remote()->transact(FLUSH_STREAM, data, &reply); |
| 183 | if (err != NO_ERROR) { |
| 184 | return AAudioConvert_androidToAAudioResult(err); |
| 185 | } |
| 186 | // parse reply |
| 187 | aaudio_result_t res; |
| 188 | reply.readInt32(&res); |
| 189 | return res; |
| 190 | } |
| 191 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 192 | virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle, |
Phil Burk | 2ac035f | 2017-06-23 14:51:14 -0700 | [diff] [blame] | 193 | pid_t clientThreadId, |
| 194 | int64_t periodNanoseconds) |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 195 | override { |
| 196 | Parcel data, reply; |
| 197 | // send command |
| 198 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 199 | data.writeInt32(streamHandle); |
| 200 | data.writeInt32((int32_t) clientThreadId); |
| 201 | data.writeInt64(periodNanoseconds); |
| 202 | status_t err = remote()->transact(REGISTER_AUDIO_THREAD, data, &reply); |
| 203 | if (err != NO_ERROR) { |
| 204 | return AAudioConvert_androidToAAudioResult(err); |
| 205 | } |
| 206 | // parse reply |
| 207 | aaudio_result_t res; |
| 208 | reply.readInt32(&res); |
| 209 | return res; |
| 210 | } |
| 211 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 212 | virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle, |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 213 | pid_t clientThreadId) |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 214 | override { |
| 215 | Parcel data, reply; |
| 216 | // send command |
| 217 | data.writeInterfaceToken(IAAudioService::getInterfaceDescriptor()); |
| 218 | data.writeInt32(streamHandle); |
| 219 | data.writeInt32((int32_t) clientThreadId); |
| 220 | status_t err = remote()->transact(UNREGISTER_AUDIO_THREAD, data, &reply); |
| 221 | if (err != NO_ERROR) { |
| 222 | return AAudioConvert_androidToAAudioResult(err); |
| 223 | } |
| 224 | // parse reply |
| 225 | aaudio_result_t res; |
| 226 | reply.readInt32(&res); |
| 227 | return res; |
| 228 | } |
| 229 | |
| 230 | }; |
| 231 | |
| 232 | // Implement an interface to the service. |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 233 | // This is here so that you don't have to link with libaaudio static library. |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 234 | IMPLEMENT_META_INTERFACE(AAudioService, "IAAudioService"); |
| 235 | |
| 236 | // The order of parameters in the Parcels must match with code in BpAAudioService |
| 237 | |
| 238 | status_t BnAAudioService::onTransact(uint32_t code, const Parcel& data, |
| 239 | Parcel* reply, uint32_t flags) { |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 240 | aaudio_handle_t streamHandle; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 241 | aaudio::AAudioStreamRequest request; |
| 242 | aaudio::AAudioStreamConfiguration configuration; |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 243 | pid_t tid; |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 244 | int64_t nanoseconds; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 245 | aaudio_result_t result; |
Phil Burk | a5891f4 | 2018-03-12 17:21:11 -0700 | [diff] [blame] | 246 | status_t status = NO_ERROR; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 247 | ALOGV("BnAAudioService::onTransact(%i) %i", code, flags); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 248 | |
| 249 | switch(code) { |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 250 | case REGISTER_CLIENT: { |
| 251 | CHECK_INTERFACE(IAAudioService, data, reply); |
| 252 | sp<IAAudioClient> client = interface_cast<IAAudioClient>( |
| 253 | data.readStrongBinder()); |
Phil Burk | ef7eaaf | 2019-05-01 11:26:35 -0700 | [diff] [blame] | 254 | // readStrongBinder() can return null |
| 255 | if (client.get() == nullptr) { |
| 256 | ALOGE("BnAAudioService::%s(REGISTER_CLIENT) client is NULL!", __func__); |
| 257 | android_errorWriteLog(0x534e4554, "116230453"); |
| 258 | return DEAD_OBJECT; |
| 259 | } else { |
| 260 | registerClient(client); |
| 261 | return NO_ERROR; |
| 262 | } |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 263 | } break; |
| 264 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 265 | case OPEN_STREAM: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 266 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 267 | request.readFromParcel(&data); |
jiabin | 901f65d | 2017-07-12 17:56:35 -0700 | [diff] [blame] | 268 | result = request.validate(); |
| 269 | if (result != AAUDIO_OK) { |
| 270 | streamHandle = result; |
| 271 | } else { |
| 272 | //ALOGD("BnAAudioService::client openStream request dump --------------------"); |
| 273 | //request.dump(); |
| 274 | // Override the uid and pid from the client in case they are incorrect. |
| 275 | request.setUserId(IPCThreadState::self()->getCallingUid()); |
| 276 | request.setProcessId(IPCThreadState::self()->getCallingPid()); |
| 277 | streamHandle = openStream(request, configuration); |
| 278 | //ALOGD("BnAAudioService::onTransact OPEN_STREAM server handle = 0x%08X", |
| 279 | // streamHandle); |
| 280 | } |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 281 | reply->writeInt32(streamHandle); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 282 | configuration.writeToParcel(reply); |
| 283 | return NO_ERROR; |
| 284 | } break; |
| 285 | |
| 286 | case CLOSE_STREAM: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 287 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 288 | data.readInt32(&streamHandle); |
| 289 | result = closeStream(streamHandle); |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 290 | //ALOGD("BnAAudioService::onTransact CLOSE_STREAM 0x%08X, result = %d", |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 291 | // streamHandle, result); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 292 | reply->writeInt32(result); |
| 293 | return NO_ERROR; |
| 294 | } break; |
| 295 | |
| 296 | case GET_STREAM_DESCRIPTION: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 297 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | a5891f4 | 2018-03-12 17:21:11 -0700 | [diff] [blame] | 298 | status = data.readInt32(&streamHandle); |
| 299 | if (status != NO_ERROR) { |
| 300 | return status; |
| 301 | } |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 302 | aaudio::AudioEndpointParcelable parcelable; |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 303 | result = getStreamDescription(streamHandle, parcelable); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 304 | if (result != AAUDIO_OK) { |
| 305 | return AAudioConvert_aaudioToAndroidStatus(result); |
| 306 | } |
Phil Burk | a5891f4 | 2018-03-12 17:21:11 -0700 | [diff] [blame] | 307 | status = reply->writeInt32(result); |
| 308 | if (status != NO_ERROR) { |
| 309 | return status; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 310 | } |
Phil Burk | a5891f4 | 2018-03-12 17:21:11 -0700 | [diff] [blame] | 311 | return parcelable.writeToParcel(reply); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 312 | } break; |
| 313 | |
| 314 | case START_STREAM: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 315 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 316 | data.readInt32(&streamHandle); |
| 317 | result = startStream(streamHandle); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 318 | ALOGV("BnAAudioService::onTransact START_STREAM 0x%08X, result = %d", |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 319 | streamHandle, result); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 320 | reply->writeInt32(result); |
| 321 | return NO_ERROR; |
| 322 | } break; |
| 323 | |
| 324 | case PAUSE_STREAM: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 325 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 326 | data.readInt32(&streamHandle); |
| 327 | result = pauseStream(streamHandle); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 328 | ALOGV("BnAAudioService::onTransact PAUSE_STREAM 0x%08X, result = %d", |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 329 | streamHandle, result); |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 330 | reply->writeInt32(result); |
| 331 | return NO_ERROR; |
| 332 | } break; |
| 333 | |
| 334 | case STOP_STREAM: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 335 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 336 | data.readInt32(&streamHandle); |
| 337 | result = stopStream(streamHandle); |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 338 | ALOGV("BnAAudioService::onTransact STOP_STREAM 0x%08X, result = %d", |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 339 | streamHandle, result); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 340 | reply->writeInt32(result); |
| 341 | return NO_ERROR; |
| 342 | } break; |
| 343 | |
| 344 | case FLUSH_STREAM: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 345 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 346 | data.readInt32(&streamHandle); |
| 347 | result = flushStream(streamHandle); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 348 | ALOGV("BnAAudioService::onTransact FLUSH_STREAM 0x%08X, result = %d", |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 349 | streamHandle, result); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 350 | reply->writeInt32(result); |
| 351 | return NO_ERROR; |
| 352 | } break; |
| 353 | |
| 354 | case REGISTER_AUDIO_THREAD: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 355 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 356 | data.readInt32(&streamHandle); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 357 | data.readInt32(&tid); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 358 | data.readInt64(&nanoseconds); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 359 | result = registerAudioThread(streamHandle, tid, nanoseconds); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 360 | ALOGV("BnAAudioService::onTransact REGISTER_AUDIO_THREAD 0x%08X, result = %d", |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 361 | streamHandle, result); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 362 | reply->writeInt32(result); |
| 363 | return NO_ERROR; |
| 364 | } break; |
| 365 | |
| 366 | case UNREGISTER_AUDIO_THREAD: { |
Andy Hung | a880518 | 2017-06-27 16:17:40 -0700 | [diff] [blame] | 367 | CHECK_INTERFACE(IAAudioService, data, reply); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 368 | data.readInt32(&streamHandle); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 369 | data.readInt32(&tid); |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 370 | result = unregisterAudioThread(streamHandle, tid); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 371 | ALOGV("BnAAudioService::onTransact UNREGISTER_AUDIO_THREAD 0x%08X, result = %d", |
Phil Burk | 11e8d33 | 2017-05-24 09:59:02 -0700 | [diff] [blame] | 372 | streamHandle, result); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 373 | reply->writeInt32(result); |
| 374 | return NO_ERROR; |
| 375 | } break; |
| 376 | |
| 377 | default: |
| 378 | // ALOGW("BnAAudioService::onTransact not handled %u", code); |
| 379 | return BBinder::onTransact(code, data, reply, flags); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | } /* namespace android */ |