[vlc-devel] Pass variables between modules

Michael Eberhard michael_eberhard at gmx.at
Fri Sep 28 11:29:56 CEST 2007


Hi,

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.

Thanks a lot for any help!

Best Regards,
Michael

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger



More information about the vlc-devel mailing list