]> git.sesse.net Git - vlc/blobdiff - modules/visualization/xosd/xosd.c
* now 0.6.0-cvs
[vlc] / modules / visualization / xosd / xosd.c
index 572b03bb61923754539f64243cb7000361e715eb..72b7fbfc70b77937ab001a18d4485149b52c63a4 100644 (file)
@@ -2,7 +2,7 @@
  * xosd.c : X On Screen Display interface
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: xosd.c,v 1.1 2002/08/04 17:23:44 sam Exp $
+ * $Id: xosd.c,v 1.10 2003/05/15 22:27:38 massiot Exp $
  *
  * Authors: Loïc Minier <lool@videolan.org>
  *
@@ -51,36 +51,37 @@ struct intf_sys_t
  * Local prototypes.
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
-static void Close        ( vlc_object_t * );             
+static void Close        ( vlc_object_t * );
 
-static void Run          ( intf_thread_t * );                  
+static void Run          ( intf_thread_t * );
 
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-#define POSITION_TEXT N_("flip vertical position")
+#define POSITION_TEXT N_("Flip vertical position")
 #define POSITION_LONGTEXT N_("Display xosd output on the bottom of the " \
                              "screen instead of the top")
 
-#define TXT_OFS_TEXT N_("vertical offset")
+#define TXT_OFS_TEXT N_("Vertical offset")
 #define TXT_OFS_LONGTEXT N_("Vertical offset in pixels of the displayed text")
 
-#define SHD_OFS_TEXT N_("shadow offset")
+#define SHD_OFS_TEXT N_("Shadow offset")
 #define SHD_OFS_LONGTEXT N_("Offset in pixels of the shadow")
 
-#define FONT_TEXT N_("font")
+#define FONT_TEXT N_("Font")
 #define FONT_LONGTEXT N_("Font used to display text in the xosd output")
 
 vlc_module_begin();
-    add_category_hint( N_("Miscellaneous"), NULL );
-    add_bool( "xosd-position", 1, NULL, POSITION_TEXT, POSITION_LONGTEXT );
-    add_integer( "xosd-text-offset", 0, NULL, TXT_OFS_TEXT, TXT_OFS_LONGTEXT );
+    int i = getenv( "DISPLAY" ) == NULL ? 10 : 90;
+    add_category_hint( N_("XOSD module"), NULL, VLC_TRUE );
+    add_bool( "xosd-position", 1, NULL, POSITION_TEXT, POSITION_LONGTEXT, VLC_TRUE );
+    add_integer( "xosd-text-offset", 0, NULL, TXT_OFS_TEXT, TXT_OFS_LONGTEXT, VLC_TRUE );
     add_integer( "xosd-shadow-offset", 1, NULL,
-                 SHD_OFS_TEXT, SHD_OFS_LONGTEXT );
+                 SHD_OFS_TEXT, SHD_OFS_LONGTEXT, VLC_TRUE );
     add_string( "xosd-font", "-misc-fixed-medium-r-*-*-*-300-*-*-*-*-*-*",
-                NULL, FONT_TEXT, FONT_LONGTEXT );
-    set_description( _("xosd interface module") );
-    set_capability( "interface", 40 );
+                NULL, FONT_TEXT, FONT_LONGTEXT, VLC_TRUE );
+    set_description( _("xosd interface") );
+    set_capability( "interface", i );
     set_callbacks( Open, Close );
 vlc_module_end();
 
@@ -96,12 +97,30 @@ static int Open( vlc_object_t *p_this )
     if( p_intf->p_sys == NULL )
     {
         msg_Err( p_intf, "out of memory" );
-        return( 1 );
+        return VLC_ENOMEM;
+    }
+
+    if( getenv( "DISPLAY" ) == NULL )
+    {
+        msg_Err( p_intf, "no display, please set the DISPLAY variable" );
+        return VLC_EGENERIC;
     }
 
     /* Initialize library */
     p_intf->p_sys->p_osd =
-        xosd_init( "fixed", "LawnGreen", 3, XOSD_top, 0, 1 );
+#if defined(HAVE_XOSD_VERSION_0) || defined(HAVE_XOSD_VERSION_1)
+        xosd_init( config_GetPsz( p_intf, "xosd-font" ),
+                   "LawnGreen", 3, XOSD_top, 0, 1 );
+#else
+        xosd_init( config_GetPsz( p_intf, "xosd-font" ),
+                   "LawnGreen", 3, XOSD_top, 0, 0, 1 );
+#endif
+
+    if( p_intf->p_sys->p_osd == NULL )
+    {
+        msg_Err( p_intf, "couldn't initialize libxosd" );
+        return VLC_EGENERIC;
+    }
 
     /* Initialize to NULL */
     p_intf->p_sys->psz_source = NULL;
@@ -113,14 +132,14 @@ static int Open( vlc_object_t *p_this )
 
     p_intf->pf_run = Run;
 
-    return( 0 );
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
  * Close: destroy interface stuff
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
-{   
+{
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
 
     if( p_intf->p_sys->psz_source ) free( p_intf->p_sys->psz_source );
@@ -171,8 +190,15 @@ static void Run( intf_thread_t *p_intf )
                 /* Set user preferences */
                 xosd_set_font( p_intf->p_sys->p_osd,
                                config_GetPsz( p_intf, "xosd-font" ) );
+#ifdef HAVE_XOSD_VERSION_2
+                xosd_set_horizontal_offset( p_intf->p_sys->p_osd,
+                    config_GetInt( p_intf, "xosd-text-offset" ) );
+                xosd_set_vertical_offset( p_intf->p_sys->p_osd,
+                    config_GetInt( p_intf, "xosd-text-offset" ) );
+#else
                 xosd_set_offset( p_intf->p_sys->p_osd,
                     config_GetInt( p_intf, "xosd-text-offset" ) );
+#endif
                 xosd_set_shadow_offset( p_intf->p_sys->p_osd,
                     config_GetInt( p_intf, "xosd-shadow-offset" ));
                 xosd_set_pos( p_intf->p_sys->p_osd,