1 /*****************************************************************************
2 * sdl.c : SDL plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000 VideoLAN
7 * . Initial plugin code by Samuel Hocevar <sam@via.ecp.fr>
8 * . Modified to use the SDL by Pierre Baillet <octplane@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 #define MODULE_NAME sdl
27 /*****************************************************************************
29 *****************************************************************************/
32 #include <stdlib.h> /* malloc(), free() */
35 #include "common.h" /* boolean_t, byte_t */
41 #include "interface.h"
42 #include "audio_output.h"
44 #include "video_output.h"
48 #include "modules_inner.h"
50 /*****************************************************************************
51 * Building configuration tree
52 *****************************************************************************/
55 ADD_WINDOW( "Configuration for sdl module" )
56 ADD_COMMENT( "For now, the sdl module cannot be configured" )
61 /*****************************************************************************
63 *****************************************************************************/
64 static void vout_GetPlugin( p_vout_thread_t p_vout );
65 static void intf_GetPlugin( p_intf_thread_t p_intf );
69 int vout_SDLCreate ( vout_thread_t *p_vout, char *psz_display,
70 int i_root_window, void *p_data );
71 int vout_SDLInit ( p_vout_thread_t p_vout );
72 void vout_SDLEnd ( p_vout_thread_t p_vout );
73 void vout_SDLDestroy ( p_vout_thread_t p_vout );
74 int vout_SDLManage ( p_vout_thread_t p_vout );
75 void vout_SDLDisplay ( p_vout_thread_t p_vout );
76 void vout_SDLSetPalette ( p_vout_thread_t p_vout,
77 u16 *red, u16 *green, u16 *blue, u16 *transp );
79 int intf_SDLCreate ( p_intf_thread_t p_intf );
80 void intf_SDLDestroy ( p_intf_thread_t p_intf );
81 void intf_SDLManage ( p_intf_thread_t p_intf );
84 /*****************************************************************************
85 * * Capabilities defined in the other files.
86 ******************************************************************************/
87 extern void aout_getfunctions( function_list_t * p_function_list );
89 /*****************************************************************************
90 * GetConfig: get the plugin structure and configuration
91 *****************************************************************************/
92 plugin_info_t * GetConfig( void )
94 plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
96 p_info->psz_name = "SDL (video)";
97 p_info->psz_version = VERSION;
98 p_info->psz_author = "the VideoLAN team <vlc@videolan.org>";
100 p_info->aout_GetPlugin = NULL;
101 p_info->vout_GetPlugin = vout_GetPlugin;
102 p_info->intf_GetPlugin = intf_GetPlugin;
103 p_info->yuv_GetPlugin = NULL;
106 /* if the SDL libraries are there, assume we can enter the
107 * initialization part at least, even if we fail afterwards */
109 p_info->i_score = 0x100;
111 /* If this plugin was requested, score it higher */
112 if( TestMethod( VOUT_METHOD_VAR, "sdl" ) )
114 p_info->i_score += 0x200;
120 /*****************************************************************************
121 * Following functions are only called through the p_info structure
122 *****************************************************************************/
124 static void vout_GetPlugin( p_vout_thread_t p_vout )
126 p_vout->p_sys_create = vout_SDLCreate;
127 p_vout->p_sys_init = vout_SDLInit;
128 p_vout->p_sys_end = vout_SDLEnd;
129 p_vout->p_sys_destroy = vout_SDLDestroy;
130 p_vout->p_sys_manage = vout_SDLManage;
131 p_vout->p_sys_display = vout_SDLDisplay;
132 p_vout->p_set_palette = vout_SDLSetPalette;
136 static void intf_GetPlugin( p_intf_thread_t p_intf )
138 p_intf->p_sys_create = intf_SDLCreate;
139 p_intf->p_sys_destroy = intf_SDLDestroy;
140 p_intf->p_sys_manage = intf_SDLManage;
143 /*****************************************************************************
144 * Audio stuff: All the new modules things
145 *****************************************************************************/
147 /*****************************************************************************
148 * InitModule: get the module structure and configuration.
149 *****************************************************************************
150 * We have to fill psz_name, psz_longname and psz_version. These variables
151 * will be strdup()ed later by the main application because the module can
152 * be unloaded later to save memory, and we want to be able to access this
153 * data even after the module has been unloaded.
154 *****************************************************************************/
155 int InitModule( module_t * p_module )
157 p_module->psz_name = MODULE_STRING;
158 p_module->psz_longname = "Linux SDL audio module";
159 p_module->psz_version = VERSION;
161 p_module->i_capabilities = MODULE_CAPABILITY_NULL
162 | MODULE_CAPABILITY_AOUT;
167 /*****************************************************************************
168 * ActivateModule: set the module to an usable state.
169 *****************************************************************************
170 * This function fills the capability functions and the configuration
171 * structure. Once ActivateModule() has been called, the i_usage can
172 * be set to 0 and calls to NeedModule() be made to increment it. To unload
173 * the module, one has to wait until i_usage == 0 and call DeactivateModule().
174 *****************************************************************************/
175 int ActivateModule( module_t * p_module )
177 p_module->p_functions = malloc( sizeof( module_functions_t ) );
178 if( p_module->p_functions == NULL )
183 aout_getfunctions( &p_module->p_functions->aout );
185 p_module->p_config = p_config;
190 /*****************************************************************************
191 * DeactivateModule: make sure the module can be unloaded.
192 *****************************************************************************
193 * This function must only be called when i_usage == 0. If it successfully
194 * returns, i_usage can be set to -1 and the module unloaded. Be careful to
195 * lock usage_lock during the whole process.
196 *****************************************************************************/
197 int DeactivateModule( module_t * p_module )
199 free( p_module->p_functions );