1 /* 2 * Copyright (C) 2017 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 LB2_SOUND_SYSTEM_AAUDIO_H_ 18 #define LB2_SOUND_SYSTEM_AAUDIO_H_ 19 20 #include <memory> 21 22 #include "lb2/sound_system.h" 23 #include "lb2/test_context.h" 24 25 // Implementation of a sound system via AAudio API. 26 class SoundSystemAAudio : public SoundSystem { 27 public: 28 // Default constructor--for probing. 29 SoundSystemAAudio(); 30 // Constructor with a test context--for testing. 31 explicit SoundSystemAAudio(const TestContext *testCtx); 32 SoundSystemAAudio(const SoundSystemAAudio&) = delete; 33 SoundSystemAAudio& operator=(const SoundSystemAAudio&) = delete; 34 virtual ~SoundSystemAAudio(); 35 36 bool probeDefaultSettings(PerformanceMode performanceMode, int *samplingRate, 37 int *playerBufferFrameCount, int *recorderBufferFrameCount) override; 38 bool init(WriteCallback callback) override; 39 bool drainInput() override; 40 ssize_t readAudio(AudioBufferView<sample_t> buffer) override; 41 void shutdown() override; 42 43 private: 44 struct Impl; // AAudio-specific details. 45 46 const TestContext* mTestCtx; 47 const std::unique_ptr<Impl> mImpl; 48 }; 49 50 #endif // LB2_SOUND_SYSTEM_AAUDIO_H_ 51