wasapi2: Handle GetActivateResult failure
Even if GetActivateResult() succeeded, activation result can fail. Checks output HRESULT code as well Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9468>
This commit is contained in:
parent
7651662fc9
commit
fedced4017
@ -89,16 +89,32 @@ Wasapi2ActivationHandler::ActivateCompleted (IActivateAudioInterfaceAsyncOperati
|
||||
{
|
||||
ComPtr<IUnknown> iface;
|
||||
HRESULT hr = S_OK;
|
||||
hr = op->GetActivateResult (&hr, &iface);
|
||||
if (FAILED (hr)) {
|
||||
HRESULT activate_hr = S_OK;
|
||||
hr = op->GetActivateResult (&activate_hr, &iface);
|
||||
if (!gst_wasapi2_result (hr))
|
||||
GST_ERROR ("Couldn't get activate result, hr: 0x%x", (guint) hr);
|
||||
|
||||
if (!gst_wasapi2_result (activate_hr)) {
|
||||
GST_ERROR ("GetActivateResult failed, hr: 0x%x", (guint) activate_hr);
|
||||
hr = activate_hr;
|
||||
}
|
||||
|
||||
if (SUCCEEDED (hr) && !iface) {
|
||||
GST_ERROR ("Couldn't get inteface from asyncop");
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED (hr)) {
|
||||
activate_hr_ = hr;
|
||||
SetEvent (event_);
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iface.As (&client_);
|
||||
activate_hr_ = hr;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk (lock_);
|
||||
hr = iface.As (&client_);
|
||||
activate_hr_ = hr;
|
||||
}
|
||||
|
||||
GST_LOG ("Activation result 0x%x", (guint) hr);
|
||||
|
||||
@ -133,6 +149,10 @@ Wasapi2ActivationHandler::GetClient (IAudioClient ** client, DWORD timeout)
|
||||
if (!client)
|
||||
return S_OK;
|
||||
|
||||
std::lock_guard<std::mutex> lk (lock_);
|
||||
if (!client_)
|
||||
return E_FAIL;
|
||||
|
||||
*client = client_.Get ();
|
||||
(*client)->AddRef ();
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <wrl.h>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
/* Copy of audioclientactivationparams.h since those types are defined only for
|
||||
* NTDDI_VERSION >= NTDDI_WIN10_FE */
|
||||
@ -85,6 +86,7 @@ private:
|
||||
private:
|
||||
Microsoft::WRL::ComPtr<IAudioClient> client_;
|
||||
std::atomic<HRESULT> activate_hr_ = { E_FAIL };
|
||||
std::mutex lock_;
|
||||
HANDLE event_;
|
||||
PROPVARIANT prop_ = { };
|
||||
AUDIOCLIENT_ACTIVATION_PARAMS params_ = { };
|
||||
|
Loading…
x
Reference in New Issue
Block a user