diff options
author | Chris Robinson <[email protected]> | 2023-06-07 01:44:02 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-06-07 01:44:02 -0700 |
commit | 3d9900476ec49b2994b7163a451a69560d498306 (patch) | |
tree | 7fd5d4bb9aed3c531bf3cd86db7738172788c589 /alc/backends | |
parent | 642baebaa2920c92b750246c599f1d381d3f284b (diff) |
Get the correct audio client interface with UWP
Diffstat (limited to 'alc/backends')
-rw-r--r-- | alc/backends/wasapi.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 816a2ae1..b68a59e2 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -443,24 +443,8 @@ struct DeviceHelper final : private IMMNotificationClient #if defined(ALSOFT_UWP) /** ----------------------- IActivateAudioInterfaceCompletionHandler ------------ */ - HRESULT ActivateCompleted(IActivateAudioInterfaceAsyncOperation* operation) override + HRESULT ActivateCompleted(IActivateAudioInterfaceAsyncOperation*) override { - HRESULT hrActivateResult = S_OK; - IUnknown* punkAudioInterface = nullptr; - - HRESULT hr = operation->GetActivateResult(&hrActivateResult, &punkAudioInterface); - // Check for a successful activation result - if (SUCCEEDED(hr) && SUCCEEDED(hrActivateResult)) - { - if (mPPV) - { - // Get the pointer for the Audio Client - IAudioClient3* audioClient; - punkAudioInterface->QueryInterface(IID_PPV_ARGS(&audioClient)); - *mPPV = audioClient; - } - } - SetEvent(mActiveClientEvent); // Need to return S_OK @@ -609,26 +593,35 @@ struct DeviceHelper final : private IMMNotificationClient } #if !defined(ALSOFT_UWP) - static HRESULT activateAudioClient(_In_ DeviceHandle& device, REFIID iid, void **ppv) + static HRESULT activateAudioClient(_In_ DeviceHandle &device, REFIID iid, void **ppv) { return device->Activate(iid, CLSCTX_INPROC_SERVER, nullptr, ppv); } #else - HRESULT activateAudioClient(_In_ DeviceHandle& device, _In_ REFIID iid, void **ppv) + HRESULT activateAudioClient(_In_ DeviceHandle &device, _In_ REFIID iid, void **ppv) { ComPtr<IActivateAudioInterfaceAsyncOperation> asyncOp; - mPPV = ppv; HRESULT hr{ActivateAudioInterfaceAsync(device->Id->Data(), iid, nullptr, this, al::out_ptr(asyncOp))}; if(FAILED(hr)) return hr; - asyncOp = nullptr; - DWORD res{WaitForSingleObjectEx(mActiveClientEvent, 2000, FALSE)}; + /* I don't like waiting for INFINITE time, but the activate operation + * can take an indefinite amount of time since it can require user + * input. + */ + DWORD res{WaitForSingleObjectEx(mActiveClientEvent, INFINITE, FALSE)}; if(res != WAIT_OBJECT_0) { ERR("WaitForSingleObjectEx error: 0x%lx\n", res); return E_FAIL; } - return S_OK; + + HRESULT hrActivateRes{E_FAIL}; + ComPtr<IUnknown> punkAudioIface; + hr = asyncOp->GetActivateResult(&hrActivateRes, al::out_ptr(punkAudioIface)); + if(SUCCEEDED(hr)) hr = hrActivateRes; + if(FAILED(hr)) return hr; + + return punkAudioIface->QueryInterface(iid, ppv); } #endif @@ -763,7 +756,6 @@ private: #else HANDLE mActiveClientEvent{nullptr}; - void** mPPV{nullptr}; EventRegistrationToken mRenderDeviceChangedToken; EventRegistrationToken mCaptureDeviceChangedToken; |