Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 17 | #define LOG_TAG "AAudio" |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | #include <utils/Log.h> |
| 20 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 21 | #include <stdint.h> |
| 22 | |
| 23 | #include <sys/mman.h> |
| 24 | #include <binder/Parcel.h> |
| 25 | #include <binder/Parcelable.h> |
| 26 | |
Phil Burk | a4eb0d8 | 2017-04-12 15:44:06 -0700 | [diff] [blame] | 27 | #include <aaudio/AAudio.h> |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 28 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 29 | #include "binding/AAudioStreamConfiguration.h" |
| 30 | #include "binding/AAudioStreamRequest.h" |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 31 | |
| 32 | using android::NO_ERROR; |
| 33 | using android::status_t; |
| 34 | using android::Parcel; |
| 35 | using android::Parcelable; |
| 36 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 37 | using namespace aaudio; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 38 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 39 | AAudioStreamRequest::AAudioStreamRequest() |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 40 | : mConfiguration() |
| 41 | {} |
| 42 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 43 | AAudioStreamRequest::~AAudioStreamRequest() {} |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 44 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 45 | status_t AAudioStreamRequest::writeToParcel(Parcel* parcel) const { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 46 | status_t status = parcel->writeInt32((int32_t) mUserId); |
| 47 | if (status != NO_ERROR) goto error; |
Phil Burk | 2ac035f | 2017-06-23 14:51:14 -0700 | [diff] [blame] | 48 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 49 | status = parcel->writeInt32((int32_t) mDirection); |
| 50 | if (status != NO_ERROR) goto error; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 51 | |
| 52 | status = parcel->writeBool(mSharingModeMatchRequired); |
| 53 | if (status != NO_ERROR) goto error; |
| 54 | |
Eric Laurent | cb4dae2 | 2017-07-01 19:39:32 -0700 | [diff] [blame^] | 55 | status = parcel->writeBool(mInService); |
| 56 | if (status != NO_ERROR) goto error; |
| 57 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 58 | status = mConfiguration.writeToParcel(parcel); |
| 59 | if (status != NO_ERROR) goto error; |
Eric Laurent | cb4dae2 | 2017-07-01 19:39:32 -0700 | [diff] [blame^] | 60 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 61 | return NO_ERROR; |
| 62 | |
| 63 | error: |
| 64 | ALOGE("AAudioStreamRequest.writeToParcel(): write failed = %d", status); |
| 65 | return status; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 66 | } |
| 67 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 68 | status_t AAudioStreamRequest::readFromParcel(const Parcel* parcel) { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 69 | int32_t temp; |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 70 | status_t status = parcel->readInt32(&temp); |
| 71 | if (status != NO_ERROR) goto error; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 72 | mUserId = (uid_t) temp; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 73 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 74 | status = parcel->readInt32(&temp); |
| 75 | if (status != NO_ERROR) goto error; |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 76 | mDirection = (aaudio_direction_t) temp; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 77 | |
| 78 | status = parcel->readBool(&mSharingModeMatchRequired); |
| 79 | if (status != NO_ERROR) goto error; |
| 80 | |
Eric Laurent | cb4dae2 | 2017-07-01 19:39:32 -0700 | [diff] [blame^] | 81 | status = parcel->readBool(&mInService); |
| 82 | if (status != NO_ERROR) goto error; |
| 83 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 84 | status = mConfiguration.readFromParcel(parcel); |
| 85 | if (status != NO_ERROR) goto error; |
Eric Laurent | cb4dae2 | 2017-07-01 19:39:32 -0700 | [diff] [blame^] | 86 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 87 | return NO_ERROR; |
| 88 | |
| 89 | error: |
| 90 | ALOGE("AAudioStreamRequest.readFromParcel(): read failed = %d", status); |
| 91 | return status; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 94 | aaudio_result_t AAudioStreamRequest::validate() const { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 95 | return mConfiguration.validate(); |
| 96 | } |
| 97 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 98 | void AAudioStreamRequest::dump() const { |
| 99 | ALOGD("AAudioStreamRequest mUserId = %d", mUserId); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 100 | ALOGD("AAudioStreamRequest mProcessId = %d", mProcessId); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 101 | ALOGD("AAudioStreamRequest mDirection = %d", mDirection); |
Eric Laurent | cb4dae2 | 2017-07-01 19:39:32 -0700 | [diff] [blame^] | 102 | ALOGD("AAudioStreamRequest mSharingModeMatchRequired = %d", mSharingModeMatchRequired); |
| 103 | ALOGD("AAudioStreamRequest mInService = %d", mInService); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 104 | mConfiguration.dump(); |
| 105 | } |