[vlc-devel] How to create a field that is accessible by multiple modules

Rémi Denis-Courmont remi at remlab.net
Thu Nov 15 11:43:41 CET 2012


On Thu, 15 Nov 2012 00:47:12 -0800 (PST), Peter Tap <ptrtap at yahoo.com>
wrote:
> static int MyOpen (vlc_object_t *obj) {
>    int mode = var_CreateGetIntegerCommand(obj, CFG_PREFIX "mode");
> 
>    ...
> }
> 
> Basically, I am registering a field called "mytest-mode" with the VLC
> engine.

Each VLC object has its own name-value dictionary of "variables". In this
case, you are inserting an integer named "mytest-mode" on the object *obj,
with an implicit initial value of zero.

> What I am not clear on is how can I access this field from another
module.

You need to obtain a reference to one object from the other one. The
mechanism, if it exists, will depend on the type of the modules, and the
relation between them.

Basically, you need to pass the same object to the var_*() function calls.

> static int MyOtherModuleOpen(vlc_object *obj) {
>    vlc_object_t* pMyTestObj = SomehowObtainTheOtherModule(obj);
> 
>    int mode = var_GetInteger(pMyTestObj, "mytest-mode");
>    ...
> }
> 
> 
> Can someone please help me understand how I can share the field between
> two different modules?

You cannot. Each object has its own independent dictionary.

-- 
Rémi Denis-Courmont
Sent from my collocated server



More information about the vlc-devel mailing list