]> git.sesse.net Git - vlc/blob - plugins/beos/beos.cpp
. Attempt to port the BeOS audio plugin to the new module API. Will
[vlc] / plugins / beos / beos.cpp
1 /*****************************************************************************
2  * beos.cpp : BeOS plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000 VideoLAN
5  *
6  * Authors:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 #define MODULE_NAME beos
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "defs.h"
29
30 #include <stdlib.h>                                      /* malloc(), free() */
31
32 extern "C"
33 {
34 #include "config.h"
35 #include "common.h"                                     /* boolean_t, byte_t */
36 #include "threads.h"
37 #include "mtime.h"
38 #include "plugins.h"
39
40 #include "interface.h"
41 #include "audio_output.h"
42 #include "video.h"
43 #include "video_output.h"
44
45 #include "modules.h"
46 #include "modules_inner.h"
47
48 /*****************************************************************************
49  * Build configuration tree.
50  *****************************************************************************/
51 MODULE_CONFIG_START
52 ADD_WINDOW( "Configuration for BeOS module" )
53     ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
54 MODULE_CONFIG_END
55
56 /*****************************************************************************
57  * Capabilities defined in the other files.
58  *****************************************************************************/
59 extern void aout_getfunctions( function_list_t * p_function_list );
60
61 /*****************************************************************************
62  * InitModule: get the module structure and configuration.
63  *****************************************************************************
64  * We have to fill psz_name, psz_longname and psz_version. These variables
65  * will be strdup()ed later by the main application because the module can
66  * be unloaded later to save memory, and we want to be able to access this
67  * data even after the module has been unloaded.
68  *****************************************************************************/
69 int InitModule( module_t * p_module )
70 {
71     p_module->psz_name = MODULE_STRING;
72     p_module->psz_longname = "BeOS standard API module";
73     p_module->psz_version = VERSION;
74
75     p_module->i_capabilities = MODULE_CAPABILITY_NULL
76                                 | MODULE_CAPABILITY_AOUT;
77
78     return( 0 );
79 }
80
81 /*****************************************************************************
82  * ActivateModule: set the module to an usable state.
83  *****************************************************************************
84  * This function fills the capability functions and the configuration
85  * structure. Once ActivateModule() has been called, the i_usage can
86  * be set to 0 and calls to NeedModule() be made to increment it. To unload
87  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
88  *****************************************************************************/
89 int ActivateModule( module_t * p_module )
90 {
91     p_module->p_functions = malloc( sizeof( module_functions_t ) );
92     if( p_module->p_functions == NULL )
93     {
94         return( -1 );
95     }
96
97     aout_getfunctions( &p_module->p_functions->aout );
98
99     p_module->p_config = p_config;
100
101     return( 0 );
102 }
103
104 /*****************************************************************************
105  * DeactivateModule: make sure the module can be unloaded.
106  *****************************************************************************
107  * This function must only be called when i_usage == 0. If it successfully
108  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
109  * lock usage_lock during the whole process.
110  *****************************************************************************/
111 int DeactivateModule( module_t * p_module )
112 {
113     free( p_module->p_functions );
114
115     return( 0 );
116 }
117
118 /* OLD MODULE STRUCTURE -- soon to be removed */
119
120 /*****************************************************************************
121  * Exported prototypes
122  *****************************************************************************/
123 static void vout_GetPlugin( p_vout_thread_t p_vout );
124 static void intf_GetPlugin( p_intf_thread_t p_intf );
125
126 /* Video output */
127 int     vout_BeCreate       ( vout_thread_t *p_vout, char *psz_display,
128                               int i_root_window, void *p_data );
129 int     vout_BeInit         ( p_vout_thread_t p_vout );
130 void    vout_BeEnd          ( p_vout_thread_t p_vout );
131 void    vout_BeDestroy      ( p_vout_thread_t p_vout );
132 int     vout_BeManage       ( p_vout_thread_t p_vout );
133 void    vout_BeDisplay      ( p_vout_thread_t p_vout );
134 void    vout_BeSetPalette   ( p_vout_thread_t p_vout,
135                               u16 *red, u16 *green, u16 *blue, u16 *transp );
136
137 /* Interface */
138 int     intf_BeCreate       ( p_intf_thread_t p_intf );
139 void    intf_BeDestroy      ( p_intf_thread_t p_intf );
140 void    intf_BeManage       ( p_intf_thread_t p_intf );
141
142 /*****************************************************************************
143  * GetConfig: get the plugin structure and configuration
144  *****************************************************************************/
145 plugin_info_t * GetConfig( void )
146 {
147     plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
148
149     p_info->psz_name    = "BeOS";
150     p_info->psz_version = VERSION;
151     p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
152
153     p_info->aout_GetPlugin = NULL;
154     p_info->vout_GetPlugin = vout_GetPlugin;
155     p_info->intf_GetPlugin = intf_GetPlugin;
156     p_info->yuv_GetPlugin = NULL;
157
158     /* the beos plugin always works under BeOS :) */
159     p_info->i_score = 0x800;
160
161     return( p_info );
162 }
163
164 /*****************************************************************************
165  * Following functions are only called through the p_info structure
166  *****************************************************************************/
167
168 static void vout_GetPlugin( p_vout_thread_t p_vout )
169 {
170     p_vout->p_sys_create  = vout_BeCreate;
171     p_vout->p_sys_init    = vout_BeInit;
172     p_vout->p_sys_end     = vout_BeEnd;
173     p_vout->p_sys_destroy = vout_BeDestroy;
174     p_vout->p_sys_manage  = vout_BeManage;
175     p_vout->p_sys_display = vout_BeDisplay;
176 }
177
178 static void intf_GetPlugin( p_intf_thread_t p_intf )
179 {
180     p_intf->p_sys_create  = intf_BeCreate;
181     p_intf->p_sys_destroy = intf_BeDestroy;
182     p_intf->p_sys_manage  = intf_BeManage;
183 }
184
185 } /* extern "C" */