]> git.sesse.net Git - vlc/blob - include/modules.h
* ALL: new module API. Makes a few things a lot simpler, and we gain
[vlc] / include / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: modules.h,v 1.59 2002/07/31 20:56:50 sam Exp $
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Module #defines.
26  *****************************************************************************/
27
28 /* Number of tries before we unload an unused module */
29 #define MODULE_HIDE_DELAY 50
30 #define MODULE_SHORTCUT_MAX 10
31
32 /* The module handle type. */
33 #ifdef SYS_BEOS
34 typedef int     module_handle_t;
35 #else
36 typedef void *  module_handle_t;
37 #endif
38
39 /*****************************************************************************
40  * module_bank_t: the module bank
41  *****************************************************************************
42  * This variable is accessed by any function using modules.
43  *****************************************************************************/
44 struct module_bank_t
45 {
46     VLC_COMMON_MEMBERS
47
48     module_t *   first;                          /* First module in the bank */
49     int          i_count;                     /* Number of allocated modules */
50
51     vlc_mutex_t  lock;         /* Global lock -- you can't imagine how awful *
52                                     it is to design thread-safe linked lists */
53     module_symbols_t symbols;
54 };
55
56 /*****************************************************************************
57  * Module description structure
58  *****************************************************************************/
59 struct module_t
60 {
61     VLC_COMMON_MEMBERS
62
63     /*
64      * Variables set by the module to identify itself
65      */
66     char *psz_longname;                           /* Module descriptive name */
67
68     /*
69      * Variables set by the module to tell us what it can do
70      */
71     char *psz_program;        /* Program name which will activate the module */
72
73     char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];    /* Shortcuts to the module */
74
75     char *psz_capability;                                      /* Capability */
76     int   i_score;                              /* Score for each capability */
77     u32   i_cpu;                                /* Required CPU capabilities */
78
79     vlc_bool_t b_submodule;                          /* Is this a submodule? */
80
81     /* Callbacks */
82     int  ( * pf_activate )   ( vlc_object_t * );
83     void ( * pf_deactivate ) ( vlc_object_t * );
84
85     /*
86      * Variables set by the module to store its config options
87      */
88     module_config_t *p_config;             /* Module configuration structure */
89     unsigned int     i_config_items;        /* number of configuration items */
90     unsigned int     i_bool_items;            /* number of bool config items */
91
92     /*
93      * Variables used internally by the module manager
94      */
95     /* Plugin-specific stuff */
96     module_handle_t     handle;                             /* Unique handle */
97     char *              psz_filename;                     /* Module filename */
98
99     vlc_bool_t          b_builtin;  /* Set to true if the module is built in */
100
101     int   i_usage;                                      /* Reference counter */
102     int   i_unused_delay;                  /* Delay until module is unloaded */
103
104     module_t *next;                                           /* Next module */
105     module_t *prev;                                       /* Previous module */
106
107     /*
108      * Symbol table we send to the module so that it can access vlc symbols
109      */
110     module_symbols_t *p_symbols;
111 };
112
113 /*****************************************************************************
114  * Exported functions.
115  *****************************************************************************/
116 #define module_InitBank(a)     __module_InitBank(VLC_OBJECT(a))
117 void  __module_InitBank        ( vlc_object_t * );
118 #define module_LoadMain(a)     __module_LoadMain(VLC_OBJECT(a))
119 void  __module_LoadMain        ( vlc_object_t * );
120 #define module_LoadBuiltins(a) __module_LoadBuiltins(VLC_OBJECT(a))
121 void  __module_LoadBuiltins    ( vlc_object_t * );
122 #define module_LoadPlugins(a)  __module_LoadPlugins(VLC_OBJECT(a))
123 void  __module_LoadPlugins     ( vlc_object_t * );
124 #define module_EndBank(a)      __module_EndBank(VLC_OBJECT(a))
125 void  __module_EndBank         ( vlc_object_t * );
126 #define module_ResetBank(a)    __module_ResetBank(VLC_OBJECT(a))
127 void  __module_ResetBank       ( vlc_object_t * );
128 #define module_ManageBank(a)   __module_ManageBank(VLC_OBJECT(a))
129 void  __module_ManageBank      ( vlc_object_t * );
130
131 #define module_Need(a,b,c) __module_Need(VLC_OBJECT(a),b,c)
132 VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, const char *, const char * ) );
133 #define module_Unneed(a,b) __module_Unneed(VLC_OBJECT(a),b)
134 VLC_EXPORT( void, __module_Unneed, ( vlc_object_t *, module_t * ) );
135