1828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk/*
2828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Copyright 2016 The Android Open Source Project
3828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
4828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Licensed under the Apache License, Version 2.0 (the "License");
5828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * you may not use this file except in compliance with the License.
6828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * You may obtain a copy of the License at
7828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
8828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *      http://www.apache.org/licenses/LICENSE-2.0
9828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
10828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Unless required by applicable law or agreed to in writing, software
11828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * distributed under the License is distributed on an "AS IS" BASIS,
12828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * See the License for the specific language governing permissions and
14828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * limitations under the License.
15828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk */
16828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
175204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#ifndef ANDROID_BINDING_AAUDIO_STREAM_REQUEST_H
185204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#define ANDROID_BINDING_AAUDIO_STREAM_REQUEST_H
19828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
20828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <stdint.h>
21828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
22a4eb0d86a29be2763be5fac51727858d5095794bPhil Burk#include <aaudio/AAudio.h>
23828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <binder/Parcel.h>
24828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <binder/Parcelable.h>
25828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
265ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#include "binding/AAudioStreamConfiguration.h"
27828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
28828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::status_t;
29828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::Parcel;
30828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::Parcelable;
31828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
325ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burknamespace aaudio {
33828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
345ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkclass AAudioStreamRequest : public Parcelable {
35828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkpublic:
365ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAudioStreamRequest();
375ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    virtual ~AAudioStreamRequest();
38828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
39828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    uid_t getUserId() const {
40828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        return mUserId;
41828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
42828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
43828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    void setUserId(uid_t userId) {
44828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        mUserId = userId;
45828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
46828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
47828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    pid_t getProcessId() const {
48828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        return mProcessId;
49828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
50828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
51828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    void setProcessId(pid_t processId) {
52828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        mProcessId = processId;
53828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
54828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
55c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    aaudio_direction_t getDirection() const {
56c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk        return mDirection;
57c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    }
58c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
59c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    void setDirection(aaudio_direction_t direction) {
60c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk        mDirection = direction;
61c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    }
62c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
6371f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    bool isSharingModeMatchRequired() const {
6471f35bb687476694882a617ba4a810a0bb56fe23Phil Burk        return mSharingModeMatchRequired;
6571f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    }
6671f35bb687476694882a617ba4a810a0bb56fe23Phil Burk
6771f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    void setSharingModeMatchRequired(bool required) {
6871f35bb687476694882a617ba4a810a0bb56fe23Phil Burk        mSharingModeMatchRequired = required;
6971f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    }
7071f35bb687476694882a617ba4a810a0bb56fe23Phil Burk
7171f35bb687476694882a617ba4a810a0bb56fe23Phil Burk
72c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    const AAudioStreamConfiguration &getConstantConfiguration() const {
73c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk        return mConfiguration;
74c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    }
75c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
765ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAudioStreamConfiguration &getConfiguration() {
77828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        return mConfiguration;
78828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
79828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
80828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    virtual status_t writeToParcel(Parcel* parcel) const override;
81828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
82828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    virtual status_t readFromParcel(const Parcel* parcel) override;
83828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
84c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    aaudio_result_t validate() const;
85828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
86c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    void dump() const;
87828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
88828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkprotected:
895ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAudioStreamConfiguration  mConfiguration;
90c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    uid_t                      mUserId;
91c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    pid_t                      mProcessId;
92c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    aaudio_direction_t         mDirection;
9371f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    bool                       mSharingModeMatchRequired = false;
94828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk};
95828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
965ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} /* namespace aaudio */
97828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
985204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#endif //ANDROID_BINDING_AAUDIO_STREAM_REQUEST_H
99