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 <stdalign.h>
27 # include <vlc_atomic.h>
28 
29 struct vlc_res;
30 
31 /**
32  * Private LibVLC data for each object.
33  */
34 typedef struct vlc_object_internals vlc_object_internals_t;
35 
36 struct vlc_object_internals
37 {
38     alignas (max_align_t) /* ensure vlc_externals() is maximally aligned */
39     char           *psz_name; /* given name */
40 
41     /* Object variables */
42     void           *var_root;
43     vlc_mutex_t     var_lock;
44     vlc_cond_t      var_wait;
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     vlc_mutex_t tree_lock;
55 
56     /* Object resources */
57     struct vlc_res *resources;
58 };
59 
60 # define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
61 # define vlc_externals( priv ) ((vlc_object_t *)((priv) + 1))
62 
63 void DumpVariables(vlc_object_t *obj);
64 
65 extern void var_DestroyAll( vlc_object_t * );
66 
67 /**
68  * Return a list of all variable names
69  *
70  * There is no warranty that the returned variables will be still alive after
71  * the return of this function.
72  *
73  * @return a NULL terminated list of char *, each elements and the return value
74  * must be freed by the caller
75  */
76 char **var_GetAllNames(vlc_object_t *);
77 
78 #endif
79