]> git.sesse.net Git - vlc/blobdiff - modules/codec/spudec/spudec.c
* ./src/video_output/video_output.c: don't try to change aspect ratio if it
[vlc] / modules / codec / spudec / spudec.c
index 50da46991fddeb38183eff947fbe6c8b61a36577..897d6d43acb1fec6ae108590a19b90a8d08fbd72 100644 (file)
@@ -2,7 +2,7 @@
  * spudec.c : SPU decoder thread
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: spudec.c,v 1.8 2002/11/06 21:48:24 gbazin Exp $
+ * $Id: spudec.c,v 1.13 2003/01/28 22:03:21 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -36,7 +36,7 @@
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int  OpenDecoder   ( vlc_object_t * );      
+static int  OpenDecoder   ( vlc_object_t * );
 static int  RunDecoder    ( decoder_fifo_t * );
 static int  InitThread    ( spudec_thread_t * );
 static void EndThread     ( spudec_thread_t * );
@@ -44,15 +44,22 @@ static void EndThread     ( spudec_thread_t * );
 /*****************************************************************************
  * Module descriptor.
  *****************************************************************************/
-#define FONT_TEXT N_("Font used by the text subtitler")
+#define FONT_TEXT N_("font used by the text subtitler")
 #define FONT_LONGTEXT N_(\
     "When the subtitles are coded in text form then, you can choose " \
     "which font will be used to display them.")
 
+#define DEFAULT_FONT "font-eutopiabold36.rle"
+
 vlc_module_begin();
     add_category_hint( N_("subtitles"), NULL );
-    add_file( "spudec-font", "./share/font-eutopiabold36.rle", NULL,
+#if defined(SYS_DARWIN) || defined(SYS_BEOS)
+    add_file( "spudec-font", NULL, NULL,
               FONT_TEXT, FONT_LONGTEXT );
+#else
+    add_file( "spudec-font", "./share/" DEFAULT_FONT, NULL,
+              FONT_TEXT, FONT_LONGTEXT );
+#endif
     set_description( _("subtitles decoder module") );
     set_capability( "decoder", 50 );
     set_callbacks( OpenDecoder, NULL );
@@ -61,7 +68,7 @@ vlc_module_end();
 /*****************************************************************************
  * OpenDecoder: probe the decoder and return score
  *****************************************************************************
- * Tries to launch a decoder and return score so that the interface is able 
+ * Tries to launch a decoder and return score so that the interface is able
  * to chose.
  *****************************************************************************/
 static int OpenDecoder( vlc_object_t *p_this )
@@ -98,7 +105,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
         DecoderError( p_fifo );
         return( -1 );
     }
-    
+
     /*
      * Initialize the thread properties
      */
@@ -118,6 +125,15 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
     {
         /* Here we are dealing with text subtitles */
 
+#if defined(SYS_DARWIN) || defined(SYS_BEOS)
+        if ( (psz_font = config_GetPsz( p_fifo, "spudec-font" )) == NULL )
+        {
+            char * psz_vlcpath = p_fifo->p_libvlc->psz_vlcpath;
+            psz_font = malloc( strlen(psz_vlcpath) + strlen("/share/")
+                                + strlen(DEFAULT_FONT) + 1 );
+            sprintf(psz_font, "%s/share/" DEFAULT_FONT, psz_vlcpath);
+        }
+#else
         if( (psz_font = config_GetPsz( p_fifo, "spudec-font" )) == NULL )
         {
             msg_Err( p_fifo, "no default font selected" );
@@ -125,8 +141,9 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
             p_spudec->p_fifo->b_error;
         }
         else
+#endif
         {
-            p_font = subtitler_LoadFont( p_spudec->p_vout, psz_font );
+            p_font = E_(subtitler_LoadFont)( p_spudec->p_vout, psz_font );
             if ( p_font == NULL )
             {
                 msg_Err( p_fifo, "unable to load font: %s", psz_font );
@@ -140,7 +157,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
             E_(ParseText)( p_spudec, p_font );
         }
 
-        if( p_font ) subtitler_UnloadFont( p_spudec->p_vout, p_font );
+        if( p_font ) E_(subtitler_UnloadFont)( p_spudec->p_vout, p_font );
 
     }
     else
@@ -222,12 +239,12 @@ static int InitThread( spudec_thread_t *p_spudec )
  *****************************************************************************/
 static void EndThread( spudec_thread_t *p_spudec )
 {
-    if( p_spudec->p_vout != NULL 
+    if( p_spudec->p_vout != NULL
          && p_spudec->p_vout->p_subpicture != NULL )
     {
         subpicture_t *  p_subpic;
         int             i_subpic;
-    
+
         for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
         {
             p_subpic = &p_spudec->p_vout->p_subpicture[i_subpic];
@@ -242,7 +259,7 @@ static void EndThread( spudec_thread_t *p_spudec )
 
         vlc_object_release( p_spudec->p_vout );
     }
-    
+
     CloseBitstream( &p_spudec->bit_stream );
     free( p_spudec );
 }