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_CONFIGURATION_H
185204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#define ANDROID_BINDING_AAUDIO_STREAM_CONFIGURATION_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
26828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::status_t;
27828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::Parcel;
28828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::Parcelable;
29828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
305ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burknamespace aaudio {
31828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
325ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkclass AAudioStreamConfiguration : public Parcelable {
33828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkpublic:
345ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAudioStreamConfiguration();
355ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    virtual ~AAudioStreamConfiguration();
36828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
373316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int32_t getDeviceId() const {
38828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        return mDeviceId;
39828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
40828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
413316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    void setDeviceId(int32_t deviceId) {
42828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        mDeviceId = deviceId;
43828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
44828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
453316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int32_t getSampleRate() const {
46828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        return mSampleRate;
47828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
48828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
493316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    void setSampleRate(int32_t sampleRate) {
50828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        mSampleRate = sampleRate;
51828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
52828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
53828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t getSamplesPerFrame() const {
54828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        return mSamplesPerFrame;
55828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
56828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
57828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    void setSamplesPerFrame(int32_t samplesPerFrame) {
58828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        mSamplesPerFrame = samplesPerFrame;
59828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
60828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
619dca9824da74d50be02bc81f539cc77b7bde678aPhil Burk    aaudio_format_t getAudioFormat() const {
62828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        return mAudioFormat;
63828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
64828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
659dca9824da74d50be02bc81f539cc77b7bde678aPhil Burk    void setAudioFormat(aaudio_format_t audioFormat) {
66828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk        mAudioFormat = audioFormat;
67828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    }
68828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
69c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    aaudio_sharing_mode_t getSharingMode() const {
70c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk        return mSharingMode;
71c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    }
72c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
73c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    void setSharingMode(aaudio_sharing_mode_t sharingMode) {
74c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk        mSharingMode = sharingMode;
75c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    }
76c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
773316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int32_t getBufferCapacity() const {
783df348fbaca567ca891503213ff8c344a1ea2e05Phil Burk        return mBufferCapacity;
793df348fbaca567ca891503213ff8c344a1ea2e05Phil Burk    }
803df348fbaca567ca891503213ff8c344a1ea2e05Phil Burk
813316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    void setBufferCapacity(int32_t frames) {
823df348fbaca567ca891503213ff8c344a1ea2e05Phil Burk        mBufferCapacity = frames;
833df348fbaca567ca891503213ff8c344a1ea2e05Phil Burk    }
843df348fbaca567ca891503213ff8c344a1ea2e05Phil Burk
85828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    virtual status_t writeToParcel(Parcel* parcel) const override;
86828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
87828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    virtual status_t readFromParcel(const Parcel* parcel) override;
88828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
89c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    aaudio_result_t validate() const;
90828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
91c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    void dump() const;
92828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
93c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burkprivate:
945f510d2e1d9976f45d1d1733f20ec32e56bd2239Glenn Kasten    int32_t               mDeviceId        = AAUDIO_UNSPECIFIED;
953316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int32_t               mSampleRate      = AAUDIO_UNSPECIFIED;
963df348fbaca567ca891503213ff8c344a1ea2e05Phil Burk    int32_t               mSamplesPerFrame = AAUDIO_UNSPECIFIED;
97c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    aaudio_sharing_mode_t mSharingMode     = AAUDIO_SHARING_MODE_SHARED;
989dca9824da74d50be02bc81f539cc77b7bde678aPhil Burk    aaudio_format_t       mAudioFormat     = AAUDIO_FORMAT_UNSPECIFIED;
993316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int32_t               mBufferCapacity  = AAUDIO_UNSPECIFIED;
100828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk};
101828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
1025ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} /* namespace aaudio */
103828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
1045204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#endif //ANDROID_BINDING_AAUDIO_STREAM_CONFIGURATION_H
105