[vlc-devel] Pass variables between modules

Rémi Denis-Courmont rdenis at simphalempin.com
Fri Sep 28 16:44:52 CEST 2007


Le Friday 28 September 2007 12:29:56 Michael Eberhard, vous avez écrit :
> I have implemented two custom modules for the VLC, one interface plug-in
> and one packetizer built-in. Now I want to pass some data received by the
> interface module to the packetizer. So far I have tried the following:
>
> - I set the char** array with the data as a global variable in the
> interface:
>
>     p_intf->p_sys->val_test.psz_string = (char *)psz_test;
>     var_Create( p_intf, "test", VLC_VAR_STRING );
>     var_Set( p_intf, "test", p_intf->p_sys->val_test );
>
> - I subsequently access the data in the packetizer:
>
>     p_list = vlc_list_find( p_this, VLC_OBJECT_INTF, FIND_ANYWHERE );
>     for( int i = 0; i < p_list->i_count; i++ )
>     {
>         p_intf = (intf_thread_t *)p_list->p_values[i].p_object;
>         if ( var_Get( p_intf, "test", &val_test ) == VLC_SUCCESS )
>            break;
>         p_intf = NULL;
>     }
>
>     psz_test = (char **)val_test.psz_string;
>
> The problem with the code above is that it works, but only sometimes. It
> seems that sometimes the data of the array is overwritten, and only
> parts/nothing of the array can be accessed (the access leads to a
> segmentation fault), and sometimes the program works without any problems.
> So I guess there might be a problem with the memory management, I just
> don't seem to find the right solution.

You are not releasing the list, so object references leak, and 
vlc_object_destroy() screws up later.

In any case, that a packetizer would access an interface object strikes me as 
most likely wrong. I don't know what you are trying to do. Still, it would 
seem more logical that the interface would try to find the packetizer.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list