[vlc-devel] [PATCH 05/10] vdpau: pass a window directly to vlc_xcb_parent_Create

Steve Lhomme robux4 at ycbcr.xyz
Fri Nov 22 14:12:33 CET 2019


We don't need to know about the whole display configuration.
---
 modules/hw/vdpau/display.c        |  2 +-
 modules/video_output/xcb/events.c | 16 +++++++---------
 modules/video_output/xcb/events.h |  7 +++----
 modules/video_output/xcb/render.c |  2 +-
 modules/video_output/xcb/x11.c    |  2 +-
 5 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index 33d16d52980..63dcc2291bc 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -311,7 +311,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
         return VLC_ENOMEM;
 
     const xcb_screen_t *screen;
-    if (vlc_xcb_parent_Create(vd, cfg, &sys->conn, &screen) == NULL)
+    if (vlc_xcb_parent_Create(vd, cfg->window, &sys->conn, &screen) != VLC_SUCCESS)
     {
         free(sys);
         return VLC_EGENERIC;
diff --git a/modules/video_output/xcb/events.c b/modules/video_output/xcb/events.c
index 7c036b46344..559f8da7459 100644
--- a/modules/video_output/xcb/events.c
+++ b/modules/video_output/xcb/events.c
@@ -101,17 +101,15 @@ static const xcb_screen_t *FindScreen (vlc_object_t *obj,
     return NULL;
 }
 
-vout_window_t *vlc_xcb_parent_Create(vout_display_t *vd,
-                                     const vout_display_cfg_t *cfg,
-                                     xcb_connection_t **restrict pconn,
-                                     const xcb_screen_t **restrict pscreen)
+int vlc_xcb_parent_Create(vout_display_t *vd, const vout_window_t *wnd,
+                          xcb_connection_t **restrict pconn,
+                          const xcb_screen_t **restrict pscreen)
 {
-    if (cfg->window->type != VOUT_WINDOW_TYPE_XID)
+    if (wnd->type != VOUT_WINDOW_TYPE_XID)
     {
         msg_Err (vd, "window not available");
-        return NULL;
+        return VLC_EBADVAR;
     }
-    vout_window_t *wnd = cfg->window;
 
     xcb_connection_t *conn = Connect (VLC_OBJECT(vd), wnd->display.x11);
     if (conn == NULL)
@@ -132,12 +130,12 @@ vout_window_t *vlc_xcb_parent_Create(vout_display_t *vd,
     if (screen == NULL)
         goto error;
     *pscreen = screen;
-    return wnd;
+    return VLC_SUCCESS;
 
 error:
     if (conn != NULL)
         xcb_disconnect (conn);
-    return NULL;
+    return VLC_EGENERIC;
 }
 
 /**
diff --git a/modules/video_output/xcb/events.h b/modules/video_output/xcb/events.h
index be86776847f..f3e6ef53142 100644
--- a/modules/video_output/xcb/events.h
+++ b/modules/video_output/xcb/events.h
@@ -40,10 +40,9 @@ int vlc_xcb_error_Check(vout_display_t *, xcb_connection_t *conn,
  * Creates a VLC video X window object, connects to the corresponding X server,
  * finds the corresponding X server screen.
  */
-struct vout_window_t *vlc_xcb_parent_Create(vout_display_t *obj,
-                                            const vout_display_cfg_t *cfg,
-                                            xcb_connection_t **connp,
-                                            const xcb_screen_t **screenp);
+int vlc_xcb_parent_Create(vout_display_t *obj, const vout_window_t *wnd,
+                          xcb_connection_t **connp,
+                          const xcb_screen_t **screenp);
 /**
  * Processes XCB events.
  */
diff --git a/modules/video_output/xcb/render.c b/modules/video_output/xcb/render.c
index a88cdfcbbca..c3e71933f35 100644
--- a/modules/video_output/xcb/render.c
+++ b/modules/video_output/xcb/render.c
@@ -563,7 +563,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     xcb_connection_t *conn;
     const xcb_screen_t *screen;
 
-    if (vlc_xcb_parent_Create(vd, cfg, &conn, &screen) == NULL)
+    if (vlc_xcb_parent_Create(vd, cfg->window, &conn, &screen) != VLC_SUCCESS)
         return VLC_EGENERIC;
 
     sys->conn = conn;
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index 0f7cf49eb12..05e012f3897 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -265,7 +265,7 @@ static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
     /* Get window, connect to X server */
     xcb_connection_t *conn;
     const xcb_screen_t *scr;
-    if (vlc_xcb_parent_Create(vd, cfg, &conn, &scr) == NULL)
+    if (vlc_xcb_parent_Create(vd, cfg->window, &conn, &scr) != VLC_SUCCESS)
     {
         free (sys);
         return VLC_EGENERIC;
-- 
2.17.1



More information about the vlc-devel mailing list