[vlc-commits] video_output: don't let the display module deal with picture release

Steve Lhomme git at videolan.org
Sat Oct 27 08:35:55 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 26 09:54:11 2018 +0200| [dc8447355f99243d6f225eeae73aabc0fa7b4c35] | committer: Steve Lhomme

video_output: don't let the display module deal with picture release

All the modules have to do this boilerplate code, some potentially not
releasing the subpicture.
Only VDPAU and MMAL hold a reference on the picture after Display is called.

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

 include/vlc_vout_display.h              | 3 ---
 modules/hw/mmal/vout.c                  | 4 +---
 modules/hw/vdpau/display.c              | 3 +--
 modules/video_output/android/display.c  | 3 +--
 modules/video_output/caca.c             | 2 +-
 modules/video_output/caopengllayer.m    | 3 +--
 modules/video_output/decklink.cpp       | 2 +-
 modules/video_output/fb.c               | 1 -
 modules/video_output/flaschen.c         | 2 --
 modules/video_output/ios.m              | 3 +--
 modules/video_output/kms.c              | 2 +-
 modules/video_output/kva.c              | 2 +-
 modules/video_output/macosx.m           | 2 +-
 modules/video_output/opengl/display.c   | 4 ++--
 modules/video_output/vdummy.c           | 3 +--
 modules/video_output/vmem.c             | 2 +-
 modules/video_output/win32/direct3d11.c | 3 +--
 modules/video_output/win32/direct3d9.c  | 3 +--
 modules/video_output/win32/directdraw.c | 1 -
 modules/video_output/win32/glwin32.c    | 3 +--
 modules/video_output/win32/wingdi.c     | 2 +-
 modules/video_output/xcb/x11.c          | 1 -
 modules/video_output/xcb/xvideo.c       | 1 -
 modules/video_output/yuv.c              | 1 -
 src/video_output/display.c              | 2 +-
 src/video_output/vout_wrapper.h         | 1 +
 26 files changed, 20 insertions(+), 39 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 21168a1db4..0ffdbcbfad 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -276,9 +276,6 @@ struct vout_display_t {
      * possible.
      * You cannot change the pixel content of the picture_t or of the
      * subpicture_t.
-     *
-     * This function gives away the ownership of the picture and of the
-     * subpicture, so you must release them as soon as possible.
      */
     void       (*display)(vout_display_t *, picture_t *, subpicture_t *);
 
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index 03b4a6d34a..b9ca560eeb 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -579,7 +579,7 @@ static void vd_display(vout_display_t *vd, picture_t *picture,
     if (!pic_sys->displayed || !sys->opaque) {
         buffer->cmd = 0;
         buffer->length = sys->input->buffer_size;
-        buffer->user_data = picture;
+        buffer->user_data = picture_Hold(picture);
 
         status = mmal_port_send_buffer(sys->input, buffer);
         if (status == MMAL_SUCCESS)
@@ -591,8 +591,6 @@ static void vd_display(vout_display_t *vd, picture_t *picture,
         }
 
         pic_sys->displayed = true;
-    } else {
-        picture_Release(picture);
     }
 
     display_subpicture(vd, subpicture);
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index 5e0536be56..f470c47b40 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -308,13 +308,12 @@ static void Wait(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
         {
             msg_Err(vd, "presentation queue blocking error: %s",
                     vdp_get_error_string(sys->vdp, err));
-            picture_Release(pic);
             goto out;
         }
         picture_Release(current);
     }
 
-    sys->current = pic;
+    sys->current = picture_Hold(pic);
 out:
     /* We already dealt with the subpicture in the Queue phase, so it's safe to
        delete at this point */
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 8bd26431d3..9c5e51ffc3 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -1004,14 +1004,13 @@ static void Display(vout_display_t *vd, picture_t *picture,
                     subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(picture);
 
     if (sys->p_window->b_opaque)
         AndroidOpaquePicture_Release(picture->p_sys, true);
     else
         AndroidWindow_UnlockPicture(sys, sys->p_window, picture);
 
-    picture_Release(picture);
-
     if (sys->p_sub_pic)
         AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic);
 
diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c
index dc1a06d6ba..201bf01f11 100644
--- a/modules/video_output/caca.c
+++ b/modules/video_output/caca.c
@@ -180,7 +180,7 @@ static void PictureDisplay(vout_display_t *vd, picture_t *picture, subpicture_t
     vout_display_sys_t *sys = vd->sys;
 
     caca_refresh_display(sys->dp);
-    picture_Release(picture);
+    VLC_UNUSED(picture);
     VLC_UNUSED(subpicture);
 }
 
diff --git a/modules/video_output/caopengllayer.m b/modules/video_output/caopengllayer.m
index 1b9c2724b9..c49f967264 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -298,6 +298,7 @@ static void PictureRender (vout_display_t *vd, picture_t *pic, subpicture_t *sub
 static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(pic);
 
     @synchronized (sys->cgLayer) {
         sys->b_frame_available = YES;
@@ -309,8 +310,6 @@ static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *su
         [CATransaction flush];
     }
 
-    picture_Release(pic);
-
     if (subpicture)
         subpicture_Delete(subpicture);
 }
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 054aed2889..8da517d257 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -1026,7 +1026,7 @@ end:
 
 static void DisplayVideo(vout_display_t *, picture_t *picture, subpicture_t *)
 {
-    picture_Release(picture);
+    VLC_UNUSED(picture);
 }
 
 static int ControlVideo(vout_display_t *vd, int query, va_list args)
diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c
index c26492f477..d9a2998b58 100644
--- a/modules/video_output/fb.c
+++ b/modules/video_output/fb.c
@@ -379,7 +379,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
     if (!sys->is_hw_accel)
         picture_Copy(sys->picture, picture);
 
-    picture_Release(picture);
     VLC_UNUSED(subpicture);
 }
 static int Control(vout_display_t *vd, int query, va_list args)
diff --git a/modules/video_output/flaschen.c b/modules/video_output/flaschen.c
index 28f15e6c1d..59705d3388 100644
--- a/modules/video_output/flaschen.c
+++ b/modules/video_output/flaschen.c
@@ -219,8 +219,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
     else if (result < (int)(header_len + vd->fmt.i_width * vd->fmt.i_height * 3))
         msg_Err(vd, "sendmsg only sent %d bytes in vout display flaschen", result);
         /* we might want to drop some frames? */
-
-    picture_Release(picture);
 }
 
 /**
diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index ed20827884..d7aa392a04 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -301,6 +301,7 @@ static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *sub
 {
     vout_display_sys_t *sys = vd->sys;
     struct gl_sys *glsys = sys->gl->sys;
+    VLC_UNUSED(pic);
 
     if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
     {
@@ -308,8 +309,6 @@ static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *sub
         vlc_gl_ReleaseCurrent(sys->gl);
     }
 
-    picture_Release(pic);
-
     if (subpicture)
         subpicture_Delete(subpicture);
 }
diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index da4153273a..a81fa6a7fd 100644
--- a/modules/video_output/kms.c
+++ b/modules/video_output/kms.c
@@ -653,6 +653,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
 static void Display(vout_display_t *vd, picture_t *picture,
                     subpicture_t *subpicture)
 {
+    VLC_UNUSED(picture);
     VLC_UNUSED(subpicture);
     vout_display_sys_t *sys = vd->sys;
     int i;
@@ -672,7 +673,6 @@ static void Display(vout_display_t *vd, picture_t *picture,
             sys->picture->p[i].p_pixels =
                     sys->map[sys->front_buf]+sys->offsets[i];
     }
-    picture_Release(picture);
 }
 
 
diff --git a/modules/video_output/kva.c b/modules/video_output/kva.c
index d97a4ea4e1..cec89d1f14 100644
--- a/modules/video_output/kva.c
+++ b/modules/video_output/kva.c
@@ -385,7 +385,7 @@ static void Display( vout_display_t *vd, picture_t *picture,
     vout_display_sys_t * sys = vd->sys;
 
     VLC_UNUSED( subpicture );
-    picture_Release( picture );
+    VLC_UNUSED( picture );
 
     /* Let a window procedure manage instead because if resizing a frame window
      * here, WM_SIZE is not sent to its child window.
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 359836a8ea..93172ac95c 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -334,6 +334,7 @@ static void PictureRender (vout_display_t *vd, picture_t *pic, subpicture_t *sub
 static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(pic);
     [sys->glView setVoutFlushing:YES];
     if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
     {
@@ -341,7 +342,6 @@ static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *su
         vlc_gl_ReleaseCurrent(sys->gl);
     }
     [sys->glView setVoutFlushing:NO];
-    picture_Release (pic);
     sys->has_first_frame = true;
 
     if (subpicture)
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index d0ae442196..a0dd3f74c3 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -208,6 +208,7 @@ static void PictureRender (vout_display_t *vd, picture_t *pic, subpicture_t *sub
 static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(pic);
 
     if (vlc_gl_MakeCurrent (sys->gl) == VLC_SUCCESS)
     {
@@ -215,8 +216,7 @@ static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *su
         vlc_gl_ReleaseCurrent (sys->gl);
     }
 
-    picture_Release (pic);
-    if (subpicture != NULL)
+    if (subpicture)
         subpicture_Delete(subpicture);
 }
 
diff --git a/modules/video_output/vdummy.c b/modules/video_output/vdummy.c
index 1a13e35468..a4fdc796d4 100644
--- a/modules/video_output/vdummy.c
+++ b/modules/video_output/vdummy.c
@@ -138,7 +138,7 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
 {
     VLC_UNUSED(vd);
     VLC_UNUSED(subpicture);
-    picture_Release(picture);
+    VLC_UNUSED(picture);
 }
 
 static void DisplayStat(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
@@ -155,7 +155,6 @@ static void DisplayStat(vout_display_t *vd, picture_t *picture, subpicture_t *su
         msg_Dbg(vd, "VOUT got %"PRIu64" ms offset",
                 MS_FROM_VLC_TICK(vlc_tick_now() - date));
     }
-    picture_Release(picture);
 }
 
 static int Control(vout_display_t *vd, int query, va_list args)
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index 7edf2974f0..469e05bbf4 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -271,11 +271,11 @@ static void Prepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpic,
 static void Display(vout_display_t *vd, picture_t *pic, subpicture_t *subpic)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(pic);
 
     if (sys->display != NULL)
         sys->display(sys->opaque, sys->pic_opaque);
 
-    picture_Release(pic);
     VLC_UNUSED(subpic);
 }
 
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 147e71f1a5..d4e0fcc24c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -971,6 +971,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(picture);
 
     DXGI_PRESENT_PARAMETERS presentParams;
     memset(&presentParams, 0, sizeof(presentParams));
@@ -982,8 +983,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
         msg_Err(vd, "SwapChain Present failed. (hr=0x%lX)", hr);
     }
     d3d11_device_unlock( &sys->d3d_dev );
-
-    picture_Release(picture);
     if (subpicture)
         subpicture_Delete(subpicture);
 
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index d3def81868..43f9a10601 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -582,9 +582,9 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
 {
     vout_display_sys_t *sys = vd->sys;
     const d3d9_device_t *p_d3d9_dev = &sys->d3d_dev;
+    VLC_UNUSED(subpicture);
 
     if (sys->lost_not_ready) {
-        picture_Release(picture);
         if (subpicture)
             subpicture_Delete(subpicture);
         return;
@@ -608,7 +608,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
     /* XXX See Prepare() */
     if ( !is_d3d9_opaque(picture->format.i_chroma) )
         Direct3D9LockSurface(picture);
-    picture_Release(picture);
     if (subpicture)
         subpicture_Delete(subpicture);
 
diff --git a/modules/video_output/win32/directdraw.c b/modules/video_output/win32/directdraw.c
index 121c0563e9..f374cad2a5 100644
--- a/modules/video_output/win32/directdraw.c
+++ b/modules/video_output/win32/directdraw.c
@@ -338,7 +338,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
     }
     CommonDisplay(vd);
 
-    picture_Release(picture);
     VLC_UNUSED(subpicture);
 
     Manage(vd);
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index 6427ccf658..2740debf5f 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -231,14 +231,13 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(picture);
 
     if (vlc_gl_MakeCurrent (sys->gl) == VLC_SUCCESS)
     {
         vout_display_opengl_Display (sys->vgl, &vd->source);
         vlc_gl_ReleaseCurrent (sys->gl);
     }
-
-    picture_Release(picture);
     if (subpicture)
         subpicture_Delete(subpicture);
 
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index c13f9ddd2d..fdde155a52 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -147,6 +147,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(picture);
 
 #define rect_src vd->sys->rect_src
 #define rect_src_clipped vd->sys->sys.rect_src_clipped
@@ -182,7 +183,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
 #undef rect_dest
 #undef rect_dest_clipped
     /* TODO */
-    picture_Release(picture);
     VLC_UNUSED(subpicture);
 
     CommonDisplay(vd);
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index 2541cc4dff..3bd07d534d 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -440,7 +440,6 @@ static void Display (vout_display_t *vd, picture_t *pic, subpicture_t *subpictur
      * VOUT_DISPLAY_RESET_PICTURES if done) + does not work with
      * vout_display wrapper. */
 out:
-    picture_Release (pic);
     (void)subpicture;
 }
 
diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/xcb/xvideo.c
index 6aa5c5e164..e55ce94f9c 100644
--- a/modules/video_output/xcb/xvideo.c
+++ b/modules/video_output/xcb/xvideo.c
@@ -700,7 +700,6 @@ static void Display (vout_display_t *vd, picture_t *pic, subpicture_t *subpictur
         free (e);
     }
 out:
-    picture_Release (pic);
     (void)subpicture;
 }
 
diff --git a/modules/video_output/yuv.c b/modules/video_output/yuv.c
index 4b6c0997d5..40b058c9aa 100644
--- a/modules/video_output/yuv.c
+++ b/modules/video_output/yuv.c
@@ -264,7 +264,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
     fflush(sys->f);
 
     /* */
-    picture_Release(picture);
     VLC_UNUSED(subpicture);
 }
 
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 43f7866505..6956a81ce0 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -1085,13 +1085,13 @@ static void SplitterDisplay(vout_display_t *vd,
                             subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
+    VLC_UNUSED(picture);
 
     assert(!subpicture);
     for (int i = 0; i < sys->count; i++) {
         if (sys->picture[i])
             vout_display_Display(sys->display[i], sys->picture[i], NULL);
     }
-    picture_Release(picture);
 }
 static int SplitterControl(vout_display_t *vd, int query, va_list args)
 {
diff --git a/src/video_output/vout_wrapper.h b/src/video_output/vout_wrapper.h
index 552e890bbb..d560549efc 100644
--- a/src/video_output/vout_wrapper.h
+++ b/src/video_output/vout_wrapper.h
@@ -56,6 +56,7 @@ static inline void vout_display_Display(vout_display_t *vd,
                                         subpicture_t *subpicture)
 {
     vd->display(vd, picture, subpicture);
+    picture_Release(picture);
 }
 
 /**



More information about the vlc-commits mailing list