[vlc-devel] commit: Factor SHM and non SHM pictures a little ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Apr 16 20:00:54 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Apr 16 20:59:46 2009 +0300| [b87b85154479ddc7fe05f93cc5c9e642a8d772ec] | committer: Rémi Denis-Courmont 

Factor SHM and non SHM pictures a little

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b87b85154479ddc7fe05f93cc5c9e642a8d772ec
---

 modules/video_output/xcb/xcb.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/modules/video_output/xcb/xcb.c b/modules/video_output/xcb/xcb.c
index e3dd91a..99520d9 100644
--- a/modules/video_output/xcb/xcb.c
+++ b/modules/video_output/xcb/xcb.c
@@ -280,8 +280,6 @@ struct picture_sys_t
     xcb_shm_seg_t segment; /* Shared memory segment X ID */
 };
 
-static void PictureRelease (picture_t *pic);
-static void PictureShmRelease (picture_t *pic);
 #define SHM_ERR ((void *)(intptr_t)(-1))
 
 static int PictureInit (vout_thread_t *vout, picture_t *pic)
@@ -333,6 +331,8 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic)
             shm = SHM_ERR;
         }
     }
+    else
+        priv->segment = 0;
 
     const unsigned real_width = pic->p->i_pitch / (p_sys->bpp >> 3);
     /* FIXME: anyway to getthing more intuitive than that?? */
@@ -366,8 +366,6 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic)
     priv->native = NULL;
     pic->p_sys = priv;
     pic->p->p_pixels = img->data;
-    pic->pf_release = (shm != SHM_ERR) ? PictureShmRelease
-                                       : PictureRelease;
     pic->i_status = DESTROYED_PICTURE;
     pic->i_type = DIRECT_PICTURE;
     return VLC_SUCCESS;
@@ -383,10 +381,15 @@ error:
 /**
  * Release picture private data
  */
-static void PictureRelease (picture_t *pic)
+static void PictureDeinit (picture_t *pic)
 {
     struct picture_sys_t *p_sys = pic->p_sys;
 
+    if (p_sys->segment != 0)
+    {
+        xcb_shm_detach (p_sys->conn, p_sys->segment);
+        shmdt (p_sys->image->data);
+    }
     if ((p_sys->native != NULL) && (p_sys->native != p_sys->image))
         xcb_image_destroy (p_sys->native);
     xcb_image_destroy (p_sys->image);
@@ -394,18 +397,6 @@ static void PictureRelease (picture_t *pic)
 }
 
 /**
- * Release shared memory picture private data
- */
-static void PictureShmRelease (picture_t *pic)
-{
-    struct picture_sys_t *p_sys = pic->p_sys;
-
-    xcb_shm_detach (p_sys->conn, p_sys->segment);
-    shmdt (p_sys->image->data);
-    PictureRelease (pic);
-}
-
-/**
  * Allocate drawable window and picture buffers.
  */
 static int Init (vout_thread_t *vout)
@@ -518,7 +509,7 @@ static void Deinit (vout_thread_t *vout)
     vout_sys_t *p_sys = vout->p_sys;
 
     while (I_OUTPUTPICTURES > 0)
-        picture_Release (PP_OUTPUTPICTURE[--I_OUTPUTPICTURES]);
+        PictureDeinit (PP_OUTPUTPICTURE[--I_OUTPUTPICTURES]);
 
     xcb_unmap_window (p_sys->conn, p_sys->window);
     xcb_destroy_window (p_sys->conn, p_sys->window);




More information about the vlc-devel mailing list