[vlc-devel] [PATCH 2/3] core: add a new type of callback for list variables

Felix Abecassis felix.abecassis at gmail.com
Thu Jul 24 19:40:35 CEST 2014


2014-07-24 10:30 GMT+02:00 Rémi Denis-Courmont <remi at remlab.net>:
> Le 2014-07-23 19:56, Felix Abecassis a écrit :
>
>>> I'd rather add a new table. Is there any particular reason for
>>> multiplexing
>>> the different callback types?
>
>
>> With an additional type like list_callback_entry_t
>
>
> Mostly, about not adding an enumeration and not iterating through entries of
> the wrong type.
>
>
>> and a separate
>> table for storing these callbacks, I think too much code would have to
>> be duplicated.
>
>
> I don't see how it requires more duplication. The trigger code needs
> duplication in any case, the add/remove code needs indirection already in
> the existing patch.
>

If we add a new callback table, I see two options:
- Add a new type list_callback_entry_t, functions
var_AddCallback/var_DelCallback and TriggerCallback must be largely
duplicated: callback_entry_t becomes list_callback_entry_t and we use
p_list_entries/i_list_entries instead of p_entries/i_entries.

- Keep the enumeration for callback type and make the pointer
pf_callback a void* in callback_entry_t.
We can now reuse the new handler functions AddCallback and DelCallback
with just a dispatch to the correct callback table for adding/removing
depending on the type.
Same for TriggerCallback().

> --
> Rémi Denis-Courmont
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



-- 
Félix Abecassis
http://felix.abecassis.me



More information about the vlc-devel mailing list