win32/ComWorker: make COMWorker a real class, no static members

This commit is contained in:
Max Kellermann
2021-03-06 20:33:37 +01:00
parent e1fe9ebcd6
commit 90d97053a8
5 changed files with 52 additions and 39 deletions

View File

@@ -44,7 +44,11 @@ public:
void Close() noexcept override {}
int GetVolume() override {
auto future = COMWorker::Async([&]() -> int {
auto com_worker = wasapi_output_get_com_worker(output);
if (!com_worker)
return -1;
auto future = com_worker->Async([&]() -> int {
HRESULT result;
float volume_level;
@@ -76,7 +80,11 @@ public:
}
void SetVolume(unsigned volume) override {
COMWorker::Async([&]() {
auto com_worker = wasapi_output_get_com_worker(output);
if (!com_worker)
throw std::runtime_error("Cannot set WASAPI volume");
com_worker->Async([&]() {
HRESULT result;
const float volume_level = volume / 100.0f;