[vlc-commits] gl: pass vlc_gl_t to (de)activate callbacks

Rémi Denis-Courmont git at videolan.org
Thu Jan 31 19:00:00 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jan 31 18:56:47 2019 +0200| [a1fa0542230c4dffc5a0e32d514bd861fdc7a24d] | committer: Rémi Denis-Courmont

gl: pass vlc_gl_t to (de)activate callbacks

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

 modules/video_output/glx.c        |  7 +++----
 modules/video_output/opengl/egl.c | 17 ++++++++---------
 modules/video_output/vgl.c        |  8 +++-----
 modules/video_output/win32/wgl.c  | 12 +++++-------
 src/video_output/opengl.c         | 13 ++++++-------
 5 files changed, 25 insertions(+), 32 deletions(-)

diff --git a/modules/video_output/glx.c b/modules/video_output/glx.c
index 8b2ff8f276..0ac758df6f 100644
--- a/modules/video_output/glx.c
+++ b/modules/video_output/glx.c
@@ -113,9 +113,9 @@ static bool CheckGLXext (Display *dpy, unsigned snum, const char *ext)
     return false;
 }
 
-static int Open (vlc_object_t *obj)
+static int Open(vlc_gl_t *gl)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)obj;
+    vlc_object_t *obj = VLC_OBJECT(gl);
 
     if (gl->surface->type != VOUT_WINDOW_TYPE_XID || !vlc_xlib_init (obj))
         return VLC_EGENERIC;
@@ -253,9 +253,8 @@ error:
     return VLC_EGENERIC;
 }
 
-static void Close (vlc_object_t *obj)
+static void Close(vlc_gl_t *gl)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)obj;
     vlc_gl_sys_t *sys = gl->sys;
     Display *dpy = sys->display;
 
diff --git a/modules/video_output/opengl/egl.c b/modules/video_output/opengl/egl.c
index dec85f86ac..b62c76ae1c 100644
--- a/modules/video_output/opengl/egl.c
+++ b/modules/video_output/opengl/egl.c
@@ -175,9 +175,8 @@ static EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config,
     return eglCreateWindowSurface(dpy, config, *native, attrs);
 }
 
-static void Close (vlc_object_t *obj)
+static void Close(vlc_gl_t *gl)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)obj;
     vlc_gl_sys_t *sys = gl->sys;
 
     if (sys->display != EGL_NO_DISPLAY)
@@ -206,9 +205,9 @@ static void Close (vlc_object_t *obj)
 /**
  * Probe EGL display availability
  */
-static int Open (vlc_object_t *obj, const struct gl_api *api)
+static int Open(vlc_gl_t *gl, const struct gl_api *api)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)obj;
+    vlc_object_t *obj = VLC_OBJECT(gl);
     vlc_gl_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
@@ -392,26 +391,26 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
     return VLC_SUCCESS;
 
 error:
-    Close (obj);
+    Close(gl);
     return VLC_EGENERIC;
 }
 
-static int OpenGLES2 (vlc_object_t *obj)
+static int OpenGLES2(vlc_gl_t *gl)
 {
     static const struct gl_api api = {
         "OpenGL_ES", EGL_OPENGL_ES_API, 3, EGL_OPENGL_ES2_BIT,
         { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE },
     };
-    return Open (obj, &api);
+    return Open(gl, &api);
 }
 
-static int OpenGL (vlc_object_t *obj)
+static int OpenGL(vlc_gl_t *gl)
 {
     static const struct gl_api api = {
         "OpenGL", EGL_OPENGL_API, 4, EGL_OPENGL_BIT,
         { EGL_NONE },
     };
-    return Open (obj, &api);
+    return Open(gl, &api);
 }
 
 vlc_module_begin ()
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 67de0e5c3b..9d844a93c7 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -90,9 +90,8 @@ static void Resize(vlc_gl_t * gl, unsigned w, unsigned h)
     sys->height = h;
 }
 
-static void Close(vlc_object_t *object)
+static void Close(vlc_gl_t *gl)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)object;
     vout_display_sys_t *sys = gl->sys;
     if( sys->cleanupCb )
         sys->cleanupCb(sys->opaque);
@@ -108,13 +107,12 @@ static void Close(vlc_object_t *object)
         }                                                          \
     } while( 0 )
 
-static int Open(vlc_object_t *object)
+static int Open(vlc_gl_t *gl)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)object;
     vout_display_sys_t * sys;
 
     /* Allocate structure */
-    gl->sys = sys = vlc_obj_calloc(object, 1, sizeof(*sys));
+    gl->sys = sys = vlc_obj_calloc(VLC_OBJECT(gl), 1, sizeof(*sys));
     if( !sys )
         return VLC_ENOMEM;
 
diff --git a/modules/video_output/win32/wgl.c b/modules/video_output/win32/wgl.c
index 3e485bffe1..8025620a69 100644
--- a/modules/video_output/win32/wgl.c
+++ b/modules/video_output/win32/wgl.c
@@ -37,8 +37,8 @@
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-static int Open(vlc_object_t *);
-static void Close(vlc_object_t *);
+static int Open(vlc_gl_t *);
+static void Close(vlc_gl_t *);
 
 #define HW_GPU_AFFINITY_TEXT N_("GPU affinity")
 
@@ -157,9 +157,8 @@ static void DestroyGPUAffinityDC(vlc_gl_t *gl) {
     fncDeleteDCNV(sys->affinityHDC);
 }
 
-static int Open(vlc_object_t *object)
+static int Open(vlc_gl_t *gl)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)object;
     vout_display_sys_t *sys;
 
     /* Allocate structure */
@@ -246,13 +245,12 @@ static int Open(vlc_object_t *object)
     return VLC_SUCCESS;
 
 error:
-    Close(object);
+    Close(gl);
     return VLC_EGENERIC;
 }
 
-static void Close(vlc_object_t *object)
+static void Close(vlc_gl_t *gl)
 {
-    vlc_gl_t *gl = (vlc_gl_t *)object;
     vout_display_sys_t *sys = gl->sys;
 
     if (sys->hGLRC)
diff --git a/src/video_output/opengl.c b/src/video_output/opengl.c
index c8c43e6c7f..ad5bc9cf36 100644
--- a/src/video_output/opengl.c
+++ b/src/video_output/opengl.c
@@ -39,16 +39,16 @@ struct vlc_gl_priv_t
 
 static int vlc_gl_start(void *func, va_list ap)
 {
-    int (*activate)(vlc_object_t *) = func;
-    vlc_object_t *gl = va_arg(ap, vlc_object_t *);
+    int (*activate)(vlc_gl_t *) = func;
+    vlc_gl_t *gl = va_arg(ap, vlc_gl_t *);
 
     return activate(gl);
 }
 
 static void vlc_gl_stop(void *func, va_list ap)
 {
-    void (*deactivate)(vlc_object_t *) = func;
-    vlc_object_t *gl = va_arg(ap, vlc_object_t *);
+    void (*deactivate)(vlc_gl_t *) = func;
+    vlc_gl_t *gl = va_arg(ap, vlc_gl_t *);
 
     deactivate(gl);
 }
@@ -88,8 +88,7 @@ vlc_gl_t *vlc_gl_Create(struct vout_window_t *wnd, unsigned flags,
 
     vlc_gl_t *gl = &glpriv->gl;
     gl->surface = wnd;
-    gl->module = vlc_module_load(gl, type, name, true, vlc_gl_start,
-                                 VLC_OBJECT(gl));
+    gl->module = vlc_module_load(gl, type, name, true, vlc_gl_start, gl);
     if (gl->module == NULL)
     {
         vlc_object_release(gl);
@@ -114,7 +113,7 @@ void vlc_gl_Release(vlc_gl_t *gl)
     if (!vlc_atomic_rc_dec(&glpriv->rc))
         return;
 
-    vlc_module_unload(gl, gl->module, vlc_gl_stop, VLC_OBJECT(gl));
+    vlc_module_unload(gl, gl->module, vlc_gl_stop, gl);
     vlc_object_release(gl);
 }
 



More information about the vlc-commits mailing list