]> git.sesse.net Git - vlc/blob - src/misc/variables.h
decoder: inline DecoderSignalWait()
[vlc] / src / misc / variables.h
1 /*****************************************************************************
2  * variables.h: object variables typedefs
3  *****************************************************************************
4  * Copyright (C) 1999-2012 VLC authors and VideoLAN
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 #ifndef LIBVLC_VARIABLES_H
24 # define LIBVLC_VARIABLES_H 1
25
26 # include <vlc_atomic.h>
27
28 /**
29  * Private LibVLC data for each object.
30  */
31 typedef struct vlc_object_internals vlc_object_internals_t;
32
33 struct vlc_object_internals
34 {
35     char           *psz_name; /* given name */
36
37     /* Object variables */
38     void           *var_root;
39     vlc_mutex_t     var_lock;
40     vlc_cond_t      var_wait;
41
42     /* Objects thread synchronization */
43     int             pipes[2];
44     atomic_bool     alive;
45
46     /* Objects management */
47     atomic_uint     refs;
48     vlc_destructor_t pf_destructor;
49
50     /* Objects tree structure */
51     vlc_object_internals_t *next;  /* next sibling */
52     vlc_object_internals_t *prev;  /* previous sibling */
53     vlc_object_internals_t *first; /* first child */
54 };
55
56 # define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
57 # define vlc_externals( priv ) ((vlc_object_t *)((priv) + 1))
58
59
60 typedef struct callback_entry_t callback_entry_t;
61
62 typedef struct variable_ops_t
63 {
64     int  (*pf_cmp) ( vlc_value_t, vlc_value_t );
65     void (*pf_dup) ( vlc_value_t * );
66     void (*pf_free) ( vlc_value_t * );
67 } variable_ops_t;
68
69 typedef struct callback_table_t
70 {
71     int                i_entries;
72     callback_entry_t * p_entries;
73 } callback_table_t;
74
75 /**
76  * The structure describing a variable.
77  * \note vlc_value_t is the common union for variable values
78  */
79 struct variable_t
80 {
81     char *       psz_name; /**< The variable unique name (must be first) */
82
83     /** The variable's exported value */
84     vlc_value_t  val;
85
86     /** The variable display name, mainly for use by the interfaces */
87     char *       psz_text;
88
89     const variable_ops_t *ops;
90
91     int          i_type;   /**< The type of the variable */
92     unsigned     i_usage;  /**< Reference count */
93
94     /** If the variable has min/max/step values */
95     vlc_value_t  min, max, step;
96
97     /** Index of the default choice, if the variable is to be chosen in
98      * a list */
99     int          i_default;
100     /** List of choices */
101     vlc_list_t   choices;
102     /** List of friendly names for the choices */
103     vlc_list_t   choices_text;
104
105     /** Set to TRUE if the variable is in a callback */
106     bool   b_incallback;
107
108     /** Registered value callbacks */
109     callback_table_t    value_callbacks;
110     /** Registered list callbacks */
111     callback_table_t    list_callbacks;
112 };
113
114 extern void var_DestroyAll( vlc_object_t * );
115
116 #endif