AAudioStreamRequest.cpp revision 204a163c86f357a878873fe7d4c4164f3d55c9b6
1204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk/*
2204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * Copyright 2016 The Android Open Source Project
3204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *
4204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * Licensed under the Apache License, Version 2.0 (the "License");
5204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * you may not use this file except in compliance with the License.
6204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * You may obtain a copy of the License at
7204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *
8204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *      http://www.apache.org/licenses/LICENSE-2.0
9204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *
10204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * Unless required by applicable law or agreed to in writing, software
11204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * distributed under the License is distributed on an "AS IS" BASIS,
12204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * See the License for the specific language governing permissions and
14204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * limitations under the License.
15204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk */
16204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
17204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <stdint.h>
18204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
19204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <sys/mman.h>
20204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <binder/Parcel.h>
21204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <binder/Parcelable.h>
22204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
23204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <oboe/OboeDefinitions.h>
24204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
25204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include "binding/OboeStreamConfiguration.h"
26204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include "binding/OboeStreamRequest.h"
27204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
28204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkusing android::NO_ERROR;
29204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkusing android::status_t;
30204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkusing android::Parcel;
31204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkusing android::Parcelable;
32204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
33204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkusing namespace oboe;
34204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
35204a163c86f357a878873fe7d4c4164f3d55c9b6Phil BurkOboeStreamRequest::OboeStreamRequest()
36204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    : mConfiguration()
37204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    {}
38204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
39204a163c86f357a878873fe7d4c4164f3d55c9b6Phil BurkOboeStreamRequest::~OboeStreamRequest() {}
40204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
41204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkstatus_t OboeStreamRequest::writeToParcel(Parcel* parcel) const {
42204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    parcel->writeInt32((int32_t) mUserId);
43204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    parcel->writeInt32((int32_t) mProcessId);
44204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    mConfiguration.writeToParcel(parcel);
45204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    return NO_ERROR; // TODO check for errors above
46204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk}
47204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
48204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkstatus_t OboeStreamRequest::readFromParcel(const Parcel* parcel) {
49204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    int32_t temp;
50204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    parcel->readInt32(&temp);
51204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    mUserId = (uid_t) temp;
52204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    parcel->readInt32(&temp);
53204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    mProcessId = (pid_t) temp;
54204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    mConfiguration.readFromParcel(parcel);
55204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    return NO_ERROR; // TODO check for errors above
56204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk}
57204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
58204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkoboe_result_t OboeStreamRequest::validate() {
59204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    return mConfiguration.validate();
60204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk}
61204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
62204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkvoid OboeStreamRequest::dump() {
63204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    ALOGD("OboeStreamRequest mUserId = %d -----", mUserId);
64204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    ALOGD("OboeStreamRequest mProcessId = %d", mProcessId);
65204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    mConfiguration.dump();
66204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk}
67