diff options
author | Chris Robinson <[email protected]> | 2020-03-24 11:40:34 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-03-24 11:40:34 -0700 |
commit | 62f17d8763503b0cb924566c9ab75f8bf3ac123e (patch) | |
tree | b2b3e2ece74a1596ac229ddd937fbf6150ddbc88 /alc | |
parent | eed8407599e5953b3cd07060d8afca782b4941e1 (diff) |
Don't send close messages for unopened WASAPI devices
Diffstat (limited to 'alc')
-rw-r--r-- | alc/backends/wasapi.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 059ebec6..37d89f13 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -650,6 +650,7 @@ struct WasapiPlayback final : public BackendBase, WasapiProxy { std::wstring mDevId; + HRESULT mOpenStatus{E_FAIL}; IMMDevice *mMMDev{nullptr}; IAudioClient *mClient{nullptr}; IAudioRenderClient *mRender{nullptr}; @@ -666,7 +667,9 @@ struct WasapiPlayback final : public BackendBase, WasapiProxy { WasapiPlayback::~WasapiPlayback() { - pushMessage(MsgType::CloseDevice).wait(); + if(SUCCEEDED(mOpenStatus)) + pushMessage(MsgType::CloseDevice).wait(); + mOpenStatus = E_FAIL; if(mNotifyEvent != nullptr) CloseHandle(mNotifyEvent); @@ -779,6 +782,7 @@ void WasapiPlayback::open(const ALCchar *name) if(SUCCEEDED(hr)) hr = pushMessage(MsgType::OpenDevice).get(); + mOpenStatus = hr; if(FAILED(hr)) { @@ -1194,6 +1198,7 @@ struct WasapiCapture final : public BackendBase, WasapiProxy { std::wstring mDevId; + HRESULT mOpenStatus{E_FAIL}; IMMDevice *mMMDev{nullptr}; IAudioClient *mClient{nullptr}; IAudioCaptureClient *mCapture{nullptr}; @@ -1211,7 +1216,9 @@ struct WasapiCapture final : public BackendBase, WasapiProxy { WasapiCapture::~WasapiCapture() { - pushMessage(MsgType::CloseDevice).wait(); + if(SUCCEEDED(mOpenStatus)) + pushMessage(MsgType::CloseDevice).wait(); + mOpenStatus = E_FAIL; if(mNotifyEvent != nullptr) CloseHandle(mNotifyEvent); @@ -1355,6 +1362,7 @@ void WasapiCapture::open(const ALCchar *name) if(SUCCEEDED(hr)) hr = pushMessage(MsgType::OpenDevice).get(); + mOpenStatus = hr; if(FAILED(hr)) { |