mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +00:00
wasapi2: Fix potential crash on device activation failure
The activation object is live in COM thread already and therefore self refcount hack is pointless. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4194>
This commit is contained in:
parent
65bd020754
commit
fba06cfc76
1 changed files with 4 additions and 17 deletions
|
@ -144,7 +144,6 @@ public:
|
||||||
client = (GstWasapi2Client *) g_weak_ref_get (&listener_);
|
client = (GstWasapi2Client *) g_weak_ref_get (&listener_);
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
this->Release ();
|
|
||||||
GST_WARNING ("No listener was configured");
|
GST_WARNING ("No listener was configured");
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -177,8 +176,6 @@ public:
|
||||||
* by passed IAudioClient handle via gst_wasapi2_client_on_device_activated
|
* by passed IAudioClient handle via gst_wasapi2_client_on_device_activated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this->Release ();
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,17 +228,6 @@ public:
|
||||||
hr = work_item->Invoke ();
|
hr = work_item->Invoke ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We should hold activator object until activation callback has executed,
|
|
||||||
* because OS doesn't hold reference of this callback COM object.
|
|
||||||
* otherwise access violation would happen
|
|
||||||
* See https://docs.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-activateaudiointerfaceasync
|
|
||||||
*
|
|
||||||
* This reference count will be decreased by self later on callback,
|
|
||||||
* which will be called from device worker thread.
|
|
||||||
*/
|
|
||||||
if (gst_wasapi2_result (hr))
|
|
||||||
this->AddRef ();
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,9 +390,6 @@ static void
|
||||||
gst_wasapi2_client_constructed (GObject * object)
|
gst_wasapi2_client_constructed (GObject * object)
|
||||||
{
|
{
|
||||||
GstWasapi2Client *self = GST_WASAPI2_CLIENT (object);
|
GstWasapi2Client *self = GST_WASAPI2_CLIENT (object);
|
||||||
/* *INDENT-OFF* */
|
|
||||||
ComPtr<GstWasapiDeviceActivator> activator;
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
|
|
||||||
/* Create a new thread to ensure that COM thread can be MTA thread.
|
/* Create a new thread to ensure that COM thread can be MTA thread.
|
||||||
* We cannot ensure whether CoInitializeEx() was called outside of here for
|
* We cannot ensure whether CoInitializeEx() was called outside of here for
|
||||||
|
@ -959,6 +942,10 @@ run_loop:
|
||||||
|
|
||||||
g_main_context_pop_thread_default (self->context);
|
g_main_context_pop_thread_default (self->context);
|
||||||
|
|
||||||
|
/* Wait for pending async op if any */
|
||||||
|
if (self->dispatcher)
|
||||||
|
gst_wasapi2_client_ensure_activation (self);
|
||||||
|
|
||||||
GST_WASAPI2_CLEAR_COM (self->audio_client);
|
GST_WASAPI2_CLEAR_COM (self->audio_client);
|
||||||
|
|
||||||
/* Reset explicitly to ensure that it happens before
|
/* Reset explicitly to ensure that it happens before
|
||||||
|
|
Loading…
Reference in a new issue