Big round of fixes in the aout3.
[vlc.git] / src / misc / modules_plugin.h
1 /*****************************************************************************
2  * modules_plugin.h : Plugin management functions used by the core application.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * Automatically generated from src/misc/modules_plugin.h.in by bootstrap.sh
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  * Inline functions for handling dynamic modules
26  *****************************************************************************/
27
28 /*****************************************************************************
29  * module_load: load a dynamic library
30  *****************************************************************************
31  * This function loads a dynamically linked library using a system dependant
32  * method, and returns a non-zero value on error, zero otherwise.
33  *****************************************************************************/
34 static int module_load( const char * psz_filename, module_handle_t * handle )
35 {
36 #ifdef SYS_BEOS
37     *handle = load_add_on( psz_filename );
38     return( *handle < 0 );
39
40 #elif defined(WIN32)
41     *handle = LoadLibrary( psz_filename );
42     return( *handle == NULL ); 
43
44 #elif defined(RTLD_NOW)
45 #   if defined(SYS_LINUX)
46     /* We should NOT open modules with RTLD_GLOBAL, or we are going to get
47      * namespace collisions when two modules have common public symbols,
48      * but ALSA is being a pest here. */
49     if( strstr( psz_filename, "alsa.so" ) )
50     {
51         *handle = dlopen( psz_filename, RTLD_NOW | RTLD_GLOBAL );
52         return( *handle == NULL );
53     }
54 #   endif
55     *handle = dlopen( psz_filename, RTLD_NOW );
56     return( *handle == NULL );
57
58 #else
59     *handle = dlopen( psz_filename, DL_LAZY );
60     return( *handle == NULL );
61
62 #endif
63 }
64
65 /*****************************************************************************
66  * module_unload: unload a dynamic library
67  *****************************************************************************
68  * This function unloads a previously opened dynamically linked library
69  * using a system dependant method. No return value is taken in consideration,
70  * since some libraries sometimes refuse to close properly.
71  *****************************************************************************/
72 static void module_unload( module_handle_t handle )
73 {
74 #ifdef SYS_BEOS
75     unload_add_on( handle );
76
77 #elif defined(WIN32)
78     FreeLibrary( handle );
79
80 #else
81     dlclose( handle );
82
83 #endif
84     return;
85 }
86
87 /*****************************************************************************
88  * module_getsymbol: get a symbol from a dynamic library
89  *****************************************************************************
90  * This function queries a loaded library for a symbol specified in a
91  * string, and returns a pointer to it. We don't check for dlerror() or
92  * similar functions, since we want a non-NULL symbol anyway.
93  *****************************************************************************/
94 static void * _module_getsymbol( module_handle_t handle,
95                                  const char * psz_function )
96 {
97 #ifdef SYS_BEOS
98     void * p_symbol;
99     if( B_OK == get_image_symbol( handle, psz_function,
100                                   B_SYMBOL_TYPE_TEXT, &p_symbol ) )
101     {
102         return( p_symbol );
103     }
104     else
105     {
106         return( NULL );
107     }
108
109 #elif defined(WIN32)
110     return( (void *)GetProcAddress( handle, psz_function ) );
111
112 #else
113     return( dlsym( handle, psz_function ) );
114
115 #endif
116 }
117
118 static void * module_getsymbol( module_handle_t handle,
119                                 const char * psz_function )
120 {
121     void * p_symbol = _module_getsymbol( handle, psz_function );
122
123     /* MacOS X dl library expects symbols to begin with "_". So do
124      * some other operating systems. That's really lame, but hey, what
125      * can we do ? */
126     if( p_symbol == NULL )
127     {
128         char *psz_call = malloc( strlen( psz_function ) + 2 );
129
130         strcpy( psz_call + 1, psz_function );
131         psz_call[ 0 ] = '_';
132         p_symbol = _module_getsymbol( handle, psz_call );
133         free( psz_call );
134     }
135
136     return p_symbol;
137 }
138
139 /*****************************************************************************
140  * module_error: wrapper for dlerror()
141  *****************************************************************************
142  * This function returns the error message of the last module operation. It
143  * returns the string "failed" on systems which do not have a dlerror() like
144  * function. psz_buffer can be used to store temporary data, it is guaranteed
145  * to be kept intact until the return value of module_error has been used.
146  *****************************************************************************/
147 static const char * module_error( char *psz_buffer )
148 {
149 #if defined(SYS_BEOS)
150     return( "failed" );
151
152 #elif defined(WIN32)
153     int i, i_error = GetLastError();
154
155     FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
156                    NULL, i_error, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
157                    (LPTSTR) psz_buffer, 256, NULL);
158
159     /* Go to the end of the string */
160     for( i = 0;
161          psz_buffer[i] && psz_buffer[i] != '\r' && psz_buffer[i] != '\n';
162          i++ ) {};
163
164     if( psz_buffer[i] )
165     {
166         snprintf( psz_buffer + i, 256 - i, " (error %i)", i_error );
167         psz_buffer[ 255 ] = '\0';
168     }
169     
170     return psz_buffer;
171
172 #else
173     return( dlerror() );
174
175 #endif
176 }
177
178 /*****************************************************************************
179  * STORE_SYMBOLS: store known symbols into p_symbols for plugin access.
180  *****************************************************************************/
181 #define STORE_SYMBOLS( p_symbols ) \
182     (p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \
183     (p_symbols)->__aout_NewInstance_inner = __aout_NewInstance; \
184     (p_symbols)->aout_DeleteInstance_inner = aout_DeleteInstance; \
185     (p_symbols)->aout_BufferNew_inner = aout_BufferNew; \
186     (p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \
187     (p_symbols)->aout_BufferPlay_inner = aout_BufferPlay; \
188     (p_symbols)->aout_DateInit_inner = aout_DateInit; \
189     (p_symbols)->aout_DateSet_inner = aout_DateSet; \
190     (p_symbols)->aout_DateMove_inner = aout_DateMove; \
191     (p_symbols)->aout_DateGet_inner = aout_DateGet; \
192     (p_symbols)->aout_DateIncrement_inner = aout_DateIncrement; \
193     (p_symbols)->__aout_InputNew_inner = __aout_InputNew; \
194     (p_symbols)->aout_InputDelete_inner = aout_InputDelete; \
195     (p_symbols)->__config_GetInt_inner = __config_GetInt; \
196     (p_symbols)->__config_PutInt_inner = __config_PutInt; \
197     (p_symbols)->__config_GetFloat_inner = __config_GetFloat; \
198     (p_symbols)->__config_PutFloat_inner = __config_PutFloat; \
199     (p_symbols)->__config_GetPsz_inner = __config_GetPsz; \
200     (p_symbols)->__config_PutPsz_inner = __config_PutPsz; \
201     (p_symbols)->__config_LoadCmdLine_inner = __config_LoadCmdLine; \
202     (p_symbols)->config_GetHomeDir_inner = config_GetHomeDir; \
203     (p_symbols)->__config_LoadConfigFile_inner = __config_LoadConfigFile; \
204     (p_symbols)->__config_SaveConfigFile_inner = __config_SaveConfigFile; \
205     (p_symbols)->config_FindConfig_inner = config_FindConfig; \
206     (p_symbols)->config_Duplicate_inner = config_Duplicate; \
207     (p_symbols)->config_SetCallbacks_inner = config_SetCallbacks; \
208     (p_symbols)->config_UnsetCallbacks_inner = config_UnsetCallbacks; \
209     (p_symbols)->InitBitstream_inner = InitBitstream; \
210     (p_symbols)->NextDataPacket_inner = NextDataPacket; \
211     (p_symbols)->BitstreamNextDataPacket_inner = BitstreamNextDataPacket; \
212     (p_symbols)->UnalignedShowBits_inner = UnalignedShowBits; \
213     (p_symbols)->UnalignedRemoveBits_inner = UnalignedRemoveBits; \
214     (p_symbols)->UnalignedGetBits_inner = UnalignedGetBits; \
215     (p_symbols)->CurrentPTS_inner = CurrentPTS; \
216     (p_symbols)->DecoderError_inner = DecoderError; \
217     (p_symbols)->__input_SetStatus_inner = __input_SetStatus; \
218     (p_symbols)->__input_Seek_inner = __input_Seek; \
219     (p_symbols)->__input_Tell_inner = __input_Tell; \
220     (p_symbols)->input_DumpStream_inner = input_DumpStream; \
221     (p_symbols)->input_OffsetToTime_inner = input_OffsetToTime; \
222     (p_symbols)->input_ToggleES_inner = input_ToggleES; \
223     (p_symbols)->input_ChangeArea_inner = input_ChangeArea; \
224     (p_symbols)->input_ChangeProgram_inner = input_ChangeProgram; \
225     (p_symbols)->input_InitStream_inner = input_InitStream; \
226     (p_symbols)->input_EndStream_inner = input_EndStream; \
227     (p_symbols)->input_FindProgram_inner = input_FindProgram; \
228     (p_symbols)->input_AddProgram_inner = input_AddProgram; \
229     (p_symbols)->input_DelProgram_inner = input_DelProgram; \
230     (p_symbols)->input_SetProgram_inner = input_SetProgram; \
231     (p_symbols)->input_AddArea_inner = input_AddArea; \
232     (p_symbols)->input_DelArea_inner = input_DelArea; \
233     (p_symbols)->input_FindES_inner = input_FindES; \
234     (p_symbols)->input_AddES_inner = input_AddES; \
235     (p_symbols)->input_DelES_inner = input_DelES; \
236     (p_symbols)->input_SelectES_inner = input_SelectES; \
237     (p_symbols)->input_UnselectES_inner = input_UnselectES; \
238     (p_symbols)->input_DecodePES_inner = input_DecodePES; \
239     (p_symbols)->input_ClockManageControl_inner = input_ClockManageControl; \
240     (p_symbols)->input_ClockManageRef_inner = input_ClockManageRef; \
241     (p_symbols)->input_ClockGetTS_inner = input_ClockGetTS; \
242     (p_symbols)->input_InfoCategory_inner = input_InfoCategory; \
243     (p_symbols)->input_AddInfo_inner = input_AddInfo; \
244     (p_symbols)->input_BuffersEnd_inner = input_BuffersEnd; \
245     (p_symbols)->input_NewBuffer_inner = input_NewBuffer; \
246     (p_symbols)->input_ReleaseBuffer_inner = input_ReleaseBuffer; \
247     (p_symbols)->input_ShareBuffer_inner = input_ShareBuffer; \
248     (p_symbols)->input_NewPacket_inner = input_NewPacket; \
249     (p_symbols)->input_DeletePacket_inner = input_DeletePacket; \
250     (p_symbols)->input_NewPES_inner = input_NewPES; \
251     (p_symbols)->input_DeletePES_inner = input_DeletePES; \
252     (p_symbols)->input_FillBuffer_inner = input_FillBuffer; \
253     (p_symbols)->input_Peek_inner = input_Peek; \
254     (p_symbols)->input_SplitBuffer_inner = input_SplitBuffer; \
255     (p_symbols)->input_AccessInit_inner = input_AccessInit; \
256     (p_symbols)->input_AccessReinit_inner = input_AccessReinit; \
257     (p_symbols)->input_AccessEnd_inner = input_AccessEnd; \
258     (p_symbols)->__input_FDClose_inner = __input_FDClose; \
259     (p_symbols)->__input_FDNetworkClose_inner = __input_FDNetworkClose; \
260     (p_symbols)->input_FDRead_inner = input_FDRead; \
261     (p_symbols)->input_FDNetworkRead_inner = input_FDNetworkRead; \
262     (p_symbols)->input_FDSeek_inner = input_FDSeek; \
263     (p_symbols)->__intf_Create_inner = __intf_Create; \
264     (p_symbols)->intf_RunThread_inner = intf_RunThread; \
265     (p_symbols)->intf_StopThread_inner = intf_StopThread; \
266     (p_symbols)->intf_Destroy_inner = intf_Destroy; \
267     (p_symbols)->__intf_Eject_inner = __intf_Eject; \
268     (p_symbols)->GetLang_1_inner = GetLang_1; \
269     (p_symbols)->GetLang_2T_inner = GetLang_2T; \
270     (p_symbols)->GetLang_2B_inner = GetLang_2B; \
271     (p_symbols)->DecodeLanguage_inner = DecodeLanguage; \
272     (p_symbols)->__module_Need_inner = __module_Need; \
273     (p_symbols)->__module_Unneed_inner = __module_Unneed; \
274     (p_symbols)->mstrtime_inner = mstrtime; \
275     (p_symbols)->mdate_inner = mdate; \
276     (p_symbols)->mwait_inner = mwait; \
277     (p_symbols)->msleep_inner = msleep; \
278     (p_symbols)->__network_ChannelJoin_inner = __network_ChannelJoin; \
279     (p_symbols)->__network_ChannelCreate_inner = __network_ChannelCreate; \
280     (p_symbols)->__sout_NewInstance_inner = __sout_NewInstance; \
281     (p_symbols)->sout_DeleteInstance_inner = sout_DeleteInstance; \
282     (p_symbols)->__vout_CreateThread_inner = __vout_CreateThread; \
283     (p_symbols)->vout_DestroyThread_inner = vout_DestroyThread; \
284     (p_symbols)->vout_ChromaCmp_inner = vout_ChromaCmp; \
285     (p_symbols)->vout_CreatePicture_inner = vout_CreatePicture; \
286     (p_symbols)->vout_AllocatePicture_inner = vout_AllocatePicture; \
287     (p_symbols)->vout_DestroyPicture_inner = vout_DestroyPicture; \
288     (p_symbols)->vout_DisplayPicture_inner = vout_DisplayPicture; \
289     (p_symbols)->vout_DatePicture_inner = vout_DatePicture; \
290     (p_symbols)->vout_LinkPicture_inner = vout_LinkPicture; \
291     (p_symbols)->vout_UnlinkPicture_inner = vout_UnlinkPicture; \
292     (p_symbols)->vout_PlacePicture_inner = vout_PlacePicture; \
293     (p_symbols)->vout_CreateSubPicture_inner = vout_CreateSubPicture; \
294     (p_symbols)->vout_DestroySubPicture_inner = vout_DestroySubPicture; \
295     (p_symbols)->vout_DisplaySubPicture_inner = vout_DisplaySubPicture; \
296     (p_symbols)->__msg_Generic_inner = __msg_Generic; \
297     (p_symbols)->__msg_Info_inner = __msg_Info; \
298     (p_symbols)->__msg_Err_inner = __msg_Err; \
299     (p_symbols)->__msg_Warn_inner = __msg_Warn; \
300     (p_symbols)->__msg_Dbg_inner = __msg_Dbg; \
301     (p_symbols)->__msg_Subscribe_inner = __msg_Subscribe; \
302     (p_symbols)->__msg_Unsubscribe_inner = __msg_Unsubscribe; \
303     (p_symbols)->__vlc_object_create_inner = __vlc_object_create; \
304     (p_symbols)->__vlc_object_destroy_inner = __vlc_object_destroy; \
305     (p_symbols)->__vlc_object_attach_inner = __vlc_object_attach; \
306     (p_symbols)->__vlc_object_detach_inner = __vlc_object_detach; \
307     (p_symbols)->__vlc_object_find_inner = __vlc_object_find; \
308     (p_symbols)->__vlc_object_yield_inner = __vlc_object_yield; \
309     (p_symbols)->__vlc_object_release_inner = __vlc_object_release; \
310     (p_symbols)->__vlc_list_find_inner = __vlc_list_find; \
311     (p_symbols)->vlc_list_release_inner = vlc_list_release; \
312     (p_symbols)->__vlc_liststructure_inner = __vlc_liststructure; \
313     (p_symbols)->__vlc_dumpstructure_inner = __vlc_dumpstructure; \
314     (p_symbols)->playlist_Command_inner = playlist_Command; \
315     (p_symbols)->playlist_Add_inner = playlist_Add; \
316     (p_symbols)->playlist_Delete_inner = playlist_Delete; \
317     (p_symbols)->__vlc_threads_init_inner = __vlc_threads_init; \
318     (p_symbols)->__vlc_threads_end_inner = __vlc_threads_end; \
319     (p_symbols)->__vlc_mutex_init_inner = __vlc_mutex_init; \
320     (p_symbols)->__vlc_mutex_destroy_inner = __vlc_mutex_destroy; \
321     (p_symbols)->__vlc_cond_init_inner = __vlc_cond_init; \
322     (p_symbols)->__vlc_cond_destroy_inner = __vlc_cond_destroy; \
323     (p_symbols)->__vlc_thread_create_inner = __vlc_thread_create; \
324     (p_symbols)->__vlc_thread_ready_inner = __vlc_thread_ready; \
325     (p_symbols)->__vlc_thread_join_inner = __vlc_thread_join; \
326