[vlc-devel] [PATCH] core: object: clear res from vlc_object_delete()
Thomas Guillem
thomas at gllm.fr
Mon Jan 27 16:08:47 CET 2020
On Mon, Jan 27, 2020, at 15:00, Rémi Denis-Courmont wrote:
> Hi,
>
> I don't think that we require an object to be deleted after a single module probe though (unlike the kernel), or do we?
No we don't require it, and nothing prevent to load/unload different kind of module using one vlc_object.
The newest way to load/unload modules is to load them with vlc_module_load() and close them with their own close callbacks.
The problem is that we don't call module_unneed anymore, this function was clearing the resources.
We could also expose vlc_objres_clear() to VLC CORE in order to let modules use vlc_module_load() + vlc_objres_clear() for submodules.
>
> Le 27 janvier 2020 15:18:53 GMT+02:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>> Instead of clearing them from all kind of modules API.
>>
>> This will allow to use vlc_obj_*alloc() from all modules without wondering if
>> resources will be cleaned. Indeed, some modules have their own close callbacks
>> that don't need module_unneed() (that was calling vlc_objres_clear()) to be
>> called to release them.
>>
>> Furthermore, vlc_objres_clear() is an internal API, so submodules using an API
>> defined in modules and a close callback could not benefit from it. src/input/decoder_helpers.c | 1 -
>> src/misc/objects.c | 1 +
>> src/modules/modules.c | 2 --
>> src/network/tls.c | 2 --
>> src/video_output/display.c | 2 --
>> src/video_output/opengl.c | 1 -
>> src/video_output/window.c | 1 -
>> 7 files changed, 1 insertion(+), 9 deletions(-)
>>
>> diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
>> index e59cdcb3a10..ae022796336 100644
>> --- a/src/input/decoder_helpers.c
>> +++ b/src/input/decoder_helpers.c
>> @@ -222,7 +222,6 @@ vlc_decoder_device_Release(vlc_decoder_device *device)
>> {
>> if (device->ops->close != NULL)
>> device->ops->close(device);
>> - vlc_objres_clear(VLC_OBJECT(device));
>> vlc_object_delete(device);
>> }
>> }
>> diff --git a/src/misc/objects.c b/src/misc/objects.c
>> index f87edd9827f..370f7a92e98 100644
>> --- a/src/misc/objects.c
>> +++ b/src/misc/objects.c
>> @@ -135,6 +135,7 @@ void vlc_object_deinit(vlc_object_t *obj)
>>
>> void (vlc_object_delete)(vlc_object_t *obj)
>> {
>> + vlc_objres_clear(obj);
>> vlc_object_deinit(obj);
>> free(obj);
>> }
>> diff --git a/src/modules/modules.c b/src/modules/modules.c
>> index 2df5702f840..93ca5c8fa75 100644
>> --- a/src/modules/modules.c
>> +++ b/src/modules/modules.c
>> @@ -272,8 +272,6 @@ void module_unneed(vlc_object_t *obj, module_t *module)
>>
>> if (module->deactivate != NULL)
>> module->deactivate(obj);
>> -
>> - vlc_objres_clear(obj);
>> }
>>
>> module_t *module_find (const char *name)
>> diff --git a/src/network/tls.c b/src/network/tls.c
>> index 2fde82d61a4..3cf7546691f 100644
>> --- a/src/network/tls.c
>> +++ b/src/network/tls.c
>> @@ -101,7 +101,6 @@ void vlc_tls_ServerDelete(vlc_tls_server_t *crd)
>> return;
>>
>> crd->ops->destroy(crd);
>> - vlc_objres_clear(VLC_OBJECT(crd));
>> vlc_object_delete(crd);
>> }
>>
>> @@ -129,7 +128,6 @@ void vlc_tls_ClientDelete(vlc_tls_client_t *crd)
>> return;
>>
>> crd->ops->destroy(crd);
>> - vlc_objres_clear(VLC_OBJECT(crd));
>> vlc_object_delete(crd);
>> }
>>
>> diff --git a/src/video_output/display.c b/src/video_output/display.c
>> index 76d49ee240d..db83ee74a43 100644
>> --- a/src/video_output/display.c
>> +++ b/src/video_output/display.c
>> @@ -785,7 +785,6 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
>> if (VoutDisplayCreateRender(vd)) {
>> if (vd->close != NULL)
>> vd->close(vd);
>> - vlc_objres_clear(VLC_OBJECT(vd));
>> video_format_Clean(&vd->fmt);
>> goto error;
>> }
>> @@ -814,7 +813,6 @@ void vout_display_Delete(vout_display_t *vd)
>>
>> if (vd->close != NULL)
>> vd->close(vd);
>> - vlc_objres_clear(VLC_OBJECT(vd));
>>
>> video_format_Clean(&vd->source);
>> video_format_Clean(&vd->fmt);
>> diff --git a/src/video_output/opengl.c b/src/video_output/opengl.c
>> index 9d207ac7095..9f615f9c0cd 100644
>> --- a/src/video_output/opengl.c
>> +++ b/src/video_output/opengl.c
>> @@ -105,7 +105,6 @@ void vlc_gl_Release(vlc_gl_t *gl)
>>
>> if (gl->destroy != NULL)
>> gl->destroy(gl);
>> - vlc_objres_clear(VLC_OBJECT(gl));
>> vlc_object_delete(gl);
>> }
>>
>> diff --git a/src/video_output/window.c b/src/video_output/window.c
>> index 16ebf9ef5a2..aeab072ce6c 100644
>> --- a/src/video_output/window.c
>> +++ b/src/video_output/window.c
>> @@ -140,7 +140,6 @@ void vout_window_Delete(vout_window_t *window)
>> if (window->ops->destroy != NULL)
>> window->ops->destroy(window);
>>
>> - vlc_objres_clear(VLC_OBJECT(window));
>> vlc_mutex_destroy(&w->lock);
>> vlc_object_delete(window);
>> }
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200127/f9083299/attachment-0001.html>
More information about the vlc-devel
mailing list