From: RĂ©mi Denis-Courmont Date: Thu, 16 Apr 2009 17:59:46 +0000 (+0300) Subject: Factor SHM and non SHM pictures a little X-Git-Tag: 1.0.0-pre2~15 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b87b85154479ddc7fe05f93cc5c9e642a8d772ec;p=vlc Factor SHM and non SHM pictures a little --- diff --git a/modules/video_output/xcb/xcb.c b/modules/video_output/xcb/xcb.c index e3dd91aa22..99520d99b5 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,28 +381,21 @@ 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); free (p_sys); } -/** - * 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. */ @@ -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);