]> git.sesse.net Git - vlc/blob - src/modules/modules.h
modules: added a hack to work-around the buggy 64bit runtime on OS X Leopard
[vlc] / src / modules / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
25 # error This header file can only be included from LibVLC.
26 #endif
27
28 #ifndef __LIBVLC_MODULES_H
29 # define __LIBVLC_MODULES_H 1
30
31 /* Number of tries before we unload an unused module */
32 #define MODULE_HIDE_DELAY 50
33
34 /*****************************************************************************
35  * module_bank_t: the module bank
36  *****************************************************************************
37  * This variable is accessed by any function using modules.
38  *****************************************************************************/
39 struct module_bank_t
40 {
41     unsigned         i_usage;
42
43     bool             b_plugins;
44
45     /* Plugins cache */
46     bool             b_cache;
47     bool             b_cache_dirty;
48
49     int            i_cache;
50     module_cache_t **pp_cache;
51
52     int            i_loaded_cache;
53     module_cache_t **pp_loaded_cache;
54
55     module_t       *head;
56 };
57
58 /*****************************************************************************
59  * Module cache description structure
60  *****************************************************************************/
61 struct module_cache_t
62 {
63     /* Mandatory cache entry header */
64     char       *psz_file;
65     int64_t    i_time;
66     int64_t    i_size;
67     bool b_junk;
68
69     /* Optional extra data */
70     module_t *p_module;
71     bool b_used;
72 };
73
74
75 #define MODULE_SHORTCUT_MAX 50
76
77 /* The module handle type. */
78 #if defined(HAVE_DL_DYLD) && !defined(__x86_64__)
79 #   if defined (HAVE_MACH_O_DYLD_H)
80 #       include <mach-o/dyld.h>
81 #   endif
82 typedef NSModule module_handle_t;
83 #elif defined(HAVE_IMAGE_H)
84 typedef int module_handle_t;
85 #elif defined(WIN32) || defined(UNDER_CE)
86 typedef void * module_handle_t;
87 #elif defined(HAVE_DL_DLOPEN)
88 typedef void * module_handle_t;
89 #elif defined(HAVE_DL_SHL_LOAD)
90 typedef shl_t module_handle_t;
91 #endif
92
93 /**
94  * Internal module descriptor
95  */
96 struct module_t
97 {
98     char       *psz_object_name;
99     module_t   *next;
100     module_t   *submodule;
101     module_t   *parent;
102     unsigned    submodule_count;
103     gc_object_t vlc_gc_data;
104     vlc_mutex_t lock;
105
106     /*
107      * Variables set by the module to identify itself
108      */
109     char *psz_shortname;                              /**< Module name */
110     char *psz_longname;                   /**< Module descriptive name */
111     char *psz_help;        /**< Long help string for "special" modules */
112
113     /** Shortcuts to the module */
114     char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
115
116     char    *psz_capability;                                 /**< Capability */
117     int      i_score;                          /**< Score for the capability */
118     uint32_t i_cpu;                           /**< Required CPU capabilities */
119
120     bool b_unloadable;                        /**< Can we be dlclosed? */
121     bool b_reentrant;                           /**< Are we reentrant? */
122     bool b_submodule;                        /**< Is this a submodule? */
123
124     /* Callbacks */
125     int  ( * pf_activate )   ( vlc_object_t * );
126     void ( * pf_deactivate ) ( vlc_object_t * );
127
128     /*
129      * Variables set by the module to store its config options
130      */
131     module_config_t *p_config;             /* Module configuration structure */
132     size_t           confsize;            /* Number of module_config_t items */
133     unsigned int     i_config_items;        /* number of configuration items */
134     unsigned int     i_bool_items;            /* number of bool config items */
135
136     /*
137      * Variables used internally by the module manager
138      */
139     /* Plugin-specific stuff */
140     module_handle_t     handle;                             /* Unique handle */
141     char *              psz_filename;                     /* Module filename */
142
143     bool          b_builtin;  /* Set to true if the module is built in */
144     bool          b_loaded;        /* Set to true if the dll is loaded */
145 };
146
147 module_t *vlc_module_create (vlc_object_t *);
148 module_t *vlc_submodule_create (module_t *module);
149
150 #define module_InitBank(a)     __module_InitBank(VLC_OBJECT(a))
151 void  __module_InitBank        ( vlc_object_t * );
152 void module_LoadPlugins( vlc_object_t *, bool );
153 #define module_LoadPlugins(a,b) module_LoadPlugins(VLC_OBJECT(a),b)
154 void module_EndBank( vlc_object_t *, bool );
155 #define module_EndBank(a,b) module_EndBank(VLC_OBJECT(a), b)
156
157 /* Low-level OS-dependent handler */
158 int  module_Load   (vlc_object_t *, const char *, module_handle_t *);
159 int  module_Call   (vlc_object_t *obj, module_t *);
160 void module_Unload (module_handle_t);
161
162 /* Plugins cache */
163 void   CacheMerge (vlc_object_t *, module_t *, module_t *);
164 void   CacheLoad  (vlc_object_t *, module_bank_t *, bool);
165 void   CacheSave  (vlc_object_t *, module_bank_t *);
166 module_cache_t * CacheFind (module_bank_t *, const char *, int64_t, int64_t);
167
168 #endif /* !__LIBVLC_MODULES_H */