21#include <aaudio/AAudio.h>
27#include <condition_variable>
57 struct AAudioStreamDeleter {
64 using AAudioStreamPtr = std::unique_ptr<AAudioStream, AAudioStreamDeleter>;
69 AAudioStreamPtr playStream_ {
nullptr};
70 AAudioStreamPtr ringStream_ {
nullptr};
71 AAudioStreamPtr recStream_ {
nullptr};
72 int previousUnderrunCount_ {0};
80 static void errorCallback(
92 std::thread loopThread_;
93 std::condition_variable loopCv_;
94 std::set<AudioDeviceType> streamsToRestart_;
95 bool isRunning_ {
false};
97 bool startJavaRingStream();
98 void stopJavaRingStream();
101 jobject javaRingTrack_ {
nullptr};
103 std::atomic<bool> javaRingRunning_ {
false};
104 std::thread javaRingThread_;
void updatePreference(AudioPreference &pref, int index, AudioDeviceType type) override
void startStream(AudioDeviceType stream) override
Start the capture stream and prepare the playback stream.
static void setJavaVM(JavaVM *vm)
int getIndexRingtone() const override
std::string getAudioDeviceName(int index, AudioDeviceType type) const override
int getAudioDeviceIndex(const std::string &name, AudioDeviceType type) const override
std::vector< std::string > getPlaybackDeviceList() const override
int getIndexCapture() const override
int getIndexPlayback() const override
std::vector< std::string > getCaptureDeviceList() const override
void stopStream(AudioDeviceType stream=AudioDeviceType::ALL) override
Stop the playback and capture streams.
void emitSignal(Args... args)