[vlc-commits] str_format_meta(): take playlist as parameter directly

Rémi Denis-Courmont git at videolan.org
Tue Aug 21 20:32:26 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 21 21:30:05 2012 +0300| [9cd91f9294687396aa819de7693a275608c985cc] | committer: Rémi Denis-Courmont

str_format_meta(): take playlist as parameter directly

Also inline str_format().

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9cd91f9294687396aa819de7693a275608c985cc
---

 include/vlc_strings.h             |   13 +++++++++----
 modules/gui/qt4/input_manager.cpp |    2 +-
 src/input/input.c                 |    5 +++--
 src/libvlccore.sym                |    1 -
 src/text/strings.c                |   18 ++----------------
 5 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/include/vlc_strings.h b/include/vlc_strings.h
index 9b4d094..9159282 100644
--- a/include/vlc_strings.h
+++ b/include/vlc_strings.h
@@ -45,10 +45,15 @@ VLC_API size_t vlc_b64_decode_binary( uint8_t **pp_dst, const char *psz_src );
 VLC_API char * vlc_b64_decode( const char *psz_src );
 
 VLC_API char * str_format_time( const char * );
-VLC_API char * str_format_meta( vlc_object_t *, const char * );
-#define str_format_meta( a, b ) str_format_meta( VLC_OBJECT( a ), b )
-VLC_API char * str_format( vlc_object_t *, const char * );
-#define str_format( a, b ) str_format( VLC_OBJECT( a ), b )
+VLC_API char * str_format_meta( playlist_t *, const char * );
+
+static inline char *str_format( playlist_t *pl, const char *fmt )
+{
+    char *s1 = str_format_time( fmt );
+    char *s2 = str_format_meta( pl, s1 );
+    free( s1 );
+    return s2;
+}
 
 VLC_API void filename_sanitize( char * );
 VLC_API void path_sanitize( char * );
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 45e555f..dae5ef5 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -484,7 +484,7 @@ void InputManager::UpdateName()
 
     /* Try to get the nowplaying */
     char *format = var_InheritString( p_intf, "input-title-format" );
-    char *formated = str_format_meta( p_input, format );
+    char *formated = str_format_meta( THEPL, format );
     free( format );
     name = qfu(formated);
     free( formated );
diff --git a/src/input/input.c b/src/input/input.c
index 88366ef..e35bd85 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -55,6 +55,7 @@
 #include <vlc_fs.h>
 #include <vlc_strings.h>
 #include <vlc_modules.h>
+#include <vlc_playlist.h> // FIXME
 
 /*****************************************************************************
  * Local prototypes
@@ -3237,7 +3238,7 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha
     {
         closedir( path );
 
-        char *psz_tmp = str_format( p_obj, psz_prefix );
+        char *psz_tmp = str_format( pl_Get(p_obj), psz_prefix );
         if( !psz_tmp )
             return NULL;
 
@@ -3253,7 +3254,7 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha
     }
     else
     {
-        psz_file = str_format( p_obj, psz_path );
+        psz_file = str_format( pl_Get(p_obj), psz_path );
         path_sanitize( psz_file );
         return psz_file;
     }
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index e3b4519..a859934 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -402,7 +402,6 @@ stream_Read
 stream_ReadLine
 stream_UrlNew
 stream_vaControl
-str_format
 str_format_meta
 str_format_time
 str_duration
diff --git a/src/text/strings.c b/src/text/strings.c
index 9ed515d..8db7b26 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -527,8 +527,7 @@ static void format_duration (char *buf, size_t len, int64_t duration)
                         memcpy( dst+d, string, len );               \
                         d += len;                                   \
                     }
-#undef str_format_meta
-char *str_format_meta( vlc_object_t *p_object, const char *string )
+char *str_format_meta( playlist_t *p_object, const char *string )
 {
     const char *s = string;
     bool b_is_format = false;
@@ -539,7 +538,7 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
     if( !dst ) return NULL;
     int d = 0;
 
-    input_thread_t *p_input = playlist_CurrentInput( pl_Get(p_object) );
+    input_thread_t *p_input = playlist_CurrentInput( p_object );
     input_item_t *p_item = NULL;
     if( p_input )
     {
@@ -847,19 +846,6 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
 #undef INSERT_STRING
 #undef INSERT_STRING_NO_FREE
 
-#undef str_format
-/**
- * Apply str format time and str format meta
- */
-char *str_format( vlc_object_t *p_this, const char *psz_src )
-{
-    char *psz_buf1, *psz_buf2;
-    psz_buf1 = str_format_time( psz_src );
-    psz_buf2 = str_format_meta( p_this, psz_buf1 );
-    free( psz_buf1 );
-    return psz_buf2;
-}
-
 /**
  * Remove forbidden, potentially forbidden and otherwise evil characters from
  * filenames. This includes slashes, and popular characters like colon



More information about the vlc-commits mailing list