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