/*****************************************************************************
* vout_ggi.c: GGI video output display method
*****************************************************************************
- * Copyright (C) 1998, 1999, 2000 VideoLAN
+ * Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
*
- * Authors:
+ * Authors: Vincent Seguin <seguin@via.ecp.fr>
+ * 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME ggi
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "common.h"
#include "threads.h"
#include "mtime.h"
-#include "plugins.h"
+#include "tests.h"
+#include "modules.h"
#include "video.h"
#include "video_output.h"
#include "intf_msg.h"
+#include "interface.h"
+
+#include "main.h"
/*****************************************************************************
* vout_sys_t: video output GGI method descriptor
/* GGI system informations */
ggi_visual_t p_display; /* display device */
- /* Buffers informations */
+ /* Buffer information */
ggi_directbuffer * p_buffer[2]; /* buffers */
boolean_t b_must_acquire; /* must be acquired before writing */
} vout_sys_t;
/*****************************************************************************
- * Local prototypes
+ * Local prototypes.
+ *****************************************************************************/
+static int vout_Probe ( probedata_t *p_data );
+static int vout_Create ( struct vout_thread_s * );
+static int vout_Init ( struct vout_thread_s * );
+static void vout_End ( struct vout_thread_s * );
+static void vout_Destroy ( struct vout_thread_s * );
+static int vout_Manage ( struct vout_thread_s * );
+static void vout_Display ( struct vout_thread_s * );
+
+static int GGIOpenDisplay ( vout_thread_t *p_vout );
+static void GGICloseDisplay( vout_thread_t *p_vout );
+
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
+ *****************************************************************************/
+void _M( vout_getfunctions )( function_list_t * p_function_list )
+{
+ p_function_list->pf_probe = vout_Probe;
+ p_function_list->functions.vout.pf_create = vout_Create;
+ p_function_list->functions.vout.pf_init = vout_Init;
+ p_function_list->functions.vout.pf_end = vout_End;
+ p_function_list->functions.vout.pf_destroy = vout_Destroy;
+ p_function_list->functions.vout.pf_manage = vout_Manage;
+ p_function_list->functions.vout.pf_display = vout_Display;
+ p_function_list->functions.vout.pf_setpalette = NULL;
+}
+
+/*****************************************************************************
+ * vout_Probe: probe the video driver and return a score
+ *****************************************************************************
+ * This function tries to initialize GGI and returns a score to the
+ * plugin manager so that it can select the best plugin.
*****************************************************************************/
-static int GGIOpenDisplay ( vout_thread_t *p_vout, char *psz_display, void *p_data );
-static void GGICloseDisplay ( vout_thread_t *p_vout );
+static int vout_Probe( probedata_t *p_data )
+{
+ if( TestMethod( VOUT_METHOD_VAR, "ggi" ) )
+ {
+ return( 999 );
+ }
+
+ return( 40 );
+}
/*****************************************************************************
- * vout_SysCreate: allocate GGI video thread output method
+ * vout_Create: allocate GGI video thread output method
*****************************************************************************
* This function allocate and initialize a GGI vout method. It uses some of the
* vout properties to choose the correct mode, and change them according to the
* mode actually used.
*****************************************************************************/
-int vout_SysCreate( vout_thread_t *p_vout, char *psz_display, int i_root_window, void *p_data )
+int vout_Create( vout_thread_t *p_vout )
{
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
- intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
+ intf_ErrMsg( "vout error: %s", strerror(ENOMEM) );
return( 1 );
}
/* Open and initialize device */
- if( GGIOpenDisplay( p_vout, psz_display, p_data ) )
+ if( GGIOpenDisplay( p_vout ) )
{
- intf_ErrMsg("error: can't initialize GGI display\n");
+ intf_ErrMsg( "vout error: can't initialize GGI display" );
free( p_vout->p_sys );
return( 1 );
}
}
/*****************************************************************************
- * vout_SysInit: initialize GGI video thread output method
+ * vout_Init: initialize GGI video thread output method
*****************************************************************************
* This function initialize the GGI display device.
*****************************************************************************/
-int vout_SysInit( vout_thread_t *p_vout )
+int vout_Init( vout_thread_t *p_vout )
{
/* Acquire first buffer */
if( p_vout->p_sys->b_must_acquire )
}
/*****************************************************************************
- * vout_SysEnd: terminate Sys video thread output method
+ * vout_End: terminate GGI video thread output method
*****************************************************************************
- * Terminate an output method created by vout_SysCreate
+ * Terminate an output method created by vout_Create
*****************************************************************************/
-void vout_SysEnd( vout_thread_t *p_vout )
+void vout_End( vout_thread_t *p_vout )
{
/* Release buffer */
if( p_vout->p_sys->b_must_acquire )
}
/*****************************************************************************
- * vout_SysDestroy: destroy Sys video thread output method
+ * vout_Destroy: destroy GGI video thread output method
*****************************************************************************
- * Terminate an output method created by vout_SysCreate
+ * Terminate an output method created by vout_Create
*****************************************************************************/
-void vout_SysDestroy( vout_thread_t *p_vout )
+void vout_Destroy( vout_thread_t *p_vout )
{
GGICloseDisplay( p_vout );
+
free( p_vout->p_sys );
}
/*****************************************************************************
- * vout_SysManage: handle Sys events
+ * vout_Manage: handle GGI events
*****************************************************************************
* This function should be called regularly by video output thread. It returns
* a non null value if an error occured.
*****************************************************************************/
-int vout_SysManage( vout_thread_t *p_vout )
+int vout_Manage( vout_thread_t *p_vout )
{
- /* FIXME: 8bpp: change palette ?? */
+ int i_key; /* unicode key */
+
+ /* For all events in queue */
+ while( ggiKbhit( p_vout->p_sys->p_display ) )
+ {
+ i_key = ggiGetc( p_vout->p_sys->p_display );
+ switch( i_key )
+ {
+ case 'q':
+ /* FIXME pass message ! */
+ p_main->p_intf->b_die = 1;
+ break;
+
+ default:
+ break;
+ }
+ }
+
return( 0 );
}
/*****************************************************************************
- * vout_SysDisplay: displays previously rendered output
+ * vout_Display: displays previously rendered output
*****************************************************************************
* This function send the currently rendered image to the display, wait until
* it is displayed and switch the two rendering buffer, preparing next frame.
*****************************************************************************/
-void vout_SysDisplay( vout_thread_t *p_vout )
+void vout_Display( vout_thread_t *p_vout )
{
/* Change display frame */
if( p_vout->p_sys->b_must_acquire )
* Open and initialize display according to preferences specified in the vout
* thread fields.
*****************************************************************************/
-static int GGIOpenDisplay( vout_thread_t *p_vout, char *psz_display, void *p_data )
+static int GGIOpenDisplay( vout_thread_t *p_vout )
{
ggi_mode mode; /* mode descriptor */
ggi_color col_fg; /* foreground color */
ggi_color col_bg; /* background color */
int i_index; /* all purposes index */
+ char *psz_display;
/* Initialize library */
if( ggiInit() )
{
- intf_ErrMsg("error: can't initialize GGI library\n");
+ intf_ErrMsg( "vout error: can't initialize GGI library" );
return( 1 );
}
/* Open display */
+ psz_display = main_GetPszVariable( VOUT_DISPLAY_VAR, NULL );
+
p_vout->p_sys->p_display = ggiOpen( psz_display, NULL );
+
if( p_vout->p_sys->p_display == NULL )
{
- intf_ErrMsg("error: can't open GGI default display\n");
+ intf_ErrMsg( "vout error: can't open GGI default display" );
ggiExit();
return( 1 );
}
- /* give the data back to the interface */
- fprintf(stderr, "display is %i\n", p_vout->p_sys->p_display);
- *(ggi_visual_t *)p_data = p_vout->p_sys->p_display;
-
/* Find most appropriate mode */
mode.frames = 2; /* 2 buffers */
- mode.visible.x = p_vout->i_width; /* minimum width */
- mode.visible.y = p_vout->i_height; /* minimum height */
+ mode.visible.x = main_GetIntVariable( VOUT_WIDTH_VAR,
+ VOUT_WIDTH_DEFAULT );
+ mode.visible.y = main_GetIntVariable( VOUT_HEIGHT_VAR,
+ VOUT_HEIGHT_DEFAULT );
mode.virt.x = GGI_AUTO;
mode.virt.y = GGI_AUTO;
mode.size.x = GGI_AUTO;
/* Set mode */
if( ggiSetMode( p_vout->p_sys->p_display, &mode ) )
{
- intf_ErrMsg("error: can't set GGI mode\n");
+ intf_ErrMsg( "vout error: can't set GGI mode" );
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
{
/* Get buffer address */
p_vout->p_sys->p_buffer[ i_index ] =
- ggiDBGetBuffer( p_vout->p_sys->p_display, i_index );
+ (ggi_directbuffer *)ggiDBGetBuffer( p_vout->p_sys->p_display, i_index );
if( p_vout->p_sys->p_buffer[ i_index ] == NULL )
{
- intf_ErrMsg("error: double buffering is not possible\n");
+ intf_ErrMsg( "vout error: double buffering is not possible" );
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
(p_vout->p_sys->p_buffer[ i_index ]->noaccess != 0) ||
(p_vout->p_sys->p_buffer[ i_index ]->align != 0) )
{
- intf_ErrMsg("error: incorrect video memory type\n");
+ intf_ErrMsg( "vout error: incorrect video memory type" );
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
#ifdef DEBUG
if( p_vout->p_sys->b_must_acquire )
{
- intf_DbgMsg("buffers must be acquired\n");
+ intf_DbgMsg("buffers must be acquired");
}
#endif
ggiSetGCBackground(p_vout->p_sys->p_display,
ggiMapColor(p_vout->p_sys->p_display,&col_bg)) )
{
- intf_ErrMsg("error: can't set colors\n");
+ intf_ErrMsg( "vout error: can't set colors" );
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
if( ggiSetGCClipping(p_vout->p_sys->p_display, 0, 0,
mode.visible.x, mode.visible.y ) )
{
- intf_ErrMsg("error: can't set clipping\n");
+ intf_ErrMsg( "vout error: can't set clipping" );
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );