[vlc-devel] [RFC] autosaving config options.

Derk-Jan Hartman hartman at videolan.org
Wed Aug 27 20:25:59 CEST 2008


On 26 aug 2008, at 08:45, Rémi Denis-Courmont wrote:
> On Mon, 25 Aug 2008 20:00:22 +0200, Derk-Jan Hartman <hartman at videolan.org 
> >
> wrote:
>> You want to expose the config item->saved (Currently only item->value
>> is exposed) ? So that the preferences of Qt4 and OSX would only show
>> the Saved values, instead of the "current values" ? Such that when  
>> you
>> change the preferences and save them, only the original values are
>> saved, and not something that was changed on the fly ?
>
> Yes. One problem nowadays is that you may end up "saving the command  
> line"
> if you save the preferences.

Yes i'm aware.

>>> And then, there's the persistent lack of clear policy for using
>>> config_* vs
>>> var_*.
>>
>> gibalou was gonna merge the two at one time. But he never described
>> how that would be done. Since it didn't happen, everyone started  
>> using
>> config_Put again to save options.
>
> I fail to see why we should change config_Put*. However, we COULD use
> var_Create/var_Get for command line options, and get rid of the  
> "current
> configuration" altogether. That brings us to my real problem with  
> config_.*
> vs var_.*: there is no consistent policy for using config_Get* or
> var_CreateGet*
>
>> Oh, and then we STILL need a way to make command-line options
>> unsaveable .......
>> By creating/setting variables at libvlc object level I guess, instead
>> of changing the values of the config itself.
>
> Yes. But then we need to replace all config_Get* invocations with
> var_(Create)Get, with the preferences UI being the only exception.

As a test I have made a few simple edits to try and implement this. In  
this process, I discovered that the playlist variables (and the input  
variables have the same issue btw) are initialized (in  
playlist_Create() ) before the playlist is attached to it's parent.  
This breaks the variable inheritance model.
After I moved the playlist attach call (now the last item in  
playlist_ThreadCreate() directly after the creating of the p_playlist  
object and before Initilization of the variables, I could successfully  
communicate commandline options to the interfaces (those options that  
actually already use variables of course)


diff --git a/src/config/cmdline.c b/src/config/cmdline.c
index 4ea2e6a..6bd320f 100644
--- a/src/config/cmdline.c
+++ b/src/config/cmdline.c
@@ -293,19 +293,25 @@ int __config_LoadCmdLine( vlc_object_t *p_this,  
int *pi_argc,
                      case CONFIG_ITEM_MODULE_LIST:
                      case CONFIG_ITEM_MODULE_LIST_CAT:
                      case CONFIG_ITEM_MODULE_CAT:
-                        config_PutPsz( p_this, psz_name, optarg );
+                        var_Create( p_this->p_libvlc, psz_name,  
VLC_VAR_STRING ); /* FIXME not everything is VLC_VAR_STRING */
+                        var_SetString( p_this->p_libvlc, psz_name,  
optarg );
                          break;
                      case CONFIG_ITEM_INTEGER:
-                        config_PutInt( p_this, psz_name,  
strtol(optarg, 0, 0));
+                        var_Create( p_this->p_libvlc, psz_name,  
VLC_VAR_INTEGER );
+                        var_SetInteger( p_this->p_libvlc, psz_name,  
strtol( optarg, 0, 0) );
                          break;
                      case CONFIG_ITEM_FLOAT:
-                        config_PutFloat( p_this, psz_name,  
(float)atof(optarg) );
+                        var_Create( p_this->p_libvlc, psz_name,  
VLC_VAR_FLOAT );
+                        var_SetFloat( p_this->p_libvlc, psz_name,  
(float)atof(optarg) );
                          break;
                      case CONFIG_ITEM_KEY:
-                        config_PutInt( p_this, psz_name,  
ConfigStringToKey( optarg ) );
+                        var_Create( p_this->p_libvlc, psz_name,  
VLC_VAR_HOTKEY );
+                        var_SetInteger( p_this->p_libvlc, psz_name,  
ConfigStringToKey( optarg ) );
                          break;
                      case CONFIG_ITEM_BOOL:
-                        config_PutInt( p_this, psz_name, !flag );
+msg_Dbg( p_this->p_libvlc, "now setting %s to %d", psz_name, !flag );
+                        var_Create( p_this->p_libvlc, psz_name,  
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+                        var_SetBool( p_this->p_libvlc, psz_name, ! 
flag );
                          break;
                  }
                  continue;








More information about the vlc-devel mailing list