[vlc-devel] [PATCH] xcb: remove dead code

Steve Lhomme robux4 at ycbcr.xyz
Fri Jun 21 11:06:14 CEST 2019


---
 modules/video_output/xcb/pictures.c | 122 ----------------------------
 modules/video_output/xcb/pictures.h |  12 ---
 2 files changed, 134 deletions(-)

diff --git a/modules/video_output/xcb/pictures.c b/modules/video_output/xcb/pictures.c
index 602a1a1b4f..35eb703834 100644
--- a/modules/video_output/xcb/pictures.c
+++ b/modules/video_output/xcb/pictures.c
@@ -29,21 +29,13 @@
 #include <errno.h>
 
 #include <sys/types.h>
-#ifdef HAVE_SYS_SHM_H
-# include <sys/shm.h>
-# include <sys/stat.h>
-#else
-# define shmdt(mem) free(mem)
-#endif
 
 #include <xcb/xcb.h>
 #include <xcb/shm.h>
 
 #include <vlc_common.h>
-#include <vlc_vout_display.h>
 
 #include "pictures.h"
-#include "events.h"
 
 const xcb_format_t *vlc_xcb_DepthToPixmapFormat(const xcb_setup_t *setup,
                                                 uint_fast8_t depth)
@@ -178,117 +170,3 @@ fail:
     msg_Warn(obj, "display will be slow");
     return false;
 }
-
-#ifdef HAVE_SYS_SHM_H
-/**
- * Release picture private data: detach the shared memory segment.
- */
-static void XCB_picture_SysV_Destroy (picture_t *pic)
-{
-    shmdt (pic->p[0].p_pixels);
-}
-
-static int XCB_picture_SysV_Alloc(vout_display_t *vd, picture_resource_t *res,
-                                  size_t size, xcb_connection_t *conn,
-                                  xcb_shm_seg_t segment)
-{
-    /* Allocate shared memory segment */
-    int id = shmget (IPC_PRIVATE, size, IPC_CREAT | S_IRWXU);
-    if (id == -1)
-    {
-        msg_Err (vd, "shared memory allocation error: %s",
-                 vlc_strerror_c(errno));
-        return -1;
-    }
-
-    /* Attach the segment to VLC */
-    void *shm = shmat (id, NULL, 0 /* read/write */);
-    if (-1 == (intptr_t)shm)
-    {
-        msg_Err (vd, "shared memory attachment error: %s",
-                 vlc_strerror_c(errno));
-        shmctl (id, IPC_RMID, 0);
-        return -1;
-    }
-
-    if (segment != 0)
-    {   /* Attach the segment to X */
-        xcb_void_cookie_t ck = xcb_shm_attach_checked (conn, segment, id, 1);
-        switch (vlc_xcb_error_Check(vd, conn,
-                                    "shared memory server-side error", ck))
-        {
-            case 0:
-                break;
-
-            case XCB_ACCESS:
-            {
-                struct shmid_ds buf;
-                /* Retry with promiscuous permissions */
-                shmctl (id, IPC_STAT, &buf);
-                buf.shm_perm.mode |= S_IRGRP|S_IROTH;
-                shmctl (id, IPC_SET, &buf);
-                ck = xcb_shm_attach_checked (conn, segment, id, 1);
-                if (vlc_xcb_error_Check(vd, conn, "same error on retry",
-                                        ck) == 0)
-                    break;
-            }   /* fall through */
-
-            default:
-                msg_Info (vd, "using buggy X11 server - SSH proxying?");
-                segment = 0;
-        }
-    }
-
-    shmctl (id, IPC_RMID, NULL);
-
-    res->p_sys = (void *)(uintptr_t)segment;
-    res->pf_destroy = XCB_picture_SysV_Destroy;
-    res->p[0].p_pixels = shm;
-    return 0;
-}
-#else
-# define XCB_picture_SysV_Alloc(...) (-1)
-#endif
-
-static void XCB_picture_Destroy(picture_t *pic)
-{
-    free(pic->p[0].p_pixels);
-}
-
-/**
- * Initialize a picture buffer as shared memory, according to the video output
- * format. If a attach is true, the segment is attached to
- * the X server (MIT-SHM extension).
- */
-int XCB_picture_Alloc (vout_display_t *vd, picture_resource_t *res,
-                       size_t size, xcb_connection_t *conn,
-                       xcb_shm_seg_t segment)
-{
-    if (XCB_picture_SysV_Alloc(vd, res, size, conn, segment) == 0)
-        return 0;
-
-    void *shm = aligned_alloc(32, (size + 31) & ~31);
-    if (unlikely(shm == NULL))
-        return -1;
-
-    res->p_sys = NULL;
-    res->pf_destroy = XCB_picture_Destroy;
-    res->p[0].p_pixels = shm;
-    return 0;
-}
-
-picture_t *XCB_picture_NewFromResource (const video_format_t *restrict fmt,
-                                        const picture_resource_t *restrict res,
-                                        xcb_connection_t *conn)
-{
-    picture_t *pic = picture_NewFromResource (fmt, res);
-    if (unlikely(pic == NULL))
-    {
-        xcb_shm_seg_t seg = (uintptr_t)res->p_sys;
-
-        if (seg != 0)
-            xcb_shm_detach (conn, seg);
-        shmdt (res->p[0].p_pixels);
-    }
-    return pic;
-}
diff --git a/modules/video_output/xcb/pictures.h b/modules/video_output/xcb/pictures.h
index 3e58abef6a..766dc7ef13 100644
--- a/modules/video_output/xcb/pictures.h
+++ b/modules/video_output/xcb/pictures.h
@@ -29,9 +29,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <xcb/xcb.h>
-#include <xcb/shm.h>
 #include <vlc_picture.h>
-#include <vlc_vout_display.h>
 
 const xcb_format_t *vlc_xcb_DepthToPixmapFormat(const xcb_setup_t *,
                                                 uint_fast8_t depth);
@@ -39,13 +37,3 @@ bool vlc_xcb_VisualToFormat(const xcb_setup_t *, uint_fast8_t depth,
                             const xcb_visualtype_t *, video_format_t *);
 
 bool XCB_shm_Check (vlc_object_t *obj, xcb_connection_t *conn);
-int XCB_picture_Alloc (vout_display_t *, picture_resource_t *, size_t size,
-                       xcb_connection_t *, xcb_shm_seg_t);
-picture_t *XCB_picture_NewFromResource (const video_format_t *,
-                                        const picture_resource_t *,
-                                        xcb_connection_t *);
-
-static inline xcb_shm_seg_t XCB_picture_GetSegment(const picture_t *pic)
-{
-    return (uintptr_t)pic->p_sys;
-}
-- 
2.17.1



More information about the vlc-devel mailing list