mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
d3d11window: Add unprepare method to clear internal resource
GObject::dispose method can be called multiple times. As win32 d3d11window has an internal thread and because GObject::dispose method could be called from the thread, it might cause problems such as trying to join self-thread Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1299>
This commit is contained in:
parent
8ce4980273
commit
afe941249e
6 changed files with 60 additions and 10 deletions
|
@ -594,6 +594,9 @@ gst_d3d11_video_sink_stop (GstBaseSink * sink)
|
||||||
self->fallback_pool = NULL;
|
self->fallback_pool = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self->window)
|
||||||
|
gst_d3d11_window_unprepare (self->window);
|
||||||
|
|
||||||
gst_clear_object (&self->device);
|
gst_clear_object (&self->device);
|
||||||
gst_clear_object (&self->window);
|
gst_clear_object (&self->window);
|
||||||
|
|
||||||
|
|
|
@ -999,6 +999,19 @@ gst_d3d11_window_unlock_stop (GstD3D11Window * window)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_d3d11_window_unprepare (GstD3D11Window * window)
|
||||||
|
{
|
||||||
|
GstD3D11WindowClass *klass;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_D3D11_WINDOW (window));
|
||||||
|
|
||||||
|
klass = GST_D3D11_WINDOW_GET_CLASS (window);
|
||||||
|
|
||||||
|
if (klass->unprepare)
|
||||||
|
klass->unprepare (window);
|
||||||
|
}
|
||||||
|
|
||||||
GstD3D11WindowNativeType
|
GstD3D11WindowNativeType
|
||||||
gst_d3d11_window_get_native_type_from_handle (guintptr handle)
|
gst_d3d11_window_get_native_type_from_handle (guintptr handle)
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,6 +132,8 @@ struct _GstD3D11WindowClass
|
||||||
void (*on_resize) (GstD3D11Window * window,
|
void (*on_resize) (GstD3D11Window * window,
|
||||||
guint width,
|
guint width,
|
||||||
guint height);
|
guint height);
|
||||||
|
|
||||||
|
void (*unprepare) (GstD3D11Window * window);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_d3d11_window_get_type (void);
|
GType gst_d3d11_window_get_type (void);
|
||||||
|
@ -157,6 +159,8 @@ gboolean gst_d3d11_window_unlock (GstD3D11Window * window);
|
||||||
|
|
||||||
gboolean gst_d3d11_window_unlock_stop (GstD3D11Window * window);
|
gboolean gst_d3d11_window_unlock_stop (GstD3D11Window * window);
|
||||||
|
|
||||||
|
void gst_d3d11_window_unprepare (GstD3D11Window * window);
|
||||||
|
|
||||||
void gst_d3d11_window_on_key_event (GstD3D11Window * window,
|
void gst_d3d11_window_on_key_event (GstD3D11Window * window,
|
||||||
const gchar * event,
|
const gchar * event,
|
||||||
const gchar * key);
|
const gchar * key);
|
||||||
|
|
|
@ -98,6 +98,8 @@ gst_d3d11_window_core_window_on_resize (GstD3D11Window * window,
|
||||||
guint width, guint height);
|
guint width, guint height);
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_core_window_on_resize_sync (GstD3D11Window * window);
|
gst_d3d11_window_core_window_on_resize_sync (GstD3D11Window * window);
|
||||||
|
static void
|
||||||
|
gst_d3d11_window_core_window_unprepare (GstD3D11Window * window);
|
||||||
|
|
||||||
static float
|
static float
|
||||||
get_logical_dpi (void)
|
get_logical_dpi (void)
|
||||||
|
@ -259,6 +261,8 @@ gst_d3d11_window_core_window_class_init (GstD3D11WindowCoreWindowClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_window_core_window_unlock_stop);
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_core_window_unlock_stop);
|
||||||
window_class->on_resize =
|
window_class->on_resize =
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_window_core_window_on_resize);
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_core_window_on_resize);
|
||||||
|
window_class->unprepare =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_core_window_unprepare);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -333,7 +337,15 @@ error:
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_core_window_dispose (GObject * object)
|
gst_d3d11_window_core_window_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GstD3D11WindowCoreWindow *self = GST_D3D11_WINDOW_CORE_WINDOW (object);
|
gst_d3d11_window_core_window_unprepare (GST_D3D11_WINDOW (object));
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_d3d11_window_core_window_unprepare (GstD3D11Window * window)
|
||||||
|
{
|
||||||
|
GstD3D11WindowCoreWindow *self = GST_D3D11_WINDOW_CORE_WINDOW (window);
|
||||||
CoreWindowWinRTStorage *storage = self->storage;
|
CoreWindowWinRTStorage *storage = self->storage;
|
||||||
|
|
||||||
if (storage) {
|
if (storage) {
|
||||||
|
@ -356,8 +368,6 @@ gst_d3d11_window_core_window_dispose (GObject * object)
|
||||||
}
|
}
|
||||||
|
|
||||||
self->storage = NULL;
|
self->storage = NULL;
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -96,6 +96,9 @@ gst_d3d11_window_swap_chain_panel_on_resize (GstD3D11Window * window,
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_swap_chain_panel_on_resize_sync (GstD3D11Window *
|
gst_d3d11_window_swap_chain_panel_on_resize_sync (GstD3D11Window *
|
||||||
window);
|
window);
|
||||||
|
static void
|
||||||
|
gst_d3d11_window_swap_chain_panel_unprepare (GstD3D11Window * window);
|
||||||
|
|
||||||
class PanelResizeHandler
|
class PanelResizeHandler
|
||||||
: public RuntimeClass<RuntimeClassFlags<ClassicCom>,
|
: public RuntimeClass<RuntimeClassFlags<ClassicCom>,
|
||||||
Xaml::ISizeChangedEventHandler>
|
Xaml::ISizeChangedEventHandler>
|
||||||
|
@ -224,6 +227,8 @@ gst_d3d11_window_swap_chain_panel_class_init (GstD3D11WindowSwapChainPanelClass
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_unlock_stop);
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_unlock_stop);
|
||||||
window_class->on_resize =
|
window_class->on_resize =
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_on_resize);
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_on_resize);
|
||||||
|
window_class->unprepare =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_swap_chain_panel_unprepare);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -303,9 +308,17 @@ error:
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_swap_chain_panel_dispose (GObject * object)
|
gst_d3d11_window_swap_chain_panel_dispose (GObject * object)
|
||||||
|
{
|
||||||
|
gst_d3d11_window_swap_chain_panel_unprepare (GST_D3D11_WINDOW (object));
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_d3d11_window_swap_chain_panel_unprepare (GstD3D11Window * window)
|
||||||
{
|
{
|
||||||
GstD3D11WindowSwapChainPanel *self =
|
GstD3D11WindowSwapChainPanel *self =
|
||||||
GST_D3D11_WINDOW_SWAP_CHAIN_PANEL (object);
|
GST_D3D11_WINDOW_SWAP_CHAIN_PANEL (window);
|
||||||
SwapChainPanelWinRTStorage *storage = self->storage;
|
SwapChainPanelWinRTStorage *storage = self->storage;
|
||||||
|
|
||||||
if (storage) {
|
if (storage) {
|
||||||
|
@ -329,8 +342,6 @@ gst_d3d11_window_swap_chain_panel_dispose (GObject * object)
|
||||||
}
|
}
|
||||||
|
|
||||||
self->storage = NULL;
|
self->storage = NULL;
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -118,6 +118,7 @@ gst_d3d11_window_win32_set_window_handle (GstD3D11WindowWin32 * self,
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_win32_on_resize (GstD3D11Window * window,
|
gst_d3d11_window_win32_on_resize (GstD3D11Window * window,
|
||||||
guint width, guint height);
|
guint width, guint height);
|
||||||
|
static void gst_d3d11_window_win32_unprepare (GstD3D11Window * window);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_win32_class_init (GstD3D11WindowWin32Class * klass)
|
gst_d3d11_window_win32_class_init (GstD3D11WindowWin32Class * klass)
|
||||||
|
@ -139,6 +140,8 @@ gst_d3d11_window_win32_class_init (GstD3D11WindowWin32Class * klass)
|
||||||
window_class->present = GST_DEBUG_FUNCPTR (gst_d3d11_window_win32_present);
|
window_class->present = GST_DEBUG_FUNCPTR (gst_d3d11_window_win32_present);
|
||||||
window_class->on_resize =
|
window_class->on_resize =
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_window_win32_on_resize);
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_win32_on_resize);
|
||||||
|
window_class->unprepare =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_d3d11_window_win32_unprepare);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -171,11 +174,19 @@ gst_d3d11_window_win32_constructed (GObject * object)
|
||||||
static void
|
static void
|
||||||
gst_d3d11_window_win32_dispose (GObject * object)
|
gst_d3d11_window_win32_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GstD3D11WindowWin32 *self = GST_D3D11_WINDOW_WIN32 (object);
|
gst_d3d11_window_win32_unprepare (GST_D3D11_WINDOW (object));
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_d3d11_window_win32_unprepare (GstD3D11Window * window)
|
||||||
|
{
|
||||||
|
GstD3D11WindowWin32 *self = GST_D3D11_WINDOW_WIN32 (window);
|
||||||
|
|
||||||
gst_d3d11_window_win32_release_external_handle (self);
|
gst_d3d11_window_win32_release_external_handle (self);
|
||||||
|
|
||||||
if (self->loop) {
|
if (self->loop) {
|
||||||
g_main_loop_quit (self->loop);
|
g_main_loop_quit (self->loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,8 +204,6 @@ gst_d3d11_window_win32_dispose (GObject * object)
|
||||||
g_main_context_unref (self->main_context);
|
g_main_context_unref (self->main_context);
|
||||||
self->main_context = NULL;
|
self->main_context = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue