]> git.sesse.net Git - vlc/blob - include/vlc_variables.h
contrib: ffmpeg: add some cflags for arm/neon
[vlc] / include / vlc_variables.h
1 /*****************************************************************************
2  * variables.h: variables handling
3  *****************************************************************************
4  * Copyright (C) 2002-2004 the VideoLAN team
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
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 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 General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, 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 #define VLC_VAR_GETLIST             0x0025
125 #define VLC_VAR_CHOICESCOUNT        0x0026
126
127 #define VLC_VAR_SETISCOMMAND        0x0040
128 /**@}*/
129
130 /** \defgroup var_GetAndSet Variable actions
131  * These are the different actions that can be used with var_GetAndSet()
132  * @{
133  */
134 enum {
135     VLC_VAR_BOOL_TOGGLE, /**< Invert a boolean value (param ignored) */
136     VLC_VAR_INTEGER_ADD, /**< Add parameter to an integer value */
137     VLC_VAR_INTEGER_OR,  /**< Binary OR over an integer bits field */
138     VLC_VAR_INTEGER_NAND,/**< Binary NAND over an integer bits field */
139 };
140 /**@}*/
141
142 /*****************************************************************************
143  * Prototypes
144  *****************************************************************************/
145 VLC_API int var_Create( vlc_object_t *, const char *, int );
146 #define var_Create(a,b,c) var_Create( VLC_OBJECT(a), b, c )
147
148 VLC_API int var_Destroy( vlc_object_t *, const char * );
149 #define var_Destroy(a,b) var_Destroy( VLC_OBJECT(a), b )
150
151 VLC_API int var_Change( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * );
152 #define var_Change(a,b,c,d,e) var_Change( VLC_OBJECT(a), b, c, d, e )
153
154 VLC_API int var_Type( vlc_object_t *, const char * ) VLC_USED;
155 #define var_Type(a,b) var_Type( VLC_OBJECT(a), b )
156
157 VLC_API int var_Set( vlc_object_t *, const char *, vlc_value_t );
158 #define var_Set(a,b,c) var_Set( VLC_OBJECT(a), b, c )
159
160 VLC_API int var_Get( vlc_object_t *, const char *, vlc_value_t * );
161 #define var_Get(a,b,c) var_Get( VLC_OBJECT(a), b, c )
162
163 VLC_API int var_SetChecked( vlc_object_t *, const char *, int, vlc_value_t );
164 #define var_SetChecked(o,n,t,v) var_SetChecked(VLC_OBJECT(o),n,t,v)
165 VLC_API int var_GetChecked( vlc_object_t *, const char *, int, vlc_value_t * );
166 #define var_GetChecked(o,n,t,v) var_GetChecked(VLC_OBJECT(o),n,t,v)
167 VLC_API int var_GetAndSet( vlc_object_t *, const char *, int, vlc_value_t * );
168
169 VLC_API int var_Inherit( vlc_object_t *, const char *, int, vlc_value_t * );
170
171 VLC_API int var_Command( vlc_object_t *, const char *, const char *, const char *, char ** );
172 #define var_Command(a,b,c,d,e) var_Command( VLC_OBJECT( a ), b, c, d, e )
173
174 VLC_API void var_FreeList( vlc_value_t *, vlc_value_t * );
175
176
177 /*****************************************************************************
178  * Variable callbacks
179  *****************************************************************************
180  * int MyCallback( vlc_object_t *p_this,
181  *                 char const *psz_variable,
182  *                 vlc_value_t oldvalue,
183  *                 vlc_value_t newvalue,
184  *                 void *p_data);
185  *****************************************************************************/
186 VLC_API int var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
187 VLC_API int var_DelCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
188 VLC_API int var_TriggerCallback( vlc_object_t *, const char * );
189
190 #define var_AddCallback(a,b,c,d) var_AddCallback( VLC_OBJECT(a), b, c, d )
191 #define var_DelCallback(a,b,c,d) var_DelCallback( VLC_OBJECT(a), b, c, d )
192 #define var_TriggerCallback(a,b) var_TriggerCallback( VLC_OBJECT(a), b )
193
194 /*****************************************************************************
195  * helpers functions
196  *****************************************************************************/
197
198 /**
199  * Set the value of an integer variable
200  *
201  * \param p_obj The object that holds the variable
202  * \param psz_name The name of the variable
203  * \param i The new integer value of this variable
204  */
205 static inline int var_SetInteger( vlc_object_t *p_obj, const char *psz_name,
206                                   int64_t i )
207 {
208     vlc_value_t val;
209     val.i_int = i;
210     return var_SetChecked( p_obj, psz_name, VLC_VAR_INTEGER, val );
211 }
212
213 /**
214  * Set the value of an boolean variable
215  *
216  * \param p_obj The object that holds the variable
217  * \param psz_name The name of the variable
218  * \param b The new boolean value of this variable
219  */
220 static inline int var_SetBool( vlc_object_t *p_obj, const char *psz_name, bool b )
221 {
222     vlc_value_t val;
223     val.b_bool = b;
224     return var_SetChecked( p_obj, psz_name, VLC_VAR_BOOL, val );
225 }
226
227 /**
228  * Set the value of a time variable
229  *
230  * \param p_obj The object that holds the variable
231  * \param psz_name The name of the variable
232  * \param i The new time value of this variable
233  */
234 static inline int var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_t i )
235 {
236     vlc_value_t val;
237     val.i_time = i;
238     return var_SetChecked( p_obj, psz_name, VLC_VAR_TIME, val );
239 }
240
241 static inline int var_SetCoords( vlc_object_t *obj, const char *name,
242                                  int32_t x, int32_t y )
243 {
244     vlc_value_t val;
245     val.coords.x = x;
246     val.coords.y = y;
247     return var_SetChecked (obj, name, VLC_VAR_COORDS, val);
248 }
249 #define var_SetCoords(o,n,x,y) var_SetCoords(VLC_OBJECT(o),n,x,y)
250
251 /**
252  * Set the value of a float variable
253  *
254  * \param p_obj The object that holds the variable
255  * \param psz_name The name of the variable
256  * \param f The new float value of this variable
257  */
258 static inline int var_SetFloat( vlc_object_t *p_obj, const char *psz_name, float f )
259 {
260     vlc_value_t val;
261     val.f_float = f;
262     return var_SetChecked( p_obj, psz_name, VLC_VAR_FLOAT, val );
263 }
264
265 /**
266  * Set the value of a string variable
267  *
268  * \param p_obj The object that holds the variable
269  * \param psz_name The name of the variable
270  * \param psz_string The new string value of this variable
271  */
272 static inline int var_SetString( vlc_object_t *p_obj, const char *psz_name, const char *psz_string )
273 {
274     vlc_value_t val;
275     val.psz_string = (char *)psz_string;
276     return var_SetChecked( p_obj, psz_name, VLC_VAR_STRING, val );
277 }
278
279 /**
280  * Set the value of a pointer variable
281  *
282  * \param p_obj The object that holds the variable
283  * \param psz_name The name of the variable
284  * \param ptr The new pointer value of this variable
285  */
286 static inline
287 int var_SetAddress( vlc_object_t *p_obj, const char *psz_name, void *ptr )
288 {
289     vlc_value_t val;
290     val.p_address = ptr;
291     return var_SetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, val );
292 }
293
294 #define var_SetInteger(a,b,c)   var_SetInteger( VLC_OBJECT(a),b,c)
295 #define var_SetBool(a,b,c)      var_SetBool( VLC_OBJECT(a),b,c)
296 #define var_SetTime(a,b,c)      var_SetTime( VLC_OBJECT(a),b,c)
297 #define var_SetFloat(a,b,c)     var_SetFloat( VLC_OBJECT(a),b,c)
298 #define var_SetString(a,b,c)    var_SetString( VLC_OBJECT(a),b,c)
299 #define var_SetAddress(o, n, p) var_SetAddress(VLC_OBJECT(o), n, p)
300
301
302 /**
303  * Get an integer value
304 *
305  * \param p_obj The object that holds the variable
306  * \param psz_name The name of the variable
307  */
308 VLC_USED
309 static inline int64_t var_GetInteger( vlc_object_t *p_obj, const char *psz_name )
310 {
311     vlc_value_t val;
312     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_INTEGER, &val ) )
313         return val.i_int;
314     else
315         return 0;
316 }
317
318 /**
319  * Get a boolean value
320  *
321  * \param p_obj The object that holds the variable
322  * \param psz_name The name of the variable
323  */
324 VLC_USED
325 static inline bool var_GetBool( vlc_object_t *p_obj, const char *psz_name )
326 {
327     vlc_value_t val; val.b_bool = false;
328
329     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_BOOL, &val ) )
330         return val.b_bool;
331     else
332         return false;
333 }
334
335 /**
336  * Get a time value
337  *
338  * \param p_obj The object that holds the variable
339  * \param psz_name The name of the variable
340  */
341 VLC_USED
342 static inline int64_t var_GetTime( vlc_object_t *p_obj, const char *psz_name )
343 {
344     vlc_value_t val; val.i_time = 0L;
345     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_TIME, &val ) )
346         return val.i_time;
347     else
348         return 0;
349 }
350
351 static inline void var_GetCoords( vlc_object_t *obj, const char *name,
352                                   int32_t *px, int32_t *py )
353 {
354     vlc_value_t val;
355
356     if (likely(!var_GetChecked (obj, name, VLC_VAR_COORDS, &val)))
357     {
358         *px = val.coords.x;
359         *py = val.coords.y;
360     }
361     else
362         *px = *py = 0;
363 }
364 #define var_GetCoords(o,n,x,y) var_GetCoords(VLC_OBJECT(o),n,x,y)
365
366 /**
367  * Get a float value
368  *
369  * \param p_obj The object that holds the variable
370  * \param psz_name The name of the variable
371  */
372 VLC_USED
373 static inline float var_GetFloat( vlc_object_t *p_obj, const char *psz_name )
374 {
375     vlc_value_t val; val.f_float = 0.0;
376     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_FLOAT, &val ) )
377         return val.f_float;
378     else
379         return 0.0;
380 }
381
382 /**
383  * Get a string value
384  *
385  * \param p_obj The object that holds the variable
386  * \param psz_name The name of the variable
387  */
388 VLC_USED VLC_MALLOC
389 static inline char *var_GetString( vlc_object_t *p_obj, const char *psz_name )
390 {
391     vlc_value_t val; val.psz_string = NULL;
392     if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
393         return NULL;
394     else
395         return val.psz_string;
396 }
397
398 VLC_USED VLC_MALLOC
399 static inline char *var_GetNonEmptyString( vlc_object_t *p_obj, const char *psz_name )
400 {
401     vlc_value_t val;
402     if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
403         return NULL;
404     if( val.psz_string && *val.psz_string )
405         return val.psz_string;
406     free( val.psz_string );
407     return NULL;
408 }
409
410 VLC_USED
411 static inline void *var_GetAddress( vlc_object_t *p_obj, const char *psz_name )
412 {
413     vlc_value_t val;
414     if( var_GetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, &val ) )
415         return NULL;
416     else
417         return val.p_address;
418 }
419
420 /**
421  * Increment an integer variable
422  * \param p_obj the object that holds the variable
423  * \param psz_name the name of the variable
424  */
425 static inline int64_t var_IncInteger( vlc_object_t *p_obj, const char *psz_name )
426 {
427     vlc_value_t val;
428     val.i_int = 1;
429     var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
430     return val.i_int;
431 }
432 #define var_IncInteger(a,b) var_IncInteger( VLC_OBJECT(a), b )
433
434 /**
435  * Decrement an integer variable
436  * \param p_obj the object that holds the variable
437  * \param psz_name the name of the variable
438  */
439 static inline int64_t var_DecInteger( vlc_object_t *p_obj, const char *psz_name )
440 {
441     vlc_value_t val;
442     val.i_int = -1;
443     var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
444     return val.i_int;
445 }
446 #define var_DecInteger(a,b) var_DecInteger( VLC_OBJECT(a), b )
447
448 static inline uint64_t var_OrInteger( vlc_object_t *obj, const char *name,
449                                       unsigned v )
450 {
451     vlc_value_t val;
452     val.i_int = v;
453     var_GetAndSet( obj, name, VLC_VAR_INTEGER_OR, &val );
454     return val.i_int;
455 }
456 #define var_OrInteger(a,b,c) var_OrInteger(VLC_OBJECT(a),b,c)
457
458 static inline uint64_t var_NAndInteger( vlc_object_t *obj, const char *name,
459                                         unsigned v )
460 {
461     vlc_value_t val;
462     val.i_int = v;
463     var_GetAndSet( obj, name, VLC_VAR_INTEGER_NAND, &val );
464     return val.i_int;
465 }
466 #define var_NAndInteger(a,b,c) var_NAndInteger(VLC_OBJECT(a),b,c)
467
468 /**
469  * Create a integer variable with inherit and get its value.
470  *
471  * \param p_obj The object that holds the variable
472  * \param psz_name The name of the variable
473  */
474 VLC_USED
475 static inline int64_t var_CreateGetInteger( vlc_object_t *p_obj, const char *psz_name )
476 {
477     var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
478     return var_GetInteger( p_obj, psz_name );
479 }
480
481 /**
482  * Create a boolean variable with inherit and get its value.
483  *
484  * \param p_obj The object that holds the variable
485  * \param psz_name The name of the variable
486  */
487 VLC_USED
488 static inline bool var_CreateGetBool( vlc_object_t *p_obj, const char *psz_name )
489 {
490     var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
491     return var_GetBool( p_obj, psz_name );
492 }
493
494 /**
495  * Create a time variable with inherit and get its value.
496  *
497  * \param p_obj The object that holds the variable
498  * \param psz_name The name of the variable
499  */
500 VLC_USED
501 static inline int64_t var_CreateGetTime( vlc_object_t *p_obj, const char *psz_name )
502 {
503     var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT );
504     return var_GetTime( p_obj, psz_name );
505 }
506
507 /**
508  * Create a float variable with inherit and get its value.
509  *
510  * \param p_obj The object that holds the variable
511  * \param psz_name The name of the variable
512  */
513 VLC_USED
514 static inline float var_CreateGetFloat( vlc_object_t *p_obj, const char *psz_name )
515 {
516     var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
517     return var_GetFloat( p_obj, psz_name );
518 }
519
520 /**
521  * Create a string variable with inherit and get its value.
522  *
523  * \param p_obj The object that holds the variable
524  * \param psz_name The name of the variable
525  */
526 VLC_USED VLC_MALLOC
527 static inline char *var_CreateGetString( vlc_object_t *p_obj,
528                                            const char *psz_name )
529 {
530     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
531     return var_GetString( p_obj, psz_name );
532 }
533
534 VLC_USED VLC_MALLOC
535 static inline char *var_CreateGetNonEmptyString( vlc_object_t *p_obj,
536                                                    const char *psz_name )
537 {
538     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
539     return var_GetNonEmptyString( p_obj, psz_name );
540 }
541
542 /**
543  * Create an address variable with inherit and get its value.
544  *
545  * \param p_obj The object that holds the variable
546  * \param psz_name The name of the variable
547  */
548 VLC_USED
549 static inline void *var_CreateGetAddress( vlc_object_t *p_obj,
550                                            const char *psz_name )
551 {
552     var_Create( p_obj, psz_name, VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT );
553     return var_GetAddress( p_obj, psz_name );
554 }
555
556 #define var_CreateGetInteger(a,b)   var_CreateGetInteger( VLC_OBJECT(a),b)
557 #define var_CreateGetBool(a,b)   var_CreateGetBool( VLC_OBJECT(a),b)
558 #define var_CreateGetTime(a,b)   var_CreateGetTime( VLC_OBJECT(a),b)
559 #define var_CreateGetFloat(a,b)   var_CreateGetFloat( VLC_OBJECT(a),b)
560 #define var_CreateGetString(a,b)   var_CreateGetString( VLC_OBJECT(a),b)
561 #define var_CreateGetNonEmptyString(a,b)   var_CreateGetNonEmptyString( VLC_OBJECT(a),b)
562 #define var_CreateGetAddress(a,b)  var_CreateGetAddress( VLC_OBJECT(a),b)
563
564 /**
565  * Create a integer command variable with inherit and get its value.
566  *
567  * \param p_obj The object that holds the variable
568  * \param psz_name The name of the variable
569  */
570 VLC_USED
571 static inline int64_t var_CreateGetIntegerCommand( vlc_object_t *p_obj, const char *psz_name )
572 {
573     var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT
574                                    | VLC_VAR_ISCOMMAND );
575     return var_GetInteger( p_obj, psz_name );
576 }
577
578 /**
579  * Create a boolean command variable with inherit and get its value.
580  *
581  * \param p_obj The object that holds the variable
582  * \param psz_name The name of the variable
583  */
584 VLC_USED
585 static inline bool var_CreateGetBoolCommand( vlc_object_t *p_obj, const char *psz_name )
586 {
587     var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT
588                                    | VLC_VAR_ISCOMMAND );
589     return var_GetBool( p_obj, psz_name );
590 }
591
592 /**
593  * Create a time command variable with inherit and get its value.
594  *
595  * \param p_obj The object that holds the variable
596  * \param psz_name The name of the variable
597  */
598 VLC_USED
599 static inline int64_t var_CreateGetTimeCommand( vlc_object_t *p_obj, const char *psz_name )
600 {
601     var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT
602                                    | VLC_VAR_ISCOMMAND );
603     return var_GetTime( p_obj, psz_name );
604 }
605
606 /**
607  * Create a float command variable with inherit and get its value.
608  *
609  * \param p_obj The object that holds the variable
610  * \param psz_name The name of the variable
611  */
612 VLC_USED
613 static inline float var_CreateGetFloatCommand( vlc_object_t *p_obj, const char *psz_name )
614 {
615     var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT
616                                    | VLC_VAR_ISCOMMAND );
617     return var_GetFloat( p_obj, psz_name );
618 }
619
620 /**
621  * Create a string command variable with inherit and get its value.
622  *
623  * \param p_obj The object that holds the variable
624  * \param psz_name The name of the variable
625  */
626 VLC_USED VLC_MALLOC
627 static inline char *var_CreateGetStringCommand( vlc_object_t *p_obj,
628                                            const char *psz_name )
629 {
630     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
631                                    | VLC_VAR_ISCOMMAND );
632     return var_GetString( p_obj, psz_name );
633 }
634
635 VLC_USED VLC_MALLOC
636 static inline char *var_CreateGetNonEmptyStringCommand( vlc_object_t *p_obj,
637                                                    const char *psz_name )
638 {
639     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
640                                    | VLC_VAR_ISCOMMAND );
641     return var_GetNonEmptyString( p_obj, psz_name );
642 }
643
644 #define var_CreateGetIntegerCommand(a,b)   var_CreateGetIntegerCommand( VLC_OBJECT(a),b)
645 #define var_CreateGetBoolCommand(a,b)   var_CreateGetBoolCommand( VLC_OBJECT(a),b)
646 #define var_CreateGetTimeCommand(a,b)   var_CreateGetTimeCommand( VLC_OBJECT(a),b)
647 #define var_CreateGetFloatCommand(a,b)   var_CreateGetFloatCommand( VLC_OBJECT(a),b)
648 #define var_CreateGetStringCommand(a,b)   var_CreateGetStringCommand( VLC_OBJECT(a),b)
649 #define var_CreateGetNonEmptyStringCommand(a,b)   var_CreateGetNonEmptyStringCommand( VLC_OBJECT(a),b)
650
651 VLC_USED
652 static inline int var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
653 {
654     vlc_value_t count;
655     if( var_Change( p_obj, psz_name, VLC_VAR_CHOICESCOUNT, &count, NULL ) )
656         return 0;
657     return count.i_int;
658 }
659 #define var_CountChoices(a,b) var_CountChoices( VLC_OBJECT(a),b)
660
661
662 static inline bool var_ToggleBool( vlc_object_t *p_obj, const char *psz_name )
663 {
664     vlc_value_t val;
665     var_GetAndSet( p_obj, psz_name, VLC_VAR_BOOL_TOGGLE, &val );
666     return val.b_bool;
667 }
668 #define var_ToggleBool(a,b) var_ToggleBool( VLC_OBJECT(a),b )
669
670
671 VLC_USED
672 static inline bool var_InheritBool( vlc_object_t *obj, const char *name )
673 {
674     vlc_value_t val;
675
676     if( var_Inherit( obj, name, VLC_VAR_BOOL, &val ) )
677         val.b_bool = false;
678     return val.b_bool;
679 }
680 #define var_InheritBool(o, n) var_InheritBool(VLC_OBJECT(o), n)
681
682 VLC_USED
683 static inline int64_t var_InheritInteger( vlc_object_t *obj, const char *name )
684 {
685     vlc_value_t val;
686
687     if( var_Inherit( obj, name, VLC_VAR_INTEGER, &val ) )
688         val.i_int = 0;
689     return val.i_int;
690 }
691 #define var_InheritInteger(o, n) var_InheritInteger(VLC_OBJECT(o), n)
692
693 VLC_USED
694 static inline float var_InheritFloat( vlc_object_t *obj, const char *name )
695 {
696     vlc_value_t val;
697
698     if( var_Inherit( obj, name, VLC_VAR_FLOAT, &val ) )
699         val.f_float = 0.;
700     return val.f_float;
701 }
702 #define var_InheritFloat(o, n) var_InheritFloat(VLC_OBJECT(o), n)
703
704 VLC_USED VLC_MALLOC
705 static inline char *var_InheritString( vlc_object_t *obj, const char *name )
706 {
707     vlc_value_t val;
708
709     if( var_Inherit( obj, name, VLC_VAR_STRING, &val ) )
710         val.psz_string = NULL;
711     else if( val.psz_string && !*val.psz_string )
712     {
713         free( val.psz_string );
714         val.psz_string = NULL;
715     }
716     return val.psz_string;
717 }
718 #define var_InheritString(o, n) var_InheritString(VLC_OBJECT(o), n)
719
720 VLC_USED
721 static inline mtime_t var_InheritTime( vlc_object_t *obj, const char *name )
722 {
723     vlc_value_t val;
724
725     if( var_Inherit( obj, name, VLC_VAR_TIME, &val ) )
726         val.i_time = 0;
727     return val.i_time;
728 }
729 #define var_InheritTime(o, n) var_InheritTime(VLC_OBJECT(o), n)
730
731 VLC_USED
732 static inline void *var_InheritAddress( vlc_object_t *obj, const char *name )
733 {
734     vlc_value_t val;
735
736     if( var_Inherit( obj, name, VLC_VAR_ADDRESS, &val ) )
737         val.p_address = NULL;
738     return val.p_address;
739 }
740 #define var_InheritAddress(o, n) var_InheritAddress(VLC_OBJECT(o), n)
741
742 VLC_API int var_InheritURational( vlc_object_t *, unsigned *num, unsigned *den, const char *var );
743 #define var_InheritURational(a,b,c,d) var_InheritURational(VLC_OBJECT(a), b, c, d)
744
745 #define var_GetInteger(a,b)   var_GetInteger( VLC_OBJECT(a),b)
746 #define var_GetBool(a,b)   var_GetBool( VLC_OBJECT(a),b)
747 #define var_GetTime(a,b)   var_GetTime( VLC_OBJECT(a),b)
748 #define var_GetFloat(a,b)   var_GetFloat( VLC_OBJECT(a),b)
749 #define var_GetString(a,b)   var_GetString( VLC_OBJECT(a),b)
750 #define var_GetNonEmptyString(a,b)   var_GetNonEmptyString( VLC_OBJECT(a),b)
751 #define var_GetAddress(a,b)  var_GetAddress( VLC_OBJECT(a),b)
752
753 VLC_API int var_LocationParse(vlc_object_t *, const char *mrl, const char *prefix);
754 #define var_LocationParse(o, m, p) var_LocationParse(VLC_OBJECT(o), m, p)
755
756 /**
757  * @}
758  */
759 #endif /*  _VLC_VARIABLES_H */