[vlc-devel] [PATCH 24/24] vout: change "vout display" activate/deactivate callbacks.
Thomas Guillem
thomas at gllm.fr
Wed Oct 31 17:50:19 CET 2018
Pass, vd, cfg, fmtp and video_context (that will be used for the future VOUT
push model).
During the transition, vd->cfg and vd->fmt are still valid (but they will be
removed).
vd->fmt is only used directly from the pf_pool callback. This callback will be
removed too.
---
include/vlc_vout_display.h | 23 ++++++++++++++++++++
modules/hw/mmal/vout.c | 14 ++++++-------
modules/hw/vdpau/display.c | 19 ++++++++---------
modules/video_output/android/display.c | 29 ++++++++++++--------------
modules/video_output/caopengllayer.m | 16 +++++++-------
modules/video_output/fb.c | 19 ++++++++---------
modules/video_output/flaschen.c | 14 ++++++-------
modules/video_output/ios.m | 25 +++++++++++-----------
modules/video_output/kms.c | 28 ++++++++-----------------
modules/video_output/macosx.m | 21 +++++++++----------
modules/video_output/opengl/display.c | 15 +++++++------
modules/video_output/vdummy.c | 27 +++++++++++++-----------
modules/video_output/vmem.c | 14 ++++++-------
modules/video_output/wayland/shm.c | 11 ++++------
modules/video_output/xcb/x11.c | 21 +++++++++----------
modules/video_output/xcb/xvideo.c | 18 ++++++++--------
modules/video_output/yuv.c | 14 ++++++-------
src/video_output/display.c | 26 +++++++++++++++--------
18 files changed, 182 insertions(+), 172 deletions(-)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index a3285dc8bb..39f8a12306 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -208,6 +208,29 @@ struct vout_display_owner_t {
void (*event)(vout_display_t *, int, va_list);
};
+/**
+ * "vout display" open callback
+ *
+ * @param vd vout display context
+ * @param cfg Initial and current configuration.
+ * @param fmtp By default, it is equal to vd->source except for the aspect
+ * ratio which is undefined(0) and is ignored. It can be changed by the module
+ * to request a different format.
+ * @param context XXX: to be defined.
+ * @return VLC_SUCCESS or a VLC error code
+ */
+typedef int (*vout_display_open_cb)(vout_display_t *vd,
+ const vout_display_cfg_t *cfg,
+ video_format_t *fmtp,
+ vlc_video_context *context);
+
+/**
+ * "vout display" close callback
+ *
+ * @param vd vout display context
+ */
+typedef int (*vout_display_close_cb)(vout_display_t *vd);
+
struct vout_display_t {
struct vlc_common_members obj;
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index 75080a0546..2a19556b4c 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -68,8 +68,9 @@
#define PHASE_OFFSET_TARGET ((double)0.25)
#define PHASE_CHECK_INTERVAL 100
-static int Open(vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin()
set_shortname(N_("MMAL vout"))
@@ -181,11 +182,9 @@ static void dmx_region_delete(struct dmx_region_t *dmx_region,
static void show_background(vout_display_t *vd, bool enable);
static void maintain_phase_sync(vout_display_t *vd);
-static int Open(vlc_object_t *object)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)object;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmt = &vd->fmt;
vout_display_sys_t *sys;
uint32_t buffer_pitch, buffer_height;
vout_display_place_t place;
@@ -322,10 +321,11 @@ out:
if (ret != VLC_SUCCESS)
Close(object);
+ (void) context;
return ret;
}
-static void Close(vlc_object_t *object)
+static void Close(vout_display_t *vd)
{
vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys = vd->sys;
diff --git a/modules/hw/vdpau/display.c b/modules/hw/vdpau/display.c
index 7e5548ffc5..447b0499f1 100644
--- a/modules/hw/vdpau/display.c
+++ b/modules/hw/vdpau/display.c
@@ -38,8 +38,9 @@
#include "vlc_vdpau.h"
#include "events.h"
-static int Open(vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin()
set_shortname(N_("VDPAU"))
@@ -411,14 +412,12 @@ static int xcb_screen_num(xcb_connection_t *conn, const xcb_screen_t *screen)
return -1;
}
-static int Open(vlc_object_t *obj)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- if (!vlc_xlib_init(obj))
+ if (!vlc_xlib_init(VLC_OBJECT(vd)))
return VLC_EGENERIC;
- vout_display_t *vd = (vout_display_t *)obj;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys = malloc(sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -436,7 +435,7 @@ static int Open(vlc_object_t *obj)
&sys->vdp, &sys->device);
if (err != VDP_STATUS_OK)
{
- msg_Dbg(obj, "device creation failure: error %d", (int)err);
+ msg_Dbg(vd, "device creation failure: error %d", (int)err);
xcb_disconnect(sys->conn);
free(sys);
return VLC_EGENERIC;
@@ -654,6 +653,7 @@ static int Open(vlc_object_t *obj)
vd->display = Wait;
vd->control = Control;
+ (void) context;
return VLC_SUCCESS;
error:
@@ -663,9 +663,8 @@ error:
return VLC_EGENERIC;
}
-static void Close(vlc_object_t *obj)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)obj;
vout_display_sys_t *sys = vd->sys;
vdp_presentation_queue_destroy(sys->vdp, sys->queue);
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index 3b9694fb08..2cb5b0d6ca 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -51,9 +51,11 @@
"Force use of a specific chroma for output. Default is RGB32."
#define CFG_PREFIX "android-display-"
-static int Open (vlc_object_t *);
-static int OpenOpaque (vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static int OpenOpaque(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
static void SubpicturePrepare(vout_display_t *vd, subpicture_t *subpicture);
vlc_module_begin()
@@ -607,16 +609,13 @@ static int OpenCommon(vout_display_t *vd, const vout_display_cfg_t *cfg,
return VLC_SUCCESS;
error:
- Close(VLC_OBJECT(vd));
+ Close(vd);
return VLC_EGENERIC;
}
-static int Open(vlc_object_t *p_this)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t*)p_this;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
-
if (fmtp->i_chroma == VLC_CODEC_ANDROID_OPAQUE)
return VLC_EGENERIC;
@@ -625,15 +624,13 @@ static int Open(vlc_object_t *p_this)
* 2. gles2 vout failed */
fmtp->projection_mode = PROJECTION_MODE_RECTANGULAR;
+ (void) context;
return OpenCommon(vd, cfg, fmtp);
}
-static int OpenOpaque(vlc_object_t *p_this)
+static int OpenOpaque(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t*)p_this;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
-
if (fmtp->i_chroma != VLC_CODEC_ANDROID_OPAQUE)
return VLC_EGENERIC;
@@ -645,6 +642,7 @@ static int OpenOpaque(vlc_object_t *p_this)
return VLC_EGENERIC;
}
+ (void) context;
return OpenCommon(vd, cfg, fmtp);
}
@@ -690,9 +688,8 @@ end:
}
}
-static void Close(vlc_object_t *p_this)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)p_this;
vout_display_sys_t *sys = vd->sys;
/* Check if SPU regions have been properly cleared, and clear them if they
diff --git a/modules/video_output/caopengllayer.m b/modules/video_output/caopengllayer.m
index d821d40a5b..8170b2d0de 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -48,8 +48,9 @@
/*****************************************************************************
* Vout interface
*****************************************************************************/
-static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin()
set_description(N_("Core Animation OpenGL Layer (Mac OS X)"))
@@ -110,11 +111,9 @@ struct gl_sys
/*****************************************************************************
* Open: This function allocates and initializes the OpenGL vout method.
*****************************************************************************/
-static int Open (vlc_object_t *p_this)
+static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)p_this;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmt = &vd->fmt;
vout_display_sys_t *sys;
if (cfg->window->type != VOUT_WINDOW_TYPE_NSOBJECT)
@@ -225,14 +224,13 @@ static int Open (vlc_object_t *p_this)
return VLC_SUCCESS;
bailout:
- Close(p_this);
+ Close(vd);
return VLC_EGENERIC;
}
}
-static void Close (vlc_object_t *p_this)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)p_this;
vout_display_sys_t *sys = vd->sys;
if (sys->cgLayer) {
diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c
index f3da704840..38b7974cbf 100644
--- a/modules/video_output/fb.c
+++ b/modules/video_output/fb.c
@@ -73,8 +73,9 @@
#define CHROMA_TEXT N_("Image format (default RGB)")
#define CHROMA_LONGTEXT N_("Chroma fourcc used by the framebuffer. Default is RGB since the fb device has no way to report its chroma.")
-static int Open (vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin ()
set_shortname("Framebuffer")
@@ -170,11 +171,9 @@ static void ClearScreen(vout_display_sys_t *sys)
/**
* This function allocates and initializes a FB vout method.
*/
-static int Open(vlc_object_t *object)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)object;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
if (vout_display_cfg_IsWindowed(cfg))
@@ -252,7 +251,7 @@ static int Open(vlc_object_t *object)
sys->pool = NULL;
if (OpenDisplay(vd, force_resolution)) {
- Close(VLC_OBJECT(vd));
+ Close(vd);
return VLC_EGENERIC;
}
@@ -284,7 +283,7 @@ static int Open(vlc_object_t *object)
break;
default:
msg_Err(vd, "unknown screendepth %i", sys->var_info.bits_per_pixel);
- Close(VLC_OBJECT(vd));
+ Close(vd);
return VLC_EGENERIC;
}
if (sys->var_info.bits_per_pixel != 8) {
@@ -307,15 +306,15 @@ static int Open(vlc_object_t *object)
vd->display = Display;
vd->control = Control;
+ (void) context;
return VLC_SUCCESS;
}
/**
* Terminate an output method created by Open
*/
-static void Close(vlc_object_t *object)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys = vd->sys;
if (sys->pool)
diff --git a/modules/video_output/flaschen.c b/modules/video_output/flaschen.c
index 565b88c894..a87d8ed103 100644
--- a/modules/video_output/flaschen.c
+++ b/modules/video_output/flaschen.c
@@ -54,8 +54,9 @@
#define T_HEIGHT N_("Height")
#define LT_HEIGHT N_("Video height")
-static int Open( vlc_object_t * );
-static void Close( vlc_object_t * );
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin ()
set_shortname( N_("Flaschen") )
@@ -87,10 +88,9 @@ static int Control(vout_display_t *, int, va_list);
/*****************************************************************************
* Open: activates flaschen vout display method
*****************************************************************************/
-static int Open(vlc_object_t *object)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)object;
- video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
int fd;
const unsigned port = 1337;
@@ -148,12 +148,12 @@ static int Open(vlc_object_t *object)
vd->display = Display;
vd->control = Control;
+ (void) cfg; (void) context;
return VLC_SUCCESS;
}
-static void Close(vlc_object_t *object)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys = vd->sys;
if (sys->pool)
diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index cfb7840134..45041bfb3a 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -30,11 +30,13 @@
* Preamble
*****************************************************************************/
+#if 0
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <QuartzCore/QuartzCore.h>
+#endif
#import <dlfcn.h>
#ifdef HAVE_CONFIG_H
@@ -51,8 +53,9 @@
/**
* Forward declarations
*/
-static int Open(vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context);
+static void Close(vout_display_t *vd);
static picture_pool_t* PicturePool(vout_display_t *, unsigned);
static void PictureRender(vout_display_t *, picture_t *, subpicture_t *, vlc_tick_t);
@@ -142,12 +145,9 @@ static void *OurGetProcAddress(vlc_gl_t *gl, const char *name)
return dlsym(RTLD_DEFAULT, name);
}
-static int Open(vlc_object_t *this)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)this;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmt = &vd->fmt;
-
if (vout_display_cfg_IsWindowed(cfg))
return VLC_EGENERIC;
@@ -179,12 +179,12 @@ static int Open(vlc_object_t *this)
const vlc_fourcc_t *subpicture_chromas;
sys->embed = cfg->window;
- sys->gl = vlc_object_create(this, sizeof(*sys->gl));
+ sys->gl = vlc_object_create(vd, sizeof(*sys->gl));
if (!sys->gl)
goto bailout;
struct gl_sys *glsys = sys->gl->sys =
- vlc_obj_malloc(this, sizeof(struct gl_sys));
+ vlc_obj_malloc(VLC_OBJECT(vd), sizeof(struct gl_sys));
if (unlikely(!sys->gl->sys))
goto bailout;
glsys->glESView = sys->glESView;
@@ -223,21 +223,20 @@ static int Open(vlc_object_t *this)
return VLC_SUCCESS;
bailout:
- Close(this);
+ Close(vd);
return VLC_EGENERIC;
}
}
-static void Close (vlc_object_t *this)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)this;
vout_display_sys_t *sys = vd->sys;
@autoreleasepool {
BOOL flushed = NO;
if (sys->gl != NULL) {
struct gl_sys *glsys = sys->gl->sys;
- msg_Dbg(this, "deleting display");
+ msg_Dbg(vd, "deleting display");
if (likely(glsys->vgl))
{
diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index 80733c576a..1cce937330 100644
--- a/modules/video_output/kms.c
+++ b/modules/video_output/kms.c
@@ -674,7 +674,10 @@ static void Display(vout_display_t *vd, picture_t *picture)
}
-static void CloseDisplay(vout_display_t *vd)
+/**
+ * Terminate an output method created by Open
+ */
+static void Close(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
@@ -685,26 +688,12 @@ static void CloseDisplay(vout_display_t *vd)
drmDropMaster(sys->drm_fd);
}
-
-/**
- * Terminate an output method created by Open
- */
-static void Close(vlc_object_t *object)
-{
- vout_display_t *vd = (vout_display_t *)object;
-
- CloseDisplay(vd);
-}
-
-
/**
* This function allocates and initializes a KMS vout method.
*/
-static int Open(vlc_object_t *object)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)object;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
vlc_fourcc_t local_vlc_chroma;
uint32_t local_drm_chroma;
@@ -717,7 +706,7 @@ static int Open(vlc_object_t *object)
/*
* Allocate instance and initialize some members
*/
- vd->sys = sys = vlc_obj_calloc(object, 1, sizeof(*sys));
+ vd->sys = sys = vlc_obj_calloc(VLC_OBJECT(vd), 1, sizeof(*sys));
if (!sys)
return VLC_ENOMEM;
@@ -758,7 +747,7 @@ static int Open(vlc_object_t *object)
}
if (OpenDisplay(vd) != VLC_SUCCESS) {
- Close(VLC_OBJECT(vd));
+ Close(vd);
return VLC_EGENERIC;
}
@@ -775,6 +764,7 @@ static int Open(vlc_object_t *object)
vd->control = Control;
vout_window_ReportSize(cfg->window, sys->width, sys->height);
+ (void) context;
return VLC_SUCCESS;
}
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 7ead67d722..f33e823391 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -52,8 +52,9 @@
/**
* Forward declarations
*/
-static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context);
+static void Close(vout_display_t *vd);
static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count);
static void PictureRender (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture,
@@ -130,11 +131,9 @@ static void *OurGetProcAddress(vlc_gl_t *gl, const char *name)
return dlsym(RTLD_DEFAULT, name);
}
-static int Open (vlc_object_t *this)
+static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)this;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmt = &vd->fmt;
vout_display_sys_t *sys = calloc (1, sizeof(*sys));
if (cfg->window->type != VOUT_WINDOW_TYPE_NSOBJECT)
@@ -146,7 +145,7 @@ static int Open (vlc_object_t *this)
@autoreleasepool {
if (!CGDisplayUsesOpenGLAcceleration (kCGDirectMainDisplay))
- msg_Err (this, "no OpenGL hardware acceleration found. this can lead to slow output and unexpected results");
+ msg_Err (vd, "no OpenGL hardware acceleration found. this can lead to slow output and unexpected results");
vd->sys = sys;
sys->pool = NULL;
@@ -204,7 +203,7 @@ static int Open (vlc_object_t *this)
}
/* Initialize common OpenGL video display */
- sys->gl = vlc_object_create(this, sizeof(*sys->gl));
+ sys->gl = vlc_object_create(vd, sizeof(*sys->gl));
if( unlikely( !sys->gl ) )
goto error;
@@ -256,17 +255,17 @@ static int Open (vlc_object_t *this)
/* */
vout_window_ReportSize(sys->embed, fmt->i_visible_width, fmt->i_visible_height);
+ (void) context;
return VLC_SUCCESS;
error:
- Close(this);
+ Close(vd);
return VLC_EGENERIC;
}
}
-void Close (vlc_object_t *this)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)this;
vout_display_sys_t *sys = vd->sys;
@autoreleasepool {
diff --git a/modules/video_output/opengl/display.c b/modules/video_output/opengl/display.c
index 7ba6e61bf3..7cc3c94b48 100644
--- a/modules/video_output/opengl/display.c
+++ b/modules/video_output/opengl/display.c
@@ -34,8 +34,9 @@
#include "vout_helper.h"
/* Plugin callbacks */
-static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
#define GL_TEXT N_("OpenGL extension")
#define GLES2_TEXT N_("OpenGL ES 2 extension")
@@ -85,11 +86,9 @@ static int Control (vout_display_t *, int, va_list);
/**
* Allocates a surface and an OpenGL context for video output.
*/
-static int Open (vlc_object_t *obj)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmt, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)obj;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmt = &vd->fmt;
vout_display_sys_t *sys = malloc (sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -160,14 +159,14 @@ error:
vlc_gl_Release (sys->gl);
free (sys);
return VLC_EGENERIC;
+ (void) context;
}
/**
* Destroys the OpenGL context.
*/
-static void Close (vlc_object_t *obj)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)obj;
vout_display_sys_t *sys = vd->sys;
vlc_gl_t *gl = sys->gl;
diff --git a/modules/video_output/vdummy.c b/modules/video_output/vdummy.c
index deef545f89..0d54b775aa 100644
--- a/modules/video_output/vdummy.c
+++ b/modules/video_output/vdummy.c
@@ -39,9 +39,11 @@
"format instead of trying to improve performances by using the most " \
"efficient one.")
-static int OpenDummy( vlc_object_t * );
-static int OpenStats( vlc_object_t * );
-static void Close( vlc_object_t * );
+static int OpenDummy(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static int OpenStats(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin ()
set_shortname( N_("Dummy") )
@@ -75,11 +77,9 @@ static int Control(vout_display_t *, int, va_list);
/*****************************************************************************
* OpenVideo: activates dummy vout display method
*****************************************************************************/
-static int Open(vlc_object_t *object,
+static int Open(vout_display_t *vd, video_format_t *fmt,
void (*display)(vout_display_t *, picture_t *))
{
- vout_display_t *vd = (vout_display_t *)object;
- video_format_t *fmt = &vd->fmt;
vout_display_sys_t *sys;
vd->sys = sys = calloc(1, sizeof(*sys));
@@ -106,19 +106,22 @@ static int Open(vlc_object_t *object,
return VLC_SUCCESS;
}
-static int OpenDummy(vlc_object_t *object)
+static int OpenDummy(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- return Open(object, NULL);
+ (void) cfg; (void) context;
+ return Open(vd, fmtp, NULL);
}
-static int OpenStats(vlc_object_t *object)
+static int OpenStats(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- return Open(object, DisplayStat);
+ (void) cfg; (void) context;
+ return Open(vd, fmtp, DisplayStat);
}
-static void Close(vlc_object_t *object)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys = vd->sys;
if (sys->pool)
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index 5fc337f5c7..9edfab51eb 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -52,8 +52,9 @@
#define LT_CHROMA N_("Output chroma for the memory image as a 4-character " \
"string, eg. \"RV32\".")
-static int Open (vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin()
set_description(N_("Video memory output"))
@@ -114,10 +115,9 @@ static int Control(vout_display_t *, int, va_list);
*****************************************************************************
* This function allocates and initializes a vout method.
*****************************************************************************/
-static int Open(vlc_object_t *object)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)object;
- video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys = malloc(sizeof(*sys));
if (unlikely(!sys))
return VLC_ENOMEM;
@@ -218,12 +218,12 @@ static int Open(vlc_object_t *object)
vd->display = Display;
vd->control = Control;
+ (void) cfg; (void) context;
return VLC_SUCCESS;
}
-static void Close(vlc_object_t *object)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys = vd->sys;
if (sys->cleanup)
diff --git a/modules/video_output/wayland/shm.c b/modules/video_output/wayland/shm.c
index d3c03f643a..df37d8af0a 100644
--- a/modules/video_output/wayland/shm.c
+++ b/modules/video_output/wayland/shm.c
@@ -378,12 +378,9 @@ static const struct wl_registry_listener registry_cbs =
registry_global_remove_cb,
};
-static int Open(vlc_object_t *obj)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)obj;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
-
if (cfg->window->type != VOUT_WINDOW_TYPE_WAYLAND)
return VLC_EGENERIC;
@@ -466,6 +463,7 @@ static int Open(vlc_object_t *obj)
vd->display = Display;
vd->control = Control;
+ (void) context;
return VLC_SUCCESS;
error:
@@ -475,9 +473,8 @@ error:
return VLC_EGENERIC;
}
-static void Close(vlc_object_t *obj)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)obj;
vout_display_sys_t *sys = vd->sys;
ResetPictures(vd);
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index c49758bad8..4260468443 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -38,8 +38,9 @@
#include "pictures.h"
#include "events.h"
-static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
/*
* Module descriptor
@@ -101,11 +102,9 @@ static const xcb_depth_t *FindDepth (const xcb_screen_t *scr,
/**
* Probe the X server.
*/
-static int Open (vlc_object_t *obj)
+static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)obj;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys = malloc (sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -228,7 +227,7 @@ static int Open (vlc_object_t *obj)
}
}
- msg_Err (obj, "no supported pixel format & visual");
+ msg_Err (vd, "no supported pixel format & visual");
goto error;
found_format:;
@@ -289,7 +288,7 @@ found_format:;
msg_Dbg (vd, "using X11 graphic context %08"PRIx32, sys->gc);
sys->visible = false;
- if (XCB_shm_Check (obj, conn))
+ if (XCB_shm_Check (VLC_OBJECT(vd), conn))
{
sys->seg_base = xcb_generate_id (conn);
for (unsigned i = 1; i < MAX_PICTURES; i++)
@@ -309,10 +308,11 @@ found_format:;
vd->display = Display;
vd->control = Control;
+ (void) context;
return VLC_SUCCESS;
error:
- Close (obj);
+ Close (vd);
return VLC_EGENERIC;
}
@@ -320,9 +320,8 @@ error:
/**
* Disconnect from the X server.
*/
-static void Close (vlc_object_t *obj)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)obj;
vout_display_sys_t *sys = vd->sys;
ResetPictures (vd);
diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/xcb/xvideo.c
index 4e220c8f0d..6753f5247f 100644
--- a/modules/video_output/xcb/xvideo.c
+++ b/modules/video_output/xcb/xvideo.c
@@ -51,8 +51,9 @@
"XVideo image format id to use. By default, VLC will " \
"try to use the best match for the video being played.")
-static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
static int EnumAdaptors(const char *, int64_t **, char ***);
/*
@@ -346,11 +347,10 @@ FindFormat (vlc_object_t *obj, xcb_connection_t *conn, video_format_t *fmt,
/**
* Probe the X server.
*/
-static int Open (vlc_object_t *obj)
+static int Open (vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)obj;
- const vout_display_cfg_t *cfg = vd->cfg;
- video_format_t *fmtp = &vd->fmt;
+ vlc_object_t *obj = VLC_OBJECT(vd);
vout_display_sys_t *p_sys;
{ /* NOTE: Reject hardware surface formats. Blending would break. */
@@ -563,10 +563,11 @@ static int Open (vlc_object_t *obj)
vd->display = Display;
vd->control = Control;
+ (void) context;
return VLC_SUCCESS;
error:
- Close (obj);
+ Close (vd);
return VLC_EGENERIC;
}
@@ -574,9 +575,8 @@ error:
/**
* Disconnect from the X server.
*/
-static void Close (vlc_object_t *obj)
+static void Close (vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)obj;
vout_display_sys_t *p_sys = vd->sys;
if (p_sys->pool)
diff --git a/modules/video_output/yuv.c b/modules/video_output/yuv.c
index d5dbd93201..52b337581a 100644
--- a/modules/video_output/yuv.c
+++ b/modules/video_output/yuv.c
@@ -51,8 +51,9 @@
#define CFG_PREFIX "yuv-"
-static int Open (vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context);
+static void Close(vout_display_t *vd);
vlc_module_begin()
set_shortname(N_("YUV output"))
@@ -92,10 +93,9 @@ struct vout_display_sys_t {
};
/* */
-static int Open(vlc_object_t *object)
+static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
+ video_format_t *fmtp, vlc_video_context *context)
{
- vout_display_t *vd = (vout_display_t *)object;
- video_format_t *fmtp = &vd->fmt;
vout_display_sys_t *sys;
/* Allocate instance and initialize some members */
@@ -161,13 +161,13 @@ static int Open(vlc_object_t *object)
vd->display = Display;
vd->control = Control;
+ (void) cfg; (void) context;
return VLC_SUCCESS;
}
/* */
-static void Close(vlc_object_t *object)
+static void Close(vout_display_t *vd)
{
- vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys = vd->sys;
if (sys->pool)
diff --git a/src/video_output/display.c b/src/video_output/display.c
index ae0f32ae19..b7832f2a7f 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -71,10 +71,18 @@ static picture_t *VideoBufferNew(filter_t *filter)
static int vout_display_start(void *func, va_list ap)
{
- int (*activate)(vlc_object_t *) = func;
+ vout_display_open_cb activate = func;
vout_display_t *vd = va_arg(ap, vout_display_t *);
+ const vout_display_cfg_t *cfg = va_arg(ap, const vout_display_cfg_t *);
+ video_format_t *fmtp = va_arg(ap, video_format_t *);
+ vlc_video_context *context = va_arg(ap, vlc_video_context *);
- return activate(VLC_OBJECT(vd));
+ video_format_Clean(fmtp);
+ video_format_Copy(fmtp, &vd->source);
+ fmtp->i_sar_num = 0;
+ fmtp->i_sar_den = 0;
+
+ return activate(vd, cfg, fmtp, context);
}
/**
@@ -91,11 +99,9 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
/* */
video_format_Copy(&vd->source, fmt);
+ video_format_Init(&vd->fmt, 0);
/* Picture buffer does not have the concept of aspect ratio */
- video_format_Copy(&vd->fmt, fmt);
- vd->fmt.i_sar_num = 0;
- vd->fmt.i_sar_den = 0;
vd->info.is_slow = false;
vd->info.has_double_click = false;
@@ -112,7 +118,10 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
vd->owner = *owner;
if (load_module) {
- vd->module = vlc_module_load(vd, "vout display", module, module && *module != '\0', vout_display_start, vd);
+ vd->module = vlc_module_load(vd, "vout display", module,
+ module && *module != '\0',
+ vout_display_start, vd, cfg, &vd->fmt,
+ NULL);
if (!vd->module) {
vlc_object_release(vd);
return NULL;
@@ -129,10 +138,9 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
static void vout_display_stop(void *func, va_list ap)
{
- void (*deactivate)(vlc_object_t *) = func;
- vout_display_t *vd = va_arg(ap, vout_display_t *);
+ vout_display_close_cb deactivate = func;
- deactivate(VLC_OBJECT(vd));
+ deactivate(va_arg(ap, vout_display_t *));
}
/**
--
2.19.1
More information about the vlc-devel
mailing list