AAudioStreamConfiguration.h revision f53e613b3dedab3ecada2c93d8846233c442d129
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 26using android::status_t; 27using android::Parcel; 28using android::Parcelable; 29 30namespace aaudio { 31 32class AAudioStreamConfiguration : public Parcelable { 33public: 34 AAudioStreamConfiguration(); 35 virtual ~AAudioStreamConfiguration(); 36 37 aaudio_device_id_t getDeviceId() const { 38 return mDeviceId; 39 } 40 41 void setDeviceId(aaudio_device_id_t deviceId) { 42 mDeviceId = deviceId; 43 } 44 45 aaudio_sample_rate_t getSampleRate() const { 46 return mSampleRate; 47 } 48 49 void setSampleRate(aaudio_sample_rate_t sampleRate) { 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 69 aaudio_size_frames_t getBufferCapacity() const { 70 return mBufferCapacity; 71 } 72 73 void setBufferCapacity(aaudio_size_frames_t frames) { 74 mBufferCapacity = frames; 75 } 76 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 85protected: 86 aaudio_device_id_t mDeviceId = AAUDIO_DEVICE_UNSPECIFIED; 87 aaudio_sample_rate_t mSampleRate = AAUDIO_UNSPECIFIED; 88 int32_t mSamplesPerFrame = AAUDIO_UNSPECIFIED; 89 aaudio_audio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED; 90 aaudio_size_frames_t mBufferCapacity = AAUDIO_UNSPECIFIED; 91}; 92 93} /* namespace aaudio */ 94 95#endif //BINDING_AAUDIO_STREAM_CONFIGURATION_H 96