• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 #ifndef ANDROID_BINDING_AAUDIO_STREAM_CONFIGURATION_H
18 #define ANDROID_BINDING_AAUDIO_STREAM_CONFIGURATION_H
19 
20 #include <stdint.h>
21 
22 #include <aaudio/AAudio.h>
23 #include <binder/Parcel.h>
24 #include <binder/Parcelable.h>
25 
26 using android::status_t;
27 using android::Parcel;
28 using android::Parcelable;
29 
30 namespace aaudio {
31 
32 class AAudioStreamConfiguration : public Parcelable {
33 public:
34     AAudioStreamConfiguration();
35     virtual ~AAudioStreamConfiguration();
36 
getDeviceId()37     int32_t getDeviceId() const {
38         return mDeviceId;
39     }
40 
setDeviceId(int32_t deviceId)41     void setDeviceId(int32_t deviceId) {
42         mDeviceId = deviceId;
43     }
44 
getSampleRate()45     int32_t getSampleRate() const {
46         return mSampleRate;
47     }
48 
setSampleRate(int32_t sampleRate)49     void setSampleRate(int32_t sampleRate) {
50         mSampleRate = sampleRate;
51     }
52 
getSamplesPerFrame()53     int32_t getSamplesPerFrame() const {
54         return mSamplesPerFrame;
55     }
56 
setSamplesPerFrame(int32_t samplesPerFrame)57     void setSamplesPerFrame(int32_t samplesPerFrame) {
58         mSamplesPerFrame = samplesPerFrame;
59     }
60 
getAudioFormat()61     aaudio_format_t getAudioFormat() const {
62         return mAudioFormat;
63     }
64 
setAudioFormat(aaudio_format_t audioFormat)65     void setAudioFormat(aaudio_format_t audioFormat) {
66         mAudioFormat = audioFormat;
67     }
68 
getSharingMode()69     aaudio_sharing_mode_t getSharingMode() const {
70         return mSharingMode;
71     }
72 
setSharingMode(aaudio_sharing_mode_t sharingMode)73     void setSharingMode(aaudio_sharing_mode_t sharingMode) {
74         mSharingMode = sharingMode;
75     }
76 
getBufferCapacity()77     int32_t getBufferCapacity() const {
78         return mBufferCapacity;
79     }
80 
setBufferCapacity(int32_t frames)81     void setBufferCapacity(int32_t frames) {
82         mBufferCapacity = frames;
83     }
84 
85     virtual status_t writeToParcel(Parcel* parcel) const override;
86 
87     virtual status_t readFromParcel(const Parcel* parcel) override;
88 
89     aaudio_result_t validate() const;
90 
91     void dump() const;
92 
93 private:
94     int32_t               mDeviceId        = AAUDIO_UNSPECIFIED;
95     int32_t               mSampleRate      = AAUDIO_UNSPECIFIED;
96     int32_t               mSamplesPerFrame = AAUDIO_UNSPECIFIED;
97     aaudio_sharing_mode_t mSharingMode     = AAUDIO_SHARING_MODE_SHARED;
98     aaudio_format_t       mAudioFormat     = AAUDIO_FORMAT_UNSPECIFIED;
99     int32_t               mBufferCapacity  = AAUDIO_UNSPECIFIED;
100 };
101 
102 } /* namespace aaudio */
103 
104 #endif //ANDROID_BINDING_AAUDIO_STREAM_CONFIGURATION_H
105