]> git.sesse.net Git - vlc/blob - include/vlc_variables.h
demux: ts: only interpolate PCR on missing PCR
[vlc] / include / vlc_variables.h
1 /*****************************************************************************
2  * vlc_variables.h: variables handling
3  *****************************************************************************
4  * Copyright (C) 2002-2004 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Gildas Bazin <gbazin@netcourrier.com>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef VLC_VARIABLES_H
26 #define VLC_VARIABLES_H 1
27
28 /**
29  * \file
30  * This file defines functions and structures for dynamic variables in vlc
31  */
32
33 /**
34  * \defgroup variables Variables
35  *
36  * Functions for using the object variables in vlc.
37  *
38  * Vlc have a very powerful "object variable" infrastructure useful
39  * for many things.
40  *
41  * @{
42  */
43
44 #define VLC_VAR_TYPE      0x00ff
45 #define VLC_VAR_CLASS     0x00f0
46 #define VLC_VAR_FLAGS     0xff00
47
48 /**
49  * \defgroup var_type Variable types
50  * These are the different types a vlc variable can have.
51  * @{
52  */
53 #define VLC_VAR_VOID      0x0010
54 #define VLC_VAR_BOOL      0x0020
55 #define VLC_VAR_INTEGER   0x0030
56 #define VLC_VAR_HOTKEY    0x0031
57 #define VLC_VAR_STRING    0x0040
58 #define VLC_VAR_VARIABLE  0x0044
59 #define VLC_VAR_FLOAT     0x0050
60 #define VLC_VAR_TIME      0x0060
61 #define VLC_VAR_ADDRESS   0x0070
62 #define VLC_VAR_COORDS    0x00A0
63 /**@}*/
64
65 /** \defgroup var_flags Additive flags
66  * These flags are added to the type field of the variable. Most as a result of
67  * a var_Change() call, but some may be added at creation time
68  * @{
69  */
70 #define VLC_VAR_HASCHOICE 0x0100
71 #define VLC_VAR_HASMIN    0x0200
72 #define VLC_VAR_HASMAX    0x0400
73 #define VLC_VAR_HASSTEP   0x0800
74
75 #define VLC_VAR_ISCOMMAND 0x2000
76
77 /** Creation flag */
78 /* If the variable is not found on the current module
79    search all parents and finally module config until found */
80 #define VLC_VAR_DOINHERIT 0x8000
81 /**@}*/
82
83 /**
84  * \defgroup var_action Variable actions
85  * These are the different actions that can be used with var_Change().
86  * The parameters given are the meaning of the two last parameters of
87  * var_Change() when this action is being used.
88  * @{
89  */
90
91 /**
92  * Set the minimum value of this variable
93  * \param p_val The new minimum value
94  * \param p_val2 Unused
95  */
96 #define VLC_VAR_SETMIN              0x0010
97 /**
98  * Set the maximum value of this variable
99  * \param p_val The new maximum value
100  * \param p_val2 Unused
101  */
102 #define VLC_VAR_SETMAX              0x0011
103 #define VLC_VAR_SETSTEP             0x0012
104
105 /**
106  * Set the value of this variable without triggering any callbacks
107  * \param p_val The new value
108  * \param p_val2 Unused
109  */
110 #define VLC_VAR_SETVALUE            0x0013
111
112 #define VLC_VAR_SETTEXT             0x0014
113 #define VLC_VAR_GETTEXT             0x0015
114
115 #define VLC_VAR_GETMIN              0x0016
116 #define VLC_VAR_GETMAX              0x0017
117 #define VLC_VAR_GETSTEP             0x0018
118
119 #define VLC_VAR_ADDCHOICE           0x0020
120 #define VLC_VAR_DELCHOICE           0x0021
121 #define VLC_VAR_CLEARCHOICES        0x0022
122 #define VLC_VAR_SETDEFAULT          0x0023
123 #define VLC_VAR_GETCHOICES          0x0024
124
125 #define VLC_VAR_CHOICESCOUNT        0x0026
126
127 /**@}*/
128
129 /** \defgroup var_GetAndSet Variable actions
130  * These are the different actions that can be used with var_GetAndSet()
131  * @{
132  */
133 enum {
134     VLC_VAR_BOOL_TOGGLE, /**< Invert a boolean value (param ignored) */
135     VLC_VAR_INTEGER_ADD, /**< Add parameter to an integer value */
136     VLC_VAR_INTEGER_OR,  /**< Binary OR over an integer bits field */
137     VLC_VAR_INTEGER_NAND,/**< Binary NAND over an integer bits field */
138 };
139 /**@}*/
140
141 /*****************************************************************************
142  * Prototypes
143  *****************************************************************************/
144 VLC_API int var_Create( vlc_object_t *, const char *, int );
145 #define var_Create(a,b,c) var_Create( VLC_OBJECT(a), b, c )
146
147 VLC_API int var_Destroy( vlc_object_t *, const char * );
148 #define var_Destroy(a,b) var_Destroy( VLC_OBJECT(a), b )
149
150 VLC_API int var_Change( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * );
151 #define var_Change(a,b,c,d,e) var_Change( VLC_OBJECT(a), b, c, d, e )
152
153 VLC_API int var_Type( vlc_object_t *, const char * ) VLC_USED;
154 #define var_Type(a,b) var_Type( VLC_OBJECT(a), b )
155
156 VLC_API int var_Set( vlc_object_t *, const char *, vlc_value_t );
157 #define var_Set(a,b,c) var_Set( VLC_OBJECT(a), b, c )
158
159 VLC_API int var_Get( vlc_object_t *, const char *, vlc_value_t * );
160 #define var_Get(a,b,c) var_Get( VLC_OBJECT(a), b, c )
161
162 VLC_API int var_SetChecked( vlc_object_t *, const char *, int, vlc_value_t );
163 #define var_SetChecked(o,n,t,v) var_SetChecked(VLC_OBJECT(o),n,t,v)
164 VLC_API int var_GetChecked( vlc_object_t *, const char *, int, vlc_value_t * );
165 #define var_GetChecked(o,n,t,v) var_GetChecked(VLC_OBJECT(o),n,t,v)
166 VLC_API int var_GetAndSet( vlc_object_t *, const char *, int, vlc_value_t * );
167
168 VLC_API int var_Inherit( vlc_object_t *, const char *, int, vlc_value_t * );
169
170 VLC_API void var_FreeList( vlc_value_t *, vlc_value_t * );
171
172
173 /*****************************************************************************
174  * Variable callbacks
175  *****************************************************************************
176  * int MyCallback( vlc_object_t *p_this,
177  *                 char const *psz_variable,
178  *                 vlc_value_t oldvalue,
179  *                 vlc_value_t newvalue,
180  *                 void *p_data);
181  *****************************************************************************/
182 VLC_API int var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
183 VLC_API int var_DelCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
184 VLC_API int var_TriggerCallback( vlc_object_t *, const char * );
185
186 VLC_API int var_AddListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
187 VLC_API int var_DelListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
188
189 #define var_AddCallback(a,b,c,d) var_AddCallback( VLC_OBJECT(a), b, c, d )
190 #define var_DelCallback(a,b,c,d) var_DelCallback( VLC_OBJECT(a), b, c, d )
191 #define var_TriggerCallback(a,b) var_TriggerCallback( VLC_OBJECT(a), b )
192
193 #define var_AddListCallback(a,b,c,d) var_AddListCallback( VLC_OBJECT(a), b, c, d )
194 #define var_DelListCallback(a,b,c,d) var_DelListCallback( VLC_OBJECT(a), b, c, d )
195
196 /*****************************************************************************
197  * helpers functions
198  *****************************************************************************/
199
200 /**
201  * Set the value of an integer variable
202  *
203  * \param p_obj The object that holds the variable
204  * \param psz_name The name of the variable
205  * \param i The new integer value of this variable
206  */
207 static inline int var_SetInteger( vlc_object_t *p_obj, const char *psz_name,
208                                   int64_t i )
209 {
210     vlc_value_t val;
211     val.i_int = i;
212     return var_SetChecked( p_obj, psz_name, VLC_VAR_INTEGER, val );
213 }
214
215 /**
216  * Set the value of an boolean variable
217  *
218  * \param p_obj The object that holds the variable
219  * \param psz_name The name of the variable
220  * \param b The new boolean value of this variable
221  */
222 static inline int var_SetBool( vlc_object_t *p_obj, const char *psz_name, bool b )
223 {
224     vlc_value_t val;
225     val.b_bool = b;
226     return var_SetChecked( p_obj, psz_name, VLC_VAR_BOOL, val );
227 }
228
229 /**
230  * Set the value of a time variable
231  *
232  * \param p_obj The object that holds the variable
233  * \param psz_name The name of the variable
234  * \param i The new time value of this variable
235  */
236 static inline int var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_t i )
237 {
238     vlc_value_t val;
239     val.i_time = i;
240     return var_SetChecked( p_obj, psz_name, VLC_VAR_TIME, val );
241 }
242
243 static inline int var_SetCoords( vlc_object_t *obj, const char *name,
244                                  int32_t x, int32_t y )
245 {
246     vlc_value_t val;
247     val.coords.x = x;
248     val.coords.y = y;
249     return var_SetChecked (obj, name, VLC_VAR_COORDS, val);
250 }
251 #define var_SetCoords(o,n,x,y) var_SetCoords(VLC_OBJECT(o),n,x,y)
252
253 /**
254  * Set the value of a float variable
255  *
256  * \param p_obj The object that holds the variable
257  * \param psz_name The name of the variable
258  * \param f The new float value of this variable
259  */
260 static inline int var_SetFloat( vlc_object_t *p_obj, const char *psz_name, float f )
261 {
262     vlc_value_t val;
263     val.f_float = f;
264     return var_SetChecked( p_obj, psz_name, VLC_VAR_FLOAT, val );
265 }
266
267 /**
268  * Set the value of a string variable
269  *
270  * \param p_obj The object that holds the variable
271  * \param psz_name The name of the variable
272  * \param psz_string The new string value of this variable
273  */
274 static inline int var_SetString( vlc_object_t *p_obj, const char *psz_name, const char *psz_string )
275 {
276     vlc_value_t val;
277     val.psz_string = (char *)psz_string;
278     return var_SetChecked( p_obj, psz_name, VLC_VAR_STRING, val );
279 }
280
281 /**
282  * Set the value of a pointer variable
283  *
284  * \param p_obj The object that holds the variable
285  * \param psz_name The name of the variable
286  * \param ptr The new pointer value of this variable
287  */
288 static inline
289 int var_SetAddress( vlc_object_t *p_obj, const char *psz_name, void *ptr )
290 {
291     vlc_value_t val;
292     val.p_address = ptr;
293     return var_SetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, val );
294 }
295
296 #define var_SetInteger(a,b,c)   var_SetInteger( VLC_OBJECT(a),b,c)
297 #define var_SetBool(a,b,c)      var_SetBool( VLC_OBJECT(a),b,c)
298 #define var_SetTime(a,b,c)      var_SetTime( VLC_OBJECT(a),b,c)
299 #define var_SetFloat(a,b,c)     var_SetFloat( VLC_OBJECT(a),b,c)
300 #define var_SetString(a,b,c)    var_SetString( VLC_OBJECT(a),b,c)
301 #define var_SetAddress(o, n, p) var_SetAddress(VLC_OBJECT(o), n, p)
302
303
304 /**
305  * Get an integer value
306 *
307  * \param p_obj The object that holds the variable
308  * \param psz_name The name of the variable
309  */
310 VLC_USED
311 static inline int64_t var_GetInteger( vlc_object_t *p_obj, const char *psz_name )
312 {
313     vlc_value_t val;
314     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_INTEGER, &val ) )
315         return val.i_int;
316     else
317         return 0;
318 }
319
320 /**
321  * Get a boolean value
322  *
323  * \param p_obj The object that holds the variable
324  * \param psz_name The name of the variable
325  */
326 VLC_USED
327 static inline bool var_GetBool( vlc_object_t *p_obj, const char *psz_name )
328 {
329     vlc_value_t val; val.b_bool = false;
330
331     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_BOOL, &val ) )
332         return val.b_bool;
333     else
334         return false;
335 }
336
337 /**
338  * Get a time value
339  *
340  * \param p_obj The object that holds the variable
341  * \param psz_name The name of the variable
342  */
343 VLC_USED
344 static inline int64_t var_GetTime( vlc_object_t *p_obj, const char *psz_name )
345 {
346     vlc_value_t val; val.i_time = 0L;
347     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_TIME, &val ) )
348         return val.i_time;
349     else
350         return 0;
351 }
352
353 static inline void var_GetCoords( vlc_object_t *obj, const char *name,
354                                   int32_t *px, int32_t *py )
355 {
356     vlc_value_t val;
357
358     if (likely(!var_GetChecked (obj, name, VLC_VAR_COORDS, &val)))
359     {
360         *px = val.coords.x;
361         *py = val.coords.y;
362     }
363     else
364         *px = *py = 0;
365 }
366 #define var_GetCoords(o,n,x,y) var_GetCoords(VLC_OBJECT(o),n,x,y)
367
368 /**
369  * Get a float value
370  *
371  * \param p_obj The object that holds the variable
372  * \param psz_name The name of the variable
373  */
374 VLC_USED
375 static inline float var_GetFloat( vlc_object_t *p_obj, const char *psz_name )
376 {
377     vlc_value_t val; val.f_float = 0.0;
378     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_FLOAT, &val ) )
379         return val.f_float;
380     else
381         return 0.0;
382 }
383
384 /**
385  * Get a string value
386  *
387  * \param p_obj The object that holds the variable
388  * \param psz_name The name of the variable
389  */
390 VLC_USED VLC_MALLOC
391 static inline char *var_GetString( vlc_object_t *p_obj, const char *psz_name )
392 {
393     vlc_value_t val; val.psz_string = NULL;
394     if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
395         return NULL;
396     else
397         return val.psz_string;
398 }
399
400 VLC_USED VLC_MALLOC
401 static inline char *var_GetNonEmptyString( vlc_object_t *p_obj, const char *psz_name )
402 {
403     vlc_value_t val;
404     if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
405         return NULL;
406     if( val.psz_string && *val.psz_string )
407         return val.psz_string;
408     free( val.psz_string );
409     return NULL;
410 }
411
412 VLC_USED
413 static inline void *var_GetAddress( vlc_object_t *p_obj, const char *psz_name )
414 {
415     vlc_value_t val;
416     if( var_GetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, &val ) )
417         return NULL;
418     else
419         return val.p_address;
420 }
421
422 /**
423  * Increment an integer variable
424  * \param p_obj the object that holds the variable
425  * \param psz_name the name of the variable
426  */
427 static inline int64_t var_IncInteger( vlc_object_t *p_obj, const char *psz_name )
428 {
429     vlc_value_t val;
430     val.i_int = 1;
431     if( var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val ) )
432         return 0;
433     return val.i_int;
434 }
435 #define var_IncInteger(a,b) var_IncInteger( VLC_OBJECT(a), b )
436
437 /**
438  * Decrement an integer variable
439  * \param p_obj the object that holds the variable
440  * \param psz_name the name of the variable
441  */
442 static inline int64_t var_DecInteger( vlc_object_t *p_obj, const char *psz_name )
443 {
444     vlc_value_t val;
445     val.i_int = -1;
446     if( var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val ) )
447         return 0;
448     return val.i_int;
449 }
450 #define var_DecInteger(a,b) var_DecInteger( VLC_OBJECT(a), b )
451
452 static inline uint64_t var_OrInteger( vlc_object_t *obj, const char *name,
453                                       unsigned v )
454 {
455     vlc_value_t val;
456     val.i_int = v;
457     if( var_GetAndSet( obj, name, VLC_VAR_INTEGER_OR, &val ) )
458         return 0;
459     return val.i_int;
460 }
461 #define var_OrInteger(a,b,c) var_OrInteger(VLC_OBJECT(a),b,c)
462
463 static inline uint64_t var_NAndInteger( vlc_object_t *obj, const char *name,
464                                         unsigned v )
465 {
466     vlc_value_t val;
467     val.i_int = v;
468     if( var_GetAndSet( obj, name, VLC_VAR_INTEGER_NAND, &val ) )
469         return 0;
470     return val.i_int;
471 }
472 #define var_NAndInteger(a,b,c) var_NAndInteger(VLC_OBJECT(a),b,c)
473
474 /**
475  * Create a integer variable with inherit and get its value.
476  *
477  * \param p_obj The object that holds the variable
478  * \param psz_name The name of the variable
479  */
480 VLC_USED
481 static inline int64_t var_CreateGetInteger( vlc_object_t *p_obj, const char *psz_name )
482 {
483     var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
484     return var_GetInteger( p_obj, psz_name );
485 }
486
487 /**
488  * Create a boolean variable with inherit and get its value.
489  *
490  * \param p_obj The object that holds the variable
491  * \param psz_name The name of the variable
492  */
493 VLC_USED
494 static inline bool var_CreateGetBool( vlc_object_t *p_obj, const char *psz_name )
495 {
496     var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
497     return var_GetBool( p_obj, psz_name );
498 }
499
500 /**
501  * Create a time variable with inherit and get its value.
502  *
503  * \param p_obj The object that holds the variable
504  * \param psz_name The name of the variable
505  */
506 VLC_USED
507 static inline int64_t var_CreateGetTime( vlc_object_t *p_obj, const char *psz_name )
508 {
509     var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT );
510     return var_GetTime( p_obj, psz_name );
511 }
512
513 /**
514  * Create a float variable with inherit and get its value.
515  *
516  * \param p_obj The object that holds the variable
517  * \param psz_name The name of the variable
518  */
519 VLC_USED
520 static inline float var_CreateGetFloat( vlc_object_t *p_obj, const char *psz_name )
521 {
522     var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
523     return var_GetFloat( p_obj, psz_name );
524 }
525
526 /**
527  * Create a string variable with inherit and get its value.
528  *
529  * \param p_obj The object that holds the variable
530  * \param psz_name The name of the variable
531  */
532 VLC_USED VLC_MALLOC
533 static inline char *var_CreateGetString( vlc_object_t *p_obj,
534                                            const char *psz_name )
535 {
536     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
537     return var_GetString( p_obj, psz_name );
538 }
539
540 VLC_USED VLC_MALLOC
541 static inline char *var_CreateGetNonEmptyString( vlc_object_t *p_obj,
542                                                    const char *psz_name )
543 {
544     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
545     return var_GetNonEmptyString( p_obj, psz_name );
546 }
547
548 /**
549  * Create an address variable with inherit and get its value.
550  *
551  * \param p_obj The object that holds the variable
552  * \param psz_name The name of the variable
553  */
554 VLC_USED
555 static inline void *var_CreateGetAddress( vlc_object_t *p_obj,
556                                            const char *psz_name )
557 {
558     var_Create( p_obj, psz_name, VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT );
559     return var_GetAddress( p_obj, psz_name );
560 }
561
562 #define var_CreateGetInteger(a,b)   var_CreateGetInteger( VLC_OBJECT(a),b)
563 #define var_CreateGetBool(a,b)   var_CreateGetBool( VLC_OBJECT(a),b)
564 #define var_CreateGetTime(a,b)   var_CreateGetTime( VLC_OBJECT(a),b)
565 #define var_CreateGetFloat(a,b)   var_CreateGetFloat( VLC_OBJECT(a),b)
566 #define var_CreateGetString(a,b)   var_CreateGetString( VLC_OBJECT(a),b)
567 #define var_CreateGetNonEmptyString(a,b)   var_CreateGetNonEmptyString( VLC_OBJECT(a),b)
568 #define var_CreateGetAddress(a,b)  var_CreateGetAddress( VLC_OBJECT(a),b)
569
570 /**
571  * Create a integer command variable with inherit and get its value.
572  *
573  * \param p_obj The object that holds the variable
574  * \param psz_name The name of the variable
575  */
576 VLC_USED
577 static inline int64_t var_CreateGetIntegerCommand( vlc_object_t *p_obj, const char *psz_name )
578 {
579     var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT
580                                    | VLC_VAR_ISCOMMAND );
581     return var_GetInteger( p_obj, psz_name );
582 }
583
584 /**
585  * Create a boolean command variable with inherit and get its value.
586  *
587  * \param p_obj The object that holds the variable
588  * \param psz_name The name of the variable
589  */
590 VLC_USED
591 static inline bool var_CreateGetBoolCommand( vlc_object_t *p_obj, const char *psz_name )
592 {
593     var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT
594                                    | VLC_VAR_ISCOMMAND );
595     return var_GetBool( p_obj, psz_name );
596 }
597
598 /**
599  * Create a time command variable with inherit and get its value.
600  *
601  * \param p_obj The object that holds the variable
602  * \param psz_name The name of the variable
603  */
604 VLC_USED
605 static inline int64_t var_CreateGetTimeCommand( vlc_object_t *p_obj, const char *psz_name )
606 {
607     var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT
608                                    | VLC_VAR_ISCOMMAND );
609     return var_GetTime( p_obj, psz_name );
610 }
611
612 /**
613  * Create a float command variable with inherit and get its value.
614  *
615  * \param p_obj The object that holds the variable
616  * \param psz_name The name of the variable
617  */
618 VLC_USED
619 static inline float var_CreateGetFloatCommand( vlc_object_t *p_obj, const char *psz_name )
620 {
621     var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT
622                                    | VLC_VAR_ISCOMMAND );
623     return var_GetFloat( p_obj, psz_name );
624 }
625
626 /**
627  * Create a string command variable with inherit and get its value.
628  *
629  * \param p_obj The object that holds the variable
630  * \param psz_name The name of the variable
631  */
632 VLC_USED VLC_MALLOC
633 static inline char *var_CreateGetStringCommand( vlc_object_t *p_obj,
634                                            const char *psz_name )
635 {
636     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
637                                    | VLC_VAR_ISCOMMAND );
638     return var_GetString( p_obj, psz_name );
639 }
640
641 VLC_USED VLC_MALLOC
642 static inline char *var_CreateGetNonEmptyStringCommand( vlc_object_t *p_obj,
643                                                    const char *psz_name )
644 {
645     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
646                                    | VLC_VAR_ISCOMMAND );
647     return var_GetNonEmptyString( p_obj, psz_name );
648 }
649
650 #define var_CreateGetIntegerCommand(a,b)   var_CreateGetIntegerCommand( VLC_OBJECT(a),b)
651 #define var_CreateGetBoolCommand(a,b)   var_CreateGetBoolCommand( VLC_OBJECT(a),b)
652 #define var_CreateGetTimeCommand(a,b)   var_CreateGetTimeCommand( VLC_OBJECT(a),b)
653 #define var_CreateGetFloatCommand(a,b)   var_CreateGetFloatCommand( VLC_OBJECT(a),b)
654 #define var_CreateGetStringCommand(a,b)   var_CreateGetStringCommand( VLC_OBJECT(a),b)
655 #define var_CreateGetNonEmptyStringCommand(a,b)   var_CreateGetNonEmptyStringCommand( VLC_OBJECT(a),b)
656
657 VLC_USED
658 static inline int var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
659 {
660     vlc_value_t count;
661     if( var_Change( p_obj, psz_name, VLC_VAR_CHOICESCOUNT, &count, NULL ) )
662         return 0;
663     return count.i_int;
664 }
665 #define var_CountChoices(a,b) var_CountChoices( VLC_OBJECT(a),b)
666
667
668 static inline bool var_ToggleBool( vlc_object_t *p_obj, const char *psz_name )
669 {
670     vlc_value_t val;
671     if( var_GetAndSet( p_obj, psz_name, VLC_VAR_BOOL_TOGGLE, &val ) )
672         return false;
673     return val.b_bool;
674 }
675 #define var_ToggleBool(a,b) var_ToggleBool( VLC_OBJECT(a),b )
676
677
678 VLC_USED
679 static inline bool var_InheritBool( vlc_object_t *obj, const char *name )
680 {
681     vlc_value_t val;
682
683     if( var_Inherit( obj, name, VLC_VAR_BOOL, &val ) )
684         val.b_bool = false;
685     return val.b_bool;
686 }
687 #define var_InheritBool(o, n) var_InheritBool(VLC_OBJECT(o), n)
688
689 VLC_USED
690 static inline int64_t var_InheritInteger( vlc_object_t *obj, const char *name )
691 {
692     vlc_value_t val;
693
694     if( var_Inherit( obj, name, VLC_VAR_INTEGER, &val ) )
695         val.i_int = 0;
696     return val.i_int;
697 }
698 #define var_InheritInteger(o, n) var_InheritInteger(VLC_OBJECT(o), n)
699
700 VLC_USED
701 static inline float var_InheritFloat( vlc_object_t *obj, const char *name )
702 {
703     vlc_value_t val;
704
705     if( var_Inherit( obj, name, VLC_VAR_FLOAT, &val ) )
706         val.f_float = 0.;
707     return val.f_float;
708 }
709 #define var_InheritFloat(o, n) var_InheritFloat(VLC_OBJECT(o), n)
710
711 VLC_USED VLC_MALLOC
712 static inline char *var_InheritString( vlc_object_t *obj, const char *name )
713 {
714     vlc_value_t val;
715
716     if( var_Inherit( obj, name, VLC_VAR_STRING, &val ) )
717         val.psz_string = NULL;
718     else if( val.psz_string && !*val.psz_string )
719     {
720         free( val.psz_string );
721         val.psz_string = NULL;
722     }
723     return val.psz_string;
724 }
725 #define var_InheritString(o, n) var_InheritString(VLC_OBJECT(o), n)
726
727 VLC_USED
728 static inline mtime_t var_InheritTime( vlc_object_t *obj, const char *name )
729 {
730     vlc_value_t val;
731
732     if( var_Inherit( obj, name, VLC_VAR_TIME, &val ) )
733         val.i_time = 0;
734     return val.i_time;
735 }
736 #define var_InheritTime(o, n) var_InheritTime(VLC_OBJECT(o), n)
737
738 VLC_USED
739 static inline void *var_InheritAddress( vlc_object_t *obj, const char *name )
740 {
741     vlc_value_t val;
742
743     if( var_Inherit( obj, name, VLC_VAR_ADDRESS, &val ) )
744         val.p_address = NULL;
745     return val.p_address;
746 }
747 #define var_InheritAddress(o, n) var_InheritAddress(VLC_OBJECT(o), n)
748
749 VLC_API int var_InheritURational( vlc_object_t *, unsigned *num, unsigned *den, const char *var );
750 #define var_InheritURational(a,b,c,d) var_InheritURational(VLC_OBJECT(a), b, c, d)
751
752 #define var_GetInteger(a,b)   var_GetInteger( VLC_OBJECT(a),b)
753 #define var_GetBool(a,b)   var_GetBool( VLC_OBJECT(a),b)
754 #define var_GetTime(a,b)   var_GetTime( VLC_OBJECT(a),b)
755 #define var_GetFloat(a,b)   var_GetFloat( VLC_OBJECT(a),b)
756 #define var_GetString(a,b)   var_GetString( VLC_OBJECT(a),b)
757 #define var_GetNonEmptyString(a,b)   var_GetNonEmptyString( VLC_OBJECT(a),b)
758 #define var_GetAddress(a,b)  var_GetAddress( VLC_OBJECT(a),b)
759
760 VLC_API int var_LocationParse(vlc_object_t *, const char *mrl, const char *prefix);
761 #define var_LocationParse(o, m, p) var_LocationParse(VLC_OBJECT(o), m, p)
762
763 /**
764  * @}
765  */
766 #endif /*  _VLC_VARIABLES_H */