2017-06-27 11:46:10 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-08-09 10:02:41 +02:00
|
|
|
#include <atomic>
|
2017-06-27 11:46:10 +02:00
|
|
|
#include "WindowsAudio.h"
|
|
|
|
|
|
|
|
// This should only be included from WindowsAudio.cpp and WASAPIStream.cpp.
|
|
|
|
|
|
|
|
class WASAPIAudioBackend : public WindowsAudioBackend {
|
|
|
|
public:
|
|
|
|
WASAPIAudioBackend();
|
2022-12-10 20:32:12 -08:00
|
|
|
~WASAPIAudioBackend();
|
2017-06-27 11:46:10 +02:00
|
|
|
|
|
|
|
bool Init(HWND window, StreamCallback callback, int sampleRate) override; // If fails, can safely delete the object
|
2023-03-24 10:40:10 +01:00
|
|
|
int GetSampleRate() const override { return sampleRate_; }
|
2017-06-27 11:46:10 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
int RunThread();
|
|
|
|
static unsigned int WINAPI soundThread(void *param);
|
|
|
|
|
2017-06-27 13:02:20 +02:00
|
|
|
HANDLE hThread_ = nullptr;
|
|
|
|
StreamCallback callback_ = nullptr;
|
|
|
|
int sampleRate_ = 0;
|
2019-08-09 10:02:41 +02:00
|
|
|
std::atomic<int> threadData_;
|
2018-09-30 21:47:00 -07:00
|
|
|
};
|