]> git.sesse.net Git - vlc/commitdiff
* modules/misc/freetype.c, modules/demux/util/sub.c: cleanup.
authorGildas Bazin <gbazin@videolan.org>
Wed, 23 Jul 2003 23:05:25 +0000 (23:05 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 23 Jul 2003 23:05:25 +0000 (23:05 +0000)
* modules/demux/util/sub.h: thou shall do a vlc_object_attach().
* src/misc/variables.c: added VLC_VAR_FILE and VLC_VAR_DIRECTORY inheritance support.

modules/demux/util/sub.c
modules/demux/util/sub.h
modules/misc/freetype.c
src/misc/variables.c

index c698a9aa81c8a668bdda59a8ad8894952d4bb0d0..4665872da534cc4e10875a12aec27cb17a7d7b04 100644 (file)
@@ -2,7 +2,7 @@
  * sub.c
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: sub.c,v 1.18 2003/07/23 21:45:13 hartman Exp $
+ * $Id: sub.c,v 1.19 2003/07/23 23:05:25 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -94,26 +94,10 @@ static int Open ( vlc_object_t *p_this )
     p_sub->pf_close = sub_close;
 
     /* Initialize the variables */
-    if( !var_Type( p_this, "sub-file" ) )
-    {
-        var_Create( p_this, "sub-file", VLC_VAR_STRING );
-        var_Change( p_this, "sub-file", VLC_VAR_INHERITVALUE, NULL, NULL );
-    }
-    if( !var_Type( p_this, "sub-fps" ) )
-    {
-        var_Create( p_this, "sub-fps", VLC_VAR_FLOAT );
-        var_Change( p_this, "sub-fps", VLC_VAR_INHERITVALUE, NULL, NULL );
-    }
-    if( !var_Type( p_this, "sub-delay" ) )
-    {
-        var_Create( p_this, "sub-delay", VLC_VAR_INTEGER );
-        var_Change( p_this, "sub-delay", VLC_VAR_INHERITVALUE, NULL, NULL );
-    }
-    if( !var_Type( p_this, "sub-type" ) )
-    {
-        var_Create( p_this, "sub-type", VLC_VAR_STRING );
-        var_Change( p_this, "sub-type", VLC_VAR_INHERITVALUE, NULL, NULL );
-    }
+    var_Create( p_this, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
+    var_Create( p_this, "sub-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
+    var_Create( p_this, "sub-delay", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_this, "sub-type", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
 
     return VLC_SUCCESS;
 }
@@ -269,11 +253,11 @@ static int  sub_open ( subtitle_demux_t *p_sub,
         var_Get( p_sub, "sub-file", &val );
         if( !val.psz_string || !*val.psz_string )
         {
-            if( val.psz_string) free( val.psz_string);
+            if( val.psz_string ) free( val.psz_string );
+        msg_Err( p_sub, "cannot open `%s' subtitle fileeee", val.psz_string );
             return VLC_EGENERIC;
         }
-        psz_name = strdup( val.psz_string );
-        free( val.psz_string );
+        psz_name = val.psz_string;
     }
     else
     {
@@ -401,15 +385,14 @@ static int  sub_open ( subtitle_demux_t *p_sub,
     {
         if( sub_read_subtitle_function[i].i_type == SUB_TYPE_UNKNOWN )
         {
-            msg_Dbg( p_input, "unknown subtitile file" );
+            msg_Dbg( p_input, "unknown subtitle file" );
             text_unload( &txt );
             return VLC_EGENERIC;
         }
 
         if( sub_read_subtitle_function[i].i_type == i_sub_type )
         {
-            msg_Dbg( p_input,
-                    "detected %s format",
+            msg_Dbg( p_input, "detected %s format",
                     sub_read_subtitle_function[i].psz_name );
             pf_read_subtitle = sub_read_subtitle_function[i].pf_read_subtitle;
             break;
index a75f4581b23bdb9e329ccfdc60271d46c01aac8a..ea99d76f4e60f259643f2ba8d9bc1d5c93032148 100644 (file)
@@ -2,7 +2,7 @@
  * sub.h
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: sub.h,v 1.4 2003/03/15 18:44:31 fenrir Exp $
+ * $Id: sub.h,v 1.5 2003/07/23 23:05:25 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
@@ -133,6 +133,7 @@ static inline
 
     p_sub = vlc_object_create( p_input, sizeof( subtitle_demux_t ) );
     p_sub->psz_object_name = "subtitle demux";
+    vlc_object_attach( p_sub, p_input );
     p_sub->p_module = module_Need( p_sub, "subtitle demux", "" );
 
     if( p_sub->p_module &&
index d433306296e34ee10797fa618cd8320ebe6336bf..a187844634e66176ed90987618dba43c6e13cdbd 100644 (file)
@@ -2,7 +2,7 @@
  * freetype.c : Put text on the video, using freetype2
  *****************************************************************************
  * Copyright (C) 2002, 2003 VideoLAN
- * $Id: freetype.c,v 1.10 2003/07/23 21:45:13 hartman Exp $
+ * $Id: freetype.c,v 1.11 2003/07/23 23:05:25 gbazin Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -137,23 +137,14 @@ static int Create( vlc_object_t *p_this )
             (uint8_t)( pow( (double)i / 255.0f, gamma_inv) * 255.0f );
     }
 
-    if( !var_Type( p_vout, "freetype-font" ) )
-    {
-        var_Create( p_vout, "freetype-font", VLC_VAR_STRING );
-        var_Change( p_vout, "freetype-font", VLC_VAR_INHERITVALUE, NULL, NULL );
-    }
-    if( !var_Type( p_vout, "freetype-fontsize" ) )
-    {
-        var_Create( p_vout, "freetype-fontsize", VLC_VAR_INTEGER );
-        var_Change( p_vout, "freetype-fontsize", VLC_VAR_INHERITVALUE, NULL, NULL );
-    }
+    var_Create( p_vout, "freetype-font", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "freetype-fontsize",
+                VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
 
     /* Look what method was requested */
     var_Get( p_vout, "freetype-font", &val );
-    psz_fontfile = (char *)malloc( PATH_MAX + 1 );
-    strcat( psz_fontfile, val.psz_string );
-    free( val.psz_string);
-    
+    psz_fontfile = val.psz_string;
+
     if( !psz_fontfile || !*psz_fontfile )
     {
         if( psz_fontfile ) free( psz_fontfile );
@@ -162,7 +153,7 @@ static int Create( vlc_object_t *p_this )
         GetWindowsDirectory( psz_fontfile, PATH_MAX + 1 );
         strcat( psz_fontfile, "\\fonts\\arial.ttf" );
 #elif SYS_DARWIN
-        strcat( psz_fontfile, DEFAULT_FONT );
+        strcpy( psz_fontfile, DEFAULT_FONT );
 #endif
     }
 
index b251ebd145a8dae5b17c9ae4eaeeb34307894f17..9cffb9be9cbda4816a50bd9f9bad5457d3b3ebc7 100644 (file)
@@ -2,7 +2,7 @@
  * variables.c: routines for object variables handling
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: variables.c,v 1.28 2003/07/23 22:01:25 gbazin Exp $
+ * $Id: variables.c,v 1.29 2003/07/23 23:05:25 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -1118,6 +1118,8 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
     {
         switch( i_type & VLC_VAR_TYPE )
         {
+        case VLC_VAR_FILE:
+        case VLC_VAR_DIRECTORY:
         case VLC_VAR_STRING:
             p_val->psz_string = config_GetPsz( p_this, psz_name );
             if( !p_val->psz_string ) p_val->psz_string = strdup("");