blob: 5202b737cd61e8b1e02cfdb24e680a81933c800b [file] [log] [blame]
Phil Burk204a1632017-01-03 17:23:43 -08001/*
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 Burk5ed503c2017-02-01 09:38:15 -080023#include <aaudio/AAudioDefinitions.h>
Phil Burk204a1632017-01-03 17:23:43 -080024
Phil Burk5ed503c2017-02-01 09:38:15 -080025#include "binding/AAudioStreamConfiguration.h"
26#include "binding/AAudioStreamRequest.h"
Phil Burk204a1632017-01-03 17:23:43 -080027
28using android::NO_ERROR;
29using android::status_t;
30using android::Parcel;
31using android::Parcelable;
32
Phil Burk5ed503c2017-02-01 09:38:15 -080033using namespace aaudio;
Phil Burk204a1632017-01-03 17:23:43 -080034
Phil Burk5ed503c2017-02-01 09:38:15 -080035AAudioStreamRequest::AAudioStreamRequest()
Phil Burk204a1632017-01-03 17:23:43 -080036 : mConfiguration()
37 {}
38
Phil Burk5ed503c2017-02-01 09:38:15 -080039AAudioStreamRequest::~AAudioStreamRequest() {}
Phil Burk204a1632017-01-03 17:23:43 -080040
Phil Burk5ed503c2017-02-01 09:38:15 -080041status_t AAudioStreamRequest::writeToParcel(Parcel* parcel) const {
Phil Burk204a1632017-01-03 17:23:43 -080042 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 Burk5ed503c2017-02-01 09:38:15 -080048status_t AAudioStreamRequest::readFromParcel(const Parcel* parcel) {
Phil Burk204a1632017-01-03 17:23:43 -080049 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 Burk5ed503c2017-02-01 09:38:15 -080058aaudio_result_t AAudioStreamRequest::validate() {
Phil Burk204a1632017-01-03 17:23:43 -080059 return mConfiguration.validate();
60}
61
Phil Burk5ed503c2017-02-01 09:38:15 -080062void AAudioStreamRequest::dump() {
63 ALOGD("AAudioStreamRequest mUserId = %d -----", mUserId);
64 ALOGD("AAudioStreamRequest mProcessId = %d", mProcessId);
Phil Burk204a1632017-01-03 17:23:43 -080065 mConfiguration.dump();
66}