blob: b8a04291be70358e7bdb45b52266d57ea52d3eac [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
Phil Burk7f6b40d2017-02-09 13:18:38 -080017#define LOG_TAG "AAudio"
18//#define LOG_NDEBUG 0
19#include <utils/Log.h>
20
Phil Burk204a1632017-01-03 17:23:43 -080021#include <stdint.h>
22
23#include <sys/mman.h>
24#include <binder/Parcel.h>
25#include <binder/Parcelable.h>
26
Phil Burk5ed503c2017-02-01 09:38:15 -080027#include <aaudio/AAudioDefinitions.h>
Phil Burk204a1632017-01-03 17:23:43 -080028
Phil Burk5ed503c2017-02-01 09:38:15 -080029#include "binding/AAudioStreamConfiguration.h"
30#include "binding/AAudioStreamRequest.h"
Phil Burk204a1632017-01-03 17:23:43 -080031
32using android::NO_ERROR;
33using android::status_t;
34using android::Parcel;
35using android::Parcelable;
36
Phil Burk5ed503c2017-02-01 09:38:15 -080037using namespace aaudio;
Phil Burk204a1632017-01-03 17:23:43 -080038
Phil Burk5ed503c2017-02-01 09:38:15 -080039AAudioStreamRequest::AAudioStreamRequest()
Phil Burk204a1632017-01-03 17:23:43 -080040 : mConfiguration()
41 {}
42
Phil Burk5ed503c2017-02-01 09:38:15 -080043AAudioStreamRequest::~AAudioStreamRequest() {}
Phil Burk204a1632017-01-03 17:23:43 -080044
Phil Burk5ed503c2017-02-01 09:38:15 -080045status_t AAudioStreamRequest::writeToParcel(Parcel* parcel) const {
Phil Burk7f6b40d2017-02-09 13:18:38 -080046 status_t status = parcel->writeInt32((int32_t) mUserId);
47 if (status != NO_ERROR) goto error;
48 status = parcel->writeInt32((int32_t) mProcessId);
49 if (status != NO_ERROR) goto error;
50 status = parcel->writeInt32((int32_t) mDirection);
51 if (status != NO_ERROR) goto error;
52 status = mConfiguration.writeToParcel(parcel);
53 if (status != NO_ERROR) goto error;
54 return NO_ERROR;
55
56error:
57 ALOGE("AAudioStreamRequest.writeToParcel(): write failed = %d", status);
58 return status;
Phil Burk204a1632017-01-03 17:23:43 -080059}
60
Phil Burk5ed503c2017-02-01 09:38:15 -080061status_t AAudioStreamRequest::readFromParcel(const Parcel* parcel) {
Phil Burk204a1632017-01-03 17:23:43 -080062 int32_t temp;
Phil Burk7f6b40d2017-02-09 13:18:38 -080063 status_t status = parcel->readInt32(&temp);
64 if (status != NO_ERROR) goto error;
Phil Burk204a1632017-01-03 17:23:43 -080065 mUserId = (uid_t) temp;
Phil Burk7f6b40d2017-02-09 13:18:38 -080066 status = parcel->readInt32(&temp);
67 if (status != NO_ERROR) goto error;
Phil Burk204a1632017-01-03 17:23:43 -080068 mProcessId = (pid_t) temp;
Phil Burk7f6b40d2017-02-09 13:18:38 -080069 status = parcel->readInt32(&temp);
70 if (status != NO_ERROR) goto error;
71 mDirection = (aaudio_direction_t) temp;
72 status = mConfiguration.readFromParcel(parcel);
73 if (status != NO_ERROR) goto error;
74 return NO_ERROR;
75
76error:
77 ALOGE("AAudioStreamRequest.readFromParcel(): read failed = %d", status);
78 return status;
Phil Burk204a1632017-01-03 17:23:43 -080079}
80
Phil Burk7f6b40d2017-02-09 13:18:38 -080081aaudio_result_t AAudioStreamRequest::validate() const {
Phil Burk204a1632017-01-03 17:23:43 -080082 return mConfiguration.validate();
83}
84
Phil Burk7f6b40d2017-02-09 13:18:38 -080085void AAudioStreamRequest::dump() const {
86 ALOGD("AAudioStreamRequest mUserId = %d", mUserId);
Phil Burk5ed503c2017-02-01 09:38:15 -080087 ALOGD("AAudioStreamRequest mProcessId = %d", mProcessId);
Phil Burk7f6b40d2017-02-09 13:18:38 -080088 ALOGD("AAudioStreamRequest mDirection = %d", mDirection);
Phil Burk204a1632017-01-03 17:23:43 -080089 mConfiguration.dump();
90}