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 | |
| 17 | #include <stdint.h> |
| 18 | |
| 19 | #include <sys/mman.h> |
| 20 | #include <binder/Parcel.h> |
| 21 | #include <binder/Parcelable.h> |
| 22 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 23 | #include <aaudio/AAudioDefinitions.h> |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 24 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 25 | #include "binding/AAudioStreamConfiguration.h" |
| 26 | #include "binding/AAudioStreamRequest.h" |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 27 | |
| 28 | using android::NO_ERROR; |
| 29 | using android::status_t; |
| 30 | using android::Parcel; |
| 31 | using android::Parcelable; |
| 32 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 33 | using namespace aaudio; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 34 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 35 | AAudioStreamRequest::AAudioStreamRequest() |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 36 | : mConfiguration() |
| 37 | {} |
| 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 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 41 | status_t AAudioStreamRequest::writeToParcel(Parcel* parcel) const { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 42 | parcel->writeInt32((int32_t) mUserId); |
| 43 | parcel->writeInt32((int32_t) mProcessId); |
| 44 | mConfiguration.writeToParcel(parcel); |
| 45 | return NO_ERROR; // TODO check for errors above |
| 46 | } |
| 47 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 48 | status_t AAudioStreamRequest::readFromParcel(const Parcel* parcel) { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 49 | int32_t temp; |
| 50 | parcel->readInt32(&temp); |
| 51 | mUserId = (uid_t) temp; |
| 52 | parcel->readInt32(&temp); |
| 53 | mProcessId = (pid_t) temp; |
| 54 | mConfiguration.readFromParcel(parcel); |
| 55 | return NO_ERROR; // TODO check for errors above |
| 56 | } |
| 57 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 58 | aaudio_result_t AAudioStreamRequest::validate() { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 59 | return mConfiguration.validate(); |
| 60 | } |
| 61 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 62 | void AAudioStreamRequest::dump() { |
| 63 | ALOGD("AAudioStreamRequest mUserId = %d -----", mUserId); |
| 64 | ALOGD("AAudioStreamRequest mProcessId = %d", mProcessId); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 65 | mConfiguration.dump(); |
| 66 | } |