[vlc-devel] [PATCH 1/4] video_output: don't let the display module deal with picture release
Steve Lhomme
robux4 at ycbcr.xyz
Fri Oct 26 11:33:10 CEST 2018
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.
---
include/vlc_vout_display.h | 3 ---
modules/hw/mmal/vout.c | 7 +------
modules/hw/vdpau/display.c | 9 ++-------
modules/video_output/android/display.c | 6 +-----
modules/video_output/caca.c | 2 +-
modules/video_output/caopengllayer.m | 7 ++-----
modules/video_output/decklink.cpp | 2 +-
modules/video_output/fb.c | 1 -
modules/video_output/flaschen.c | 2 --
modules/video_output/ios.m | 7 ++-----
modules/video_output/kms.c | 2 +-
modules/video_output/kva.c | 2 +-
modules/video_output/macosx.m | 6 ++----
modules/video_output/opengl/display.c | 6 ++----
modules/video_output/vdummy.c | 3 +--
modules/video_output/vmem.c | 2 +-
modules/video_output/win32/direct3d11.c | 6 ++----
modules/video_output/win32/direct3d9.c | 10 ++--------
modules/video_output/win32/directdraw.c | 1 -
modules/video_output/win32/glwin32.c | 6 ++----
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 | 3 +++
26 files changed, 29 insertions(+), 71 deletions(-)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 21168a1db47..0ffdbcbfadb 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 03b4a6d34a5..2a83045522c 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,15 +591,10 @@ static void vd_display(vout_display_t *vd, picture_t *picture,
}
pic_sys->displayed = true;
- } else {
- picture_Release(picture);
}
display_subpicture(vd, subpicture);
- if (subpicture)
- subpicture_Delete(subpicture);
-
if (sys->next_phase_check == 0 && sys->adjust_refresh_rate)
maintain_phase_sync(vd);
sys->next_phase_check = (sys->next_phase_check + 1) % PHASE_CHECK_INTERVAL;
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index 5e0536be566..a249b0b3ae6 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -294,6 +294,7 @@ static void Queue(vout_display_t *vd, picture_t *pic, subpicture_t *subpic,
static void Wait(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
+ VLC_UNUSED(subpicture);
picture_t *current = sys->current;
if (current != NULL)
@@ -308,19 +309,13 @@ 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 */
- if (subpicture)
- subpicture_Delete(subpicture);
-
/* Drain the event queue. TODO: remove sys->conn completely */
xcb_generic_event_t *ev;
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 8bd26431d3c..961c4c569ca 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -1004,20 +1004,16 @@ static void Display(vout_display_t *vd, picture_t *picture,
subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
+ VLC_UNUSED(subpicture);
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);
- if (subpicture)
- subpicture_Delete(subpicture);
-
sys->b_displayed = true;
}
diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c
index dc1a06d6baa..201bf01f115 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 1b9c2724b9c..09632c39115 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -298,6 +298,8 @@ 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);
+ VLC_UNUSED(subpicture);
@synchronized (sys->cgLayer) {
sys->b_frame_available = YES;
@@ -308,11 +310,6 @@ static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *su
[sys->cgLayer display];
[CATransaction flush];
}
-
- picture_Release(pic);
-
- if (subpicture)
- subpicture_Delete(subpicture);
}
static int Control (vout_display_t *vd, int query, va_list ap)
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 054aed28898..8da517d2575 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 c26492f477e..d9a2998b589 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 28f15e6c1d3..59705d33886 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 ed20827884d..975db62043e 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -301,17 +301,14 @@ 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);
+ VLC_UNUSED(subpicture);
if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
{
vout_display_opengl_Display(glsys->vgl, &vd->source);
vlc_gl_ReleaseCurrent(sys->gl);
}
-
- picture_Release(pic);
-
- if (subpicture)
- subpicture_Delete(subpicture);
}
static void PictureRender(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture,
diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index da4153273ad..a81fa6a7fd4 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 d97a4ea4e1e..cec89d1f142 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 359836a8eae..767d9dd6601 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -334,6 +334,8 @@ 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);
+ VLC_UNUSED(subpicture);
[sys->glView setVoutFlushing:YES];
if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
{
@@ -341,11 +343,7 @@ 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)
- subpicture_Delete(subpicture);
}
static int Control (vout_display_t *vd, int query, va_list ap)
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index d0ae442196f..eb53105c55d 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -208,16 +208,14 @@ 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);
+ VLC_UNUSED(subpicture);
if (vlc_gl_MakeCurrent (sys->gl) == VLC_SUCCESS)
{
vout_display_opengl_Display (sys->vgl, &vd->source);
vlc_gl_ReleaseCurrent (sys->gl);
}
-
- picture_Release (pic);
- if (subpicture != NULL)
- subpicture_Delete(subpicture);
}
static int Control (vout_display_t *vd, int query, va_list ap)
diff --git a/modules/video_output/vdummy.c b/modules/video_output/vdummy.c
index 1a13e354687..a4fdc796d4f 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 7edf2974f0a..469e05bbf49 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 147e71f1a53..d2ce80a22e4 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -971,6 +971,8 @@ 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);
+ VLC_UNUSED(subpicture);
DXGI_PRESENT_PARAMETERS presentParams;
memset(&presentParams, 0, sizeof(presentParams));
@@ -983,10 +985,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
}
d3d11_device_unlock( &sys->d3d_dev );
- picture_Release(picture);
- if (subpicture)
- subpicture_Delete(subpicture);
-
CommonDisplay(vd);
}
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index d3def818683..2705df0074b 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -582,13 +582,10 @@ 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);
+ if (sys->lost_not_ready)
return;
- }
// Present the back buffer contents to the display
// No stretching should happen here !
@@ -608,9 +605,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);
CommonDisplay(vd);
}
diff --git a/modules/video_output/win32/directdraw.c b/modules/video_output/win32/directdraw.c
index 121c0563e93..f374cad2a5e 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 6427ccf6584..681232667d2 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -231,6 +231,8 @@ 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);
+ VLC_UNUSED(subpicture);
if (vlc_gl_MakeCurrent (sys->gl) == VLC_SUCCESS)
{
@@ -238,10 +240,6 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
vlc_gl_ReleaseCurrent (sys->gl);
}
- picture_Release(picture);
- if (subpicture)
- subpicture_Delete(subpicture);
-
CommonDisplay(vd);
}
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index c13f9ddd2db..fdde155a520 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 2541cc4dffb..3bd07d534d4 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 6aa5c5e164f..e55ce94f9cf 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 4b6c0997d50..40b058c9aa4 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 43f7866505c..6956a81ce09 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 552e890bbb6..2cb0681d8fc 100644
--- a/src/video_output/vout_wrapper.h
+++ b/src/video_output/vout_wrapper.h
@@ -56,6 +56,9 @@ static inline void vout_display_Display(vout_display_t *vd,
subpicture_t *subpicture)
{
vd->display(vd, picture, subpicture);
+ picture_Release(picture);
+ if (subpicture)
+ subpicture_Delete(subpicture);
}
/**
--
2.17.1
More information about the vlc-devel
mailing list