Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 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 BINDING_AAUDIO_STREAM_CONFIGURATION_H |
| 18 | #define BINDING_AAUDIO_STREAM_CONFIGURATION_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include <binder/Parcel.h> |
| 23 | #include <binder/Parcelable.h> |
| 24 | #include <aaudio/AAudioDefinitions.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 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 37 | int32_t getDeviceId() const { |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 38 | return mDeviceId; |
| 39 | } |
| 40 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 41 | void setDeviceId(int32_t deviceId) { |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 42 | mDeviceId = deviceId; |
| 43 | } |
| 44 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 45 | int32_t getSampleRate() const { |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 46 | return mSampleRate; |
| 47 | } |
| 48 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 49 | void setSampleRate(int32_t sampleRate) { |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 50 | mSampleRate = sampleRate; |
| 51 | } |
| 52 | |
| 53 | int32_t getSamplesPerFrame() const { |
| 54 | return mSamplesPerFrame; |
| 55 | } |
| 56 | |
| 57 | void setSamplesPerFrame(int32_t samplesPerFrame) { |
| 58 | mSamplesPerFrame = samplesPerFrame; |
| 59 | } |
| 60 | |
| 61 | aaudio_audio_format_t getAudioFormat() const { |
| 62 | return mAudioFormat; |
| 63 | } |
| 64 | |
| 65 | void setAudioFormat(aaudio_audio_format_t audioFormat) { |
| 66 | mAudioFormat = audioFormat; |
| 67 | } |
| 68 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 69 | int32_t getBufferCapacity() const { |
Phil Burk | 3df348f | 2017-02-08 11:41:55 -0800 | [diff] [blame] | 70 | return mBufferCapacity; |
| 71 | } |
| 72 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 73 | void setBufferCapacity(int32_t frames) { |
Phil Burk | 3df348f | 2017-02-08 11:41:55 -0800 | [diff] [blame] | 74 | mBufferCapacity = frames; |
| 75 | } |
| 76 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 77 | virtual status_t writeToParcel(Parcel* parcel) const override; |
| 78 | |
| 79 | virtual status_t readFromParcel(const Parcel* parcel) override; |
| 80 | |
| 81 | aaudio_result_t validate(); |
| 82 | |
| 83 | void dump(); |
| 84 | |
| 85 | protected: |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 86 | int32_t mDeviceId = AAUDIO_DEVICE_UNSPECIFIED; |
| 87 | int32_t mSampleRate = AAUDIO_UNSPECIFIED; |
Phil Burk | 3df348f | 2017-02-08 11:41:55 -0800 | [diff] [blame] | 88 | int32_t mSamplesPerFrame = AAUDIO_UNSPECIFIED; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 89 | aaudio_audio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED; |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 90 | int32_t mBufferCapacity = AAUDIO_UNSPECIFIED; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } /* namespace aaudio */ |
| 94 | |
| 95 | #endif //BINDING_AAUDIO_STREAM_CONFIGURATION_H |