blob: c30c5b99d8db39528139878c9f630b1876b64736 [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 Burkfbf031e2017-10-12 15:58:31 -070017#define LOG_TAG "AAudioStreamRequest"
Phil Burkc0c70e32017-02-09 13:18:38 -080018//#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 Burka4eb0d82017-04-12 15:44:06 -070027#include <aaudio/AAudio.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 Burkc0c70e32017-02-09 13:18:38 -080046 status_t status = parcel->writeInt32((int32_t) mUserId);
47 if (status != NO_ERROR) goto error;
Phil Burk2ac035f2017-06-23 14:51:14 -070048
Phil Burk71f35bb2017-04-13 16:05:07 -070049 status = parcel->writeBool(mSharingModeMatchRequired);
50 if (status != NO_ERROR) goto error;
51
Eric Laurenta54f1282017-07-01 19:39:32 -070052 status = parcel->writeBool(mInService);
53 if (status != NO_ERROR) goto error;
54
Phil Burkc0c70e32017-02-09 13:18:38 -080055 status = mConfiguration.writeToParcel(parcel);
56 if (status != NO_ERROR) goto error;
Eric Laurenta54f1282017-07-01 19:39:32 -070057
Phil Burkc0c70e32017-02-09 13:18:38 -080058 return NO_ERROR;
59
60error:
Phil Burkfbf031e2017-10-12 15:58:31 -070061 ALOGE("writeToParcel(): write failed = %d", status);
Phil Burkc0c70e32017-02-09 13:18:38 -080062 return status;
Phil Burk204a1632017-01-03 17:23:43 -080063}
64
Phil Burk5ed503c2017-02-01 09:38:15 -080065status_t AAudioStreamRequest::readFromParcel(const Parcel* parcel) {
Phil Burk204a1632017-01-03 17:23:43 -080066 int32_t temp;
Phil Burkc0c70e32017-02-09 13:18:38 -080067 status_t status = parcel->readInt32(&temp);
68 if (status != NO_ERROR) goto error;
Phil Burk204a1632017-01-03 17:23:43 -080069 mUserId = (uid_t) temp;
Phil Burk71f35bb2017-04-13 16:05:07 -070070
Phil Burk71f35bb2017-04-13 16:05:07 -070071 status = parcel->readBool(&mSharingModeMatchRequired);
72 if (status != NO_ERROR) goto error;
73
Eric Laurenta54f1282017-07-01 19:39:32 -070074 status = parcel->readBool(&mInService);
75 if (status != NO_ERROR) goto error;
76
Phil Burkc0c70e32017-02-09 13:18:38 -080077 status = mConfiguration.readFromParcel(parcel);
78 if (status != NO_ERROR) goto error;
Eric Laurenta54f1282017-07-01 19:39:32 -070079
Phil Burkc0c70e32017-02-09 13:18:38 -080080 return NO_ERROR;
81
82error:
Phil Burkfbf031e2017-10-12 15:58:31 -070083 ALOGE("readFromParcel(): read failed = %d", status);
Phil Burkc0c70e32017-02-09 13:18:38 -080084 return status;
Phil Burk204a1632017-01-03 17:23:43 -080085}
86
Phil Burkc0c70e32017-02-09 13:18:38 -080087aaudio_result_t AAudioStreamRequest::validate() const {
Phil Burk204a1632017-01-03 17:23:43 -080088 return mConfiguration.validate();
89}
90
Phil Burkc0c70e32017-02-09 13:18:38 -080091void AAudioStreamRequest::dump() const {
Phil Burkfbf031e2017-10-12 15:58:31 -070092 ALOGD("mUserId = %d", mUserId);
93 ALOGD("mProcessId = %d", mProcessId);
94 ALOGD("mSharingModeMatchRequired = %d", mSharingModeMatchRequired);
95 ALOGD("mInService = %d", mInService);
Phil Burk204a1632017-01-03 17:23:43 -080096 mConfiguration.dump();
97}