1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 the VideoLAN team
7 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
24 #if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
25 # error This header file can only be included from LibVLC.
28 #ifndef __LIBVLC_MODULES_H
29 # define __LIBVLC_MODULES_H 1
32 /* Number of tries before we unload an unused module */
33 #define MODULE_HIDE_DELAY 50
35 /*****************************************************************************
36 * module_bank_t: the module bank
37 *****************************************************************************
38 * This variable is accessed by any function using modules.
39 *****************************************************************************/
55 module_cache_t **pp_cache;
58 module_cache_t **pp_loaded_cache;
63 /*****************************************************************************
64 * Module cache description structure
65 *****************************************************************************/
68 /* Mandatory cache entry header */
74 /* Optional extra data */
80 #define MODULE_SHORTCUT_MAX 50
82 /* The module handle type. */
83 #if defined(HAVE_DL_DYLD)
84 # if defined (HAVE_MACH_O_DYLD_H)
85 # include <mach-o/dyld.h>
87 typedef NSModule module_handle_t;
88 #elif defined(HAVE_IMAGE_H)
89 typedef int module_handle_t;
90 #elif defined(WIN32) || defined(UNDER_CE)
91 typedef void * module_handle_t;
92 #elif defined(HAVE_DL_DLOPEN)
93 typedef void * module_handle_t;
94 #elif defined(HAVE_DL_SHL_LOAD)
95 typedef shl_t module_handle_t;
99 * Internal module descriptor
103 char *psz_object_name;
107 unsigned submodule_count;
108 gc_object_t vlc_gc_data;
112 * Variables set by the module to identify itself
114 char *psz_shortname; /**< Module name */
115 char *psz_longname; /**< Module descriptive name */
116 char *psz_help; /**< Long help string for "special" modules */
118 /** Shortcuts to the module */
119 char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
121 char *psz_capability; /**< Capability */
122 int i_score; /**< Score for the capability */
123 uint32_t i_cpu; /**< Required CPU capabilities */
125 bool b_unloadable; /**< Can we be dlclosed? */
126 bool b_reentrant; /**< Are we reentrant? */
127 bool b_submodule; /**< Is this a submodule? */
130 int ( * pf_activate ) ( vlc_object_t * );
131 void ( * pf_deactivate ) ( vlc_object_t * );
134 * Variables set by the module to store its config options
136 module_config_t *p_config; /* Module configuration structure */
137 size_t confsize; /* Number of module_config_t items */
138 unsigned int i_config_items; /* number of configuration items */
139 unsigned int i_bool_items; /* number of bool config items */
142 * Variables used internally by the module manager
144 /* Plugin-specific stuff */
145 module_handle_t handle; /* Unique handle */
146 char * psz_filename; /* Module filename */
148 bool b_builtin; /* Set to true if the module is built in */
149 bool b_loaded; /* Set to true if the dll is loaded */
152 static inline module_t *module_hold (module_t *m)
154 vlc_hold (&m->vlc_gc_data);
158 static inline void module_release (module_t *m)
160 vlc_release (&m->vlc_gc_data);
163 #define module_InitBank(a) __module_InitBank(VLC_OBJECT(a))
164 void __module_InitBank ( vlc_object_t * );
165 #define module_LoadBuiltins(a) __module_LoadBuiltins(VLC_OBJECT(a))
166 void __module_LoadBuiltins ( vlc_object_t * );
167 #define module_LoadPlugins(a) __module_LoadPlugins(VLC_OBJECT(a))
168 void __module_LoadPlugins ( vlc_object_t * );
169 #define module_EndBank(a) __module_EndBank(VLC_OBJECT(a))
170 void __module_EndBank ( vlc_object_t * );
171 #define module_ResetBank(a) __module_ResetBank(VLC_OBJECT(a))
172 void __module_ResetBank ( vlc_object_t * );
174 /* Low-level OS-dependent handler */
175 int module_Load (vlc_object_t *, const char *, module_handle_t *);
176 int module_Call (vlc_object_t *obj, module_t *);
177 void module_Unload (module_handle_t);
180 void CacheMerge (vlc_object_t *, module_t *, module_t *);
181 void CacheLoad (vlc_object_t * );
182 void CacheSave (vlc_object_t * );
183 module_cache_t * CacheFind (const char *, int64_t, int64_t);
185 #endif /* !__LIBVLC_MODULES_H */