[vlc-devel] On configuration callback paradigm

rocky at panix.com rocky at panix.com
Sat Jul 26 18:01:30 CEST 2003

In adding a dynamically changable configuration variable for a
revised VCD input plugin, I came across the following awkwardness.

I scanned the vlc source for a use of a callback on
add_{integer,string} and couldn't find a single place where this was
anything other than NULL. (This made me wonder...)

Looking at src/misc/configuration.c I see that a callback is passed a
vlc_object_t pointer. I created then an appropriate callback routine
and set the field in add_integer() to my routine. When the
corresponding variable was set I got a callback. So far so good. 

The wierdness is having the callback routine retrieve the new value
that was just set and store that into the right associated structure
in the input thread. At first I naively thought that I could get this
via the vlc_object_t pointer would be passed in the callback. Alas,
vlc object is the "interface" rather than the VCD
"input". For now, I managed to solve this using a global static
variable inside the VCD plugin which is set when the a VCD object is
opened. Like this:

static input_thread_t *p_vcd_input = NULL;
static int VCDOpen( vlc_object_t *p_this ) ...
    p_vcd_input = (input_thread_t *)p_this;

static void debug_callback   ( vlc_object_t *p_this )
  thread_vcd_data_t *p_vcd;

  if (NULL == p_vcd_input) return;
  p_vcd = (thread_vcd_data_t *)p_vcd_input->p_access_data;
  p_vcd->i_debug = config_GetInt( p_vcd_input, MODULE_STRING "-debug" );

This works, but I doubt most vlc developers would find this satisfying
or clean. Another non-optimal behavior seen above is that one
has to call config_GetInt to retrieve the new value that was just
set. It would be cleaner if the new value were passed as a

- - - -

The VCD plugin is now at about a minimal stage where I think others
might try it. However with the pending vlc 0.6.1 release, my thought 
is to wait for that release and make a patch on top of that.

This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>

More information about the vlc-devel mailing list