[vlc-commits] window: add destroy callback
Rémi Denis-Courmont
git at videolan.org
Sun Dec 2 18:40:25 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec 1 16:24:01 2018 +0200| [204e8b5092932638146547526a0817bebaf66956] | committer: Rémi Denis-Courmont
window: add destroy callback
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=204e8b5092932638146547526a0817bebaf66956
---
include/vlc_vout_window.h | 7 +++++++
modules/gui/macosx/VLCVideoOutputProvider.m | 4 +++-
modules/gui/macosx/macosx.m | 3 +--
modules/gui/minimal_macosx/intf.m | 4 +++-
modules/gui/minimal_macosx/macosx.c | 3 +--
modules/gui/qt/qt.cpp | 3 ++-
modules/gui/skins2/src/skin_main.cpp | 3 ++-
modules/video_output/android/window.c | 3 ++-
modules/video_output/drawable.c | 3 ++-
modules/video_output/wayland/xdg-shell.c | 5 ++++-
modules/video_output/xcb/window.c | 16 +++++++++++++---
src/video_output/window.c | 12 +++---------
12 files changed, 43 insertions(+), 23 deletions(-)
diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
index 9981fff10f..0a28bd690e 100644
--- a/include/vlc_vout_window.h
+++ b/include/vlc_vout_window.h
@@ -138,6 +138,13 @@ struct vout_window_operations {
* vout_window_Control() should be used instead.
*/
int (*control)(vout_window_t *, int, va_list);
+
+ /**
+ * Destroy the window.
+ *
+ * Destroys the window and releases all associated resources.
+ */
+ void (*destroy)(vout_window_t *);
};
typedef struct vout_window_owner {
diff --git a/modules/gui/macosx/VLCVideoOutputProvider.m b/modules/gui/macosx/VLCVideoOutputProvider.m
index 92736c6721..950b4bee69 100644
--- a/modules/gui/macosx/VLCVideoOutputProvider.m
+++ b/modules/gui/macosx/VLCVideoOutputProvider.m
@@ -42,9 +42,11 @@
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
static int WindowControl(vout_window_t *, int i_query, va_list);
+static void WindowClose(vout_window_t *);
static const struct vout_window_operations ops = {
WindowControl,
+ WindowClose,
};
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
@@ -157,7 +159,7 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
}
}
-void WindowClose(vout_window_t *p_wnd)
+static void WindowClose(vout_window_t *p_wnd)
{
@autoreleasepool {
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
diff --git a/modules/gui/macosx/macosx.m b/modules/gui/macosx/macosx.m
index 4edd129bde..30410a1ca6 100644
--- a/modules/gui/macosx/macosx.m
+++ b/modules/gui/macosx/macosx.m
@@ -43,7 +43,6 @@ int OpenIntf (vlc_object_t *);
void CloseIntf (vlc_object_t *);
int WindowOpen (vout_window_t *, const vout_window_cfg_t *);
-void WindowClose (vout_window_t *);
/*****************************************************************************
* Module descriptor
@@ -188,7 +187,7 @@ vlc_module_begin()
add_submodule()
set_description("Mac OS X Video Output Provider")
set_capability("vout window", 100)
- set_callbacks(WindowOpen, WindowClose)
+ set_callbacks(WindowOpen, NULL)
set_section(N_("Video output"), 0)
add_integer("macosx-vdev", 0, VDEV_TEXT, VDEV_LONGTEXT, false)
diff --git a/modules/gui/minimal_macosx/intf.m b/modules/gui/minimal_macosx/intf.m
index c3ab7fd1ac..4afd8773ce 100644
--- a/modules/gui/minimal_macosx/intf.m
+++ b/modules/gui/minimal_macosx/intf.m
@@ -101,9 +101,11 @@ static void Run(intf_thread_t *p_intf)
* Vout window management
*****************************************************************************/
static int WindowControl(vout_window_t *, int i_query, va_list);
+static void WindowClose(vout_window_t *);
static const struct vout_window_operations ops = {
WindowControl,
+ WindowClose,
};
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
@@ -185,7 +187,7 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
}
}
-void WindowClose(vout_window_t *p_wnd)
+static void WindowClose(vout_window_t *p_wnd)
{
@autoreleasepool {
NSWindow * o_window = [(__bridge id)p_wnd->handle.nsobject window];
diff --git a/modules/gui/minimal_macosx/macosx.c b/modules/gui/minimal_macosx/macosx.c
index 291a05cdd1..f549b2e3cd 100644
--- a/modules/gui/minimal_macosx/macosx.c
+++ b/modules/gui/minimal_macosx/macosx.c
@@ -44,7 +44,6 @@ int OpenIntf ( vlc_object_t * );
void CloseIntf ( vlc_object_t * );
int WindowOpen ( vout_window_t *, const vout_window_cfg_t * );
-void WindowClose ( vout_window_t * );
/*****************************************************************************
* Module descriptor
@@ -64,6 +63,6 @@ vlc_module_begin ()
/* Will be loaded even without interface module. see voutgl.m */
set_description( "Minimal Mac OS X Video Output Provider" )
set_capability( "vout window", 50 )
- set_callbacks( WindowOpen, WindowClose )
+ set_callbacks( WindowOpen, NULL )
vlc_module_end ()
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index 073a418e3d..f7d973bcd6 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -346,7 +346,7 @@ vlc_module_begin ()
add_submodule ()
set_capability( "vout window", 0 )
- set_callbacks( WindowOpen, WindowClose )
+ set_callbacks( WindowOpen, NULL )
vlc_module_end ()
@@ -696,6 +696,7 @@ static int WindowControl( vout_window_t *, int i_query, va_list );
static const struct vout_window_operations window_ops = {
WindowControl,
+ WindowClose,
};
static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp
index de9554b2d1..ce42fa51b7 100644
--- a/modules/gui/skins2/src/skin_main.cpp
+++ b/modules/gui/skins2/src/skin_main.cpp
@@ -344,6 +344,7 @@ static void WindowCloseLocal( intf_thread_t* pIntf, vlc_object_t *pObj )
static const struct vout_window_operations window_ops = {
WindowControl,
+ WindowClose,
};
static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg )
@@ -518,6 +519,6 @@ vlc_module_begin ()
add_submodule ()
set_capability( "vout window", 51 )
- set_callbacks( WindowOpen, WindowClose )
+ set_callbacks( WindowOpen, NULL )
vlc_module_end ()
diff --git a/modules/video_output/android/window.c b/modules/video_output/android/window.c
index d0617cd47e..05f7ccf477 100644
--- a/modules/video_output/android/window.c
+++ b/modules/video_output/android/window.c
@@ -50,7 +50,7 @@ vlc_module_begin()
set_category(CAT_VIDEO)
set_subcategory(SUBCAT_VIDEO_VOUT)
set_capability("vout window", 10)
- set_callbacks(Open, Close)
+ set_callbacks(Open, NULL)
vlc_module_end()
@@ -84,6 +84,7 @@ static void OnNewMouseCoords(vout_window_t *wnd,
static const struct vout_window_operations ops = {
.control = Control,
+ .destroy = Close,
};
/**
diff --git a/modules/video_output/drawable.c b/modules/video_output/drawable.c
index db71e885dd..37f26c4a69 100644
--- a/modules/video_output/drawable.c
+++ b/modules/video_output/drawable.c
@@ -48,7 +48,7 @@ vlc_module_begin ()
set_category (CAT_VIDEO)
set_subcategory (SUBCAT_VIDEO_VOUT)
set_capability ("vout window", 70)
- set_callbacks (Open, Close)
+ set_callbacks (Open, NULL)
add_shortcut ("embed-hwnd")
add_integer ("drawable-hwnd", 0, HWND_TEXT, HWND_LONGTEXT, true)
@@ -64,6 +64,7 @@ static uintptr_t *used = NULL;
static const struct vout_window_operations ops = {
.control = Control,
+ .destroy = Close,
};
/**
diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c
index d37f415c74..e482c94320 100644
--- a/modules/video_output/wayland/xdg-shell.c
+++ b/modules/video_output/wayland/xdg-shell.c
@@ -236,8 +236,11 @@ static int Control(vout_window_t *wnd, int cmd, va_list ap)
return VLC_SUCCESS;
}
+static void Close(vout_window_t *);
+
static const struct vout_window_operations ops = {
.control = Control,
+ .destroy = Close,
};
#ifdef XDG_SHELL
@@ -674,7 +677,7 @@ vlc_module_begin()
#else
set_capability("vout window", 10)
#endif
- set_callbacks(Open, Close)
+ set_callbacks(Open, NULL)
add_string("wl-display", NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true)
add_integer("wl-output", 0, OUTPUT_TEXT, OUTPUT_LONGTEXT, true)
diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c
index 1cd830a120..f6ba98b516 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -561,8 +561,11 @@ static void set_wm_deco(xcb_connection_t *conn, xcb_window_t window, bool on)
atom, 32, ARRAY_SIZE(motif_wm_hints), motif_wm_hints);
}
+static void Close(vout_window_t *);
+
static const struct vout_window_operations ops = {
.control = Control,
+ .destroy = Close,
};
/**
@@ -821,6 +824,13 @@ static void ReleaseDrawable (vlc_object_t *obj, xcb_window_t window)
var_Destroy (obj->obj.libvlc, "xid-in-use");
}
+static void EmClose(vout_window_t *);
+
+static const struct vout_window_operations em_ops = {
+ .control = Control,
+ .destroy = EmClose,
+};
+
/**
* Wrap an existing X11 window to embed the video.
*/
@@ -842,7 +852,7 @@ static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg)
wnd->type = VOUT_WINDOW_TYPE_XID;
wnd->display.x11 = NULL;
wnd->handle.xid = window;
- wnd->ops = &ops;
+ wnd->ops = &em_ops;
wnd->sys = p_sys;
p_sys->conn = conn;
@@ -923,7 +933,7 @@ vlc_module_begin ()
set_category (CAT_VIDEO)
set_subcategory (SUBCAT_VIDEO_VOUT)
set_capability ("vout window", 10)
- set_callbacks (Open, Close)
+ set_callbacks(Open, NULL)
/* Obsolete since 1.1.0: */
add_obsolete_bool ("x11-altfullscreen")
@@ -937,7 +947,7 @@ vlc_module_begin ()
set_category (CAT_VIDEO)
set_subcategory (SUBCAT_VIDEO_VOUT)
set_capability ("vout window", 70)
- set_callbacks (EmOpen, EmClose)
+ set_callbacks(EmOpen, NULL)
add_shortcut ("embed-xid")
add_string ("x11-display", NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true)
diff --git a/src/video_output/window.c b/src/video_output/window.c
index 824709869d..bf8db2b24e 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -88,14 +88,6 @@ vout_window_t *vout_window_New(vlc_object_t *obj, const char *module,
return window;
}
-static void vout_window_stop(void *func, va_list ap)
-{
- int (*deactivate)(vout_window_t *) = func;
- vout_window_t *wnd = va_arg(ap, vout_window_t *);
-
- deactivate(wnd);
-}
-
void vout_window_Delete(vout_window_t *window)
{
if (!window)
@@ -108,7 +100,9 @@ void vout_window_Delete(vout_window_t *window)
vlc_inhibit_Destroy (w->inhibit);
}
- vlc_module_unload(window, w->module, vout_window_stop, window);
+ if (window->ops->destroy != NULL)
+ window->ops->destroy(window);
+ vlc_objres_clear(VLC_OBJECT(window));
vlc_object_release(window);
}
More information about the vlc-commits
mailing list