*****************************************************************************
* Copyright (C) 2000 VideoLAN
*
- * Authors:
- *
+ * Authors: Samuel Hocevar <sam@zoy.org>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME gnome
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
-#include <X11/Xlib.h>
-
#include "config.h"
#include "common.h" /* boolean_t, byte_t */
#include "threads.h"
#include "mtime.h"
-#include "tests.h"
-#include "plugins.h"
-#include "interface.h"
-#include "audio_output.h"
-#include "video.h"
-#include "video_output.h"
+#include "modules.h"
+
+/*****************************************************************************
+ * Building configuration tree
+ *****************************************************************************/
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for Gnome module" )
+ ADD_COMMENT( "For now, the Gnome module cannot be configured" )
+MODULE_CONFIG_END
-#include "main.h"
+/*****************************************************************************
+ * Capabilities defined in the other files.
+ ******************************************************************************/
+void _M( intf_getfunctions )( function_list_t * p_function_list );
/*****************************************************************************
- * Exported prototypes
+ * InitModule: get the module structure and configuration.
+ *****************************************************************************
+ * We have to fill psz_name, psz_longname and psz_version. These variables
+ * will be strdup()ed later by the main application because the module can
+ * be unloaded later to save memory, and we want to be able to access this
+ * data even after the module has been unloaded.
*****************************************************************************/
-static void vout_GetPlugin( p_vout_thread_t p_vout );
-static void intf_GetPlugin( p_intf_thread_t p_intf );
-
-/* Video output */
-int vout_GnomeCreate ( vout_thread_t *p_vout, char *psz_display,
- int i_root_window, void *p_data );
-int vout_GnomeInit ( p_vout_thread_t p_vout );
-void vout_GnomeEnd ( p_vout_thread_t p_vout );
-void vout_GnomeDestroy ( p_vout_thread_t p_vout );
-int vout_GnomeManage ( p_vout_thread_t p_vout );
-void vout_GnomeDisplay ( p_vout_thread_t p_vout );
-void vout_GnomeSetPalette ( p_vout_thread_t p_vout, u16 *red,
- u16 *green, u16 *blue, u16 *transp );
-
-/* Interface */
-int intf_GnomeCreate ( p_intf_thread_t p_intf );
-void intf_GnomeDestroy ( p_intf_thread_t p_intf );
-void intf_GnomeManage ( p_intf_thread_t p_intf );
+MODULE_INIT
+{
+ p_module->psz_name = MODULE_STRING;
+ p_module->psz_longname = "Gnome interface module";
+ p_module->psz_version = VERSION;
+
+ p_module->i_capabilities = MODULE_CAPABILITY_NULL
+ | MODULE_CAPABILITY_INTF;
+
+ return( 0 );
+}
/*****************************************************************************
- * GetConfig: get the plugin structure and configuration
+ * ActivateModule: set the module to an usable state.
+ *****************************************************************************
+ * This function fills the capability functions and the configuration
+ * structure. Once ActivateModule() has been called, the i_usage can
+ * be set to 0 and calls to NeedModule() be made to increment it. To unload
+ * the module, one has to wait until i_usage == 0 and call DeactivateModule().
*****************************************************************************/
-plugin_info_t * GetConfig( void )
+MODULE_ACTIVATE
{
- Display *p_display;
- plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
-
- p_info->psz_name = "Gnome";
- p_info->psz_version = VERSION;
- p_info->psz_author = "the VideoLAN team <vlc@videolan.org>";
-
- p_info->aout_GetPlugin = NULL;
- p_info->vout_GetPlugin = vout_GetPlugin;
- p_info->intf_GetPlugin = intf_GetPlugin;
- p_info->yuv_GetPlugin = NULL;
-
- /* Check that we can open the X display */
- if( (p_display = XOpenDisplay( XDisplayName(
- main_GetPszVariable( VOUT_DISPLAY_VAR, NULL ) ) ))
- == NULL )
- {
- p_info->i_score = 0;
- }
- else
+ p_module->p_functions = malloc( sizeof( module_functions_t ) );
+ if( p_module->p_functions == NULL )
{
- XCloseDisplay( p_display );
- p_info->i_score = 0x200;
+ return( -1 );
}
- if( TestProgram( "gvlc" ) )
- {
- p_info->i_score += 0x180;
- }
+ _M( intf_getfunctions )( &p_module->p_functions->intf );
- /* If this plugin was requested, score it higher */
- if( TestMethod( VOUT_METHOD_VAR, "gnome" ) )
- {
- p_info->i_score += 0x200;
- }
+ p_module->p_config = p_config;
- return( p_info );
+ return( 0 );
}
/*****************************************************************************
- * Following functions are only called through the p_info structure
+ * DeactivateModule: make sure the module can be unloaded.
+ *****************************************************************************
+ * This function must only be called when i_usage == 0. If it successfully
+ * returns, i_usage can be set to -1 and the module unloaded. Be careful to
+ * lock usage_lock during the whole process.
*****************************************************************************/
-
-static void vout_GetPlugin( p_vout_thread_t p_vout )
+MODULE_DEACTIVATE
{
- p_vout->p_sys_create = vout_GnomeCreate;
- p_vout->p_sys_init = vout_GnomeInit;
- p_vout->p_sys_end = vout_GnomeEnd;
- p_vout->p_sys_destroy = vout_GnomeDestroy;
- p_vout->p_sys_manage = vout_GnomeManage;
- p_vout->p_sys_display = vout_GnomeDisplay;
-
- /* optional functions */
- p_vout->p_set_palette = vout_GnomeSetPalette;
-}
+ free( p_module->p_functions );
-static void intf_GetPlugin( p_intf_thread_t p_intf )
-{
- p_intf->p_sys_create = intf_GnomeCreate;
- p_intf->p_sys_destroy = intf_GnomeDestroy;
- p_intf->p_sys_manage = intf_GnomeManage;
+ return( 0 );
}