[vlc-devel] [PATCH] gl: move destroy callback to vlc_gl_t

Rémi Denis-Courmont remi at remlab.net
Thu Jul 18 08:13:11 CEST 2019


Hi,

It is never NULL at the moment. But whether it can reasonably be NULL... I'd say it can if all resources were tracked by objres. So IMO, it's *not* a case for an assertion.

Le 18 juillet 2019 08:51:08 GMT+03:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>
>
>On Wed, Jul 17, 2019, at 22:26, Rémi Denis-Courmont wrote:
>> ---
>>  include/vlc_opengl.h              |  1 +
>>  modules/video_output/glx.c        |  3 ++-
>>  modules/video_output/opengl/egl.c |  5 +++--
>>  modules/video_output/vgl.c        |  5 +++--
>>  modules/video_output/win32/wgl.c  |  3 ++-
>>  src/video_output/opengl.c         | 11 ++---------
>>  6 files changed, 13 insertions(+), 15 deletions(-)
>> 
>> diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
>> index 8c4909fc5d..4e436c939b 100644
>> --- a/include/vlc_opengl.h
>> +++ b/include/vlc_opengl.h
>> @@ -51,6 +51,7 @@ struct vlc_gl_t
>>      void (*resize)(vlc_gl_t *, unsigned, unsigned);
>>      void (*swap)(vlc_gl_t *);
>>      void*(*getProcAddress)(vlc_gl_t *, const char *);
>> +    void (*destroy)(vlc_gl_t *);
>>  
>>      enum {
>>          VLC_GL_EXT_DEFAULT,
>> diff --git a/modules/video_output/glx.c b/modules/video_output/glx.c
>> index d5d47c017a..9856c063a3 100644
>> --- a/modules/video_output/glx.c
>> +++ b/modules/video_output/glx.c
>> @@ -219,6 +219,7 @@ static int Open(vlc_gl_t *gl, unsigned width, 
>> unsigned height)
>>      gl->resize = NULL;
>>      gl->swap = SwapBuffers;
>>      gl->getProcAddress = GetSymbol;
>> +    gl->destroy = Close;
>>  
>>      bool is_swap_interval_set = false;
>>  
>> @@ -271,5 +272,5 @@ vlc_module_begin ()
>>      set_category (CAT_VIDEO)
>>      set_subcategory (SUBCAT_VIDEO_VOUT)
>>      set_capability ("opengl", 20)
>> -    set_callbacks (Open, Close)
>> +    set_callbacks(Open, NULL)
>>  vlc_module_end ()
>> diff --git a/modules/video_output/opengl/egl.c 
>> b/modules/video_output/opengl/egl.c
>> index bd1b6941e4..b34ac06114 100644
>> --- a/modules/video_output/opengl/egl.c
>> +++ b/modules/video_output/opengl/egl.c
>> @@ -381,6 +381,7 @@ static int Open(vlc_gl_t *gl, const struct gl_api
>
>> *api,
>>      gl->resize = Resize;
>>      gl->swap = SwapBuffers;
>>      gl->getProcAddress = GetSymbol;
>> +    gl->destroy = Close;
>>      gl->egl.queryString = QueryString;
>>  
>>      sys->eglCreateImageKHR = (void
>*)eglGetProcAddress("eglCreateImageKHR");
>> @@ -422,12 +423,12 @@ vlc_module_begin ()
>>      set_category (CAT_VIDEO)
>>      set_subcategory (SUBCAT_VIDEO_VOUT)
>>      set_capability ("opengl", 50)
>> -    set_callbacks (OpenGL, Close)
>> +    set_callbacks(OpenGL, NULL)
>>      add_shortcut ("egl")
>>  
>>      add_submodule ()
>>      set_capability ("opengl es2", 50)
>> -    set_callbacks (OpenGLES2, Close)
>> +    set_callbacks(OpenGLES2, NULL)
>>      add_shortcut ("egl")
>>  
>>  vlc_module_end ()
>> diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
>> index c2c9be3696..e6825e19ac 100644
>> --- a/modules/video_output/vgl.c
>> +++ b/modules/video_output/vgl.c
>> @@ -129,6 +129,7 @@ static int Open(vlc_gl_t *gl, unsigned width, 
>> unsigned height)
>>      gl->resize = Resize;
>>      gl->swap = VglSwapBuffers;
>>      gl->getProcAddress = OurGetProcAddress;
>> +    gl->destroy = Close;
>>  
>>      if( sys->setupCb )
>>          if( !sys->setupCb(sys->opaque) )
>> @@ -154,11 +155,11 @@ vlc_module_begin()
>>      set_subcategory(SUBCAT_VIDEO_VOUT)
>>  
>>      set_capability("opengl", 0)
>> -    set_callbacks(Open, Close)
>> +    set_callbacks(Open, NULL)
>>      add_shortcut("vglmem")
>>  
>>      add_submodule()
>>      set_capability("opengl es2", 0)
>> -    set_callbacks(Open, Close)
>> +    set_callbacks(Open, NULL)
>>      add_shortcut("vglmem")
>>  vlc_module_end()
>> diff --git a/modules/video_output/win32/wgl.c 
>> b/modules/video_output/win32/wgl.c
>> index 8f18424a8b..149149963f 100644
>> --- a/modules/video_output/win32/wgl.c
>> +++ b/modules/video_output/win32/wgl.c
>> @@ -49,7 +49,7 @@ vlc_module_begin()
>>      add_integer("gpu-affinity", -1, HW_GPU_AFFINITY_TEXT, 
>> HW_GPU_AFFINITY_TEXT, true)
>>  
>>      set_capability("opengl", 50)
>> -    set_callbacks(Open, Close)
>> +    set_callbacks(Open, NULL)
>>      add_shortcut("wgl")
>>  vlc_module_end()
>>  
>> @@ -235,6 +235,7 @@ static int Open(vlc_gl_t *gl, unsigned width, 
>> unsigned height)
>>      gl->resize = NULL;
>>      gl->swap = Swap;
>>      gl->getProcAddress = OurGetProcAddress;
>> +    gl->destroy = Close;
>>  
>>      if (sys->exts.GetExtensionsStringEXT ||
>sys->exts.GetExtensionsStringARB)
>>          gl->wgl.getExtensionsString = GetExtensionsString;
>> diff --git a/src/video_output/opengl.c b/src/video_output/opengl.c
>> index f17c8ff05c..9d207ac709 100644
>> --- a/src/video_output/opengl.c
>> +++ b/src/video_output/opengl.c
>> @@ -52,14 +52,6 @@ static int vlc_gl_start(void *func, bool forced,
>va_list ap)
>>      return ret;
>>  }
>>  
>> -static void vlc_gl_stop(void *func, va_list ap)
>> -{
>> -    void (*deactivate)(vlc_gl_t *) = func;
>> -    vlc_gl_t *gl = va_arg(ap, vlc_gl_t *);
>> -
>> -    deactivate(gl);
>> -}
>> -
>>  vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *restrict cfg,
>>                          unsigned flags, const char *name)
>>  {
>> @@ -111,7 +103,8 @@ void vlc_gl_Release(vlc_gl_t *gl)
>>      if (!vlc_atomic_rc_dec(&glpriv->rc))
>>          return;
>>  
>> -    vlc_module_unload(gl->module, vlc_gl_stop, gl);
>> +    if (gl->destroy != NULL)
>> +        gl->destroy(gl);
>
>Can gl->destroy be NULL ? If not, I would have put an
>assert(gl->destroy)
>
>>      vlc_objres_clear(VLC_OBJECT(gl));
>>      vlc_object_delete(gl);
>>  }
>> -- 
>> 2.22.0
>> 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190718/94775c87/attachment.html>


More information about the vlc-devel mailing list