[vlc-commits] str_format_meta: take input thread pointer rather than playlist

Rémi Denis-Courmont git at videolan.org
Wed Jan 1 19:51:45 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jan  1 20:25:52 2014 +0200| [e64dc8c464da79ef9ce610af9ec4a18e859ae489] | committer: Rémi Denis-Courmont

str_format_meta: take input thread pointer rather than playlist

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

 include/vlc_strings.h                |    6 +++---
 modules/gui/macosx/CoreInteraction.m |    2 +-
 modules/gui/macosx/MainWindow.m      |    2 +-
 modules/gui/qt4/input_manager.cpp    |    2 +-
 modules/gui/skins2/src/vlcproc.cpp   |    2 +-
 src/input/input.c                    |    7 ++++---
 src/text/strings.c                   |   17 +++++++++++------
 7 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/include/vlc_strings.h b/include/vlc_strings.h
index 9159282..3ce4884 100644
--- a/include/vlc_strings.h
+++ b/include/vlc_strings.h
@@ -45,12 +45,12 @@ 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( playlist_t *, const char * );
+VLC_API char * str_format_meta( input_thread_t *, const char * );
 
-static inline char *str_format( playlist_t *pl, const char *fmt )
+static inline char *str_format( input_thread_t *input, const char *fmt )
 {
     char *s1 = str_format_time( fmt );
-    char *s2 = str_format_meta( pl, s1 );
+    char *s2 = str_format_meta( input, s1 );
     free( s1 );
     return s2;
 }
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index 782fe4e..8990268 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -270,7 +270,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
 
     NSString *o_name;
     char *format = var_InheritString(VLCIntf, "input-title-format");
-    char *formated = str_format_meta(pl_Get(VLCIntf), format);
+    char *formated = str_format_meta(p_input, format);
     free(format);
     o_name = [NSString stringWithUTF8String:formated];
     free(formated);
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index ef8dd55..30198ba 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -663,7 +663,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
         if (!config_GetPsz(VLCIntf, "video-title")) {
             char *format = var_InheritString(VLCIntf, "input-title-format");
-            char *formated = str_format_meta(pl_Get(VLCIntf), format);
+            char *formated = str_format_meta(p_input, format);
             free(format);
             aString = [NSString stringWithUTF8String:formated];
             free(formated);
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index bba154e..c2c0124 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -468,7 +468,7 @@ void InputManager::UpdateName()
 
     /* Try to get the nowplaying */
     char *format = var_InheritString( p_intf, "input-title-format" );
-    char *formated = str_format_meta( THEPL, format );
+    char *formated = str_format_meta( p_input, format );
     free( format );
     name = qfu(formated);
     free( formated );
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 7aa1022..80a4a18 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -739,7 +739,7 @@ void VlcProc::update_current_input()
     {
         // Update short name (as defined by --input-title-format)
         char *psz_fmt = var_InheritString( getIntf(), "input-title-format" );
-        char *psz_name = str_format_meta( pPlaylist, psz_fmt );
+        char *psz_name = str_format_meta( pInput, psz_fmt );
         SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
         free( psz_fmt );
         free( psz_name );
diff --git a/src/input/input.c b/src/input/input.c
index 183681a..ea11bca 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -3105,6 +3105,8 @@ void input_UpdateStatistic( input_thread_t *p_input,
 /* TODO FIXME nearly the same logic that snapshot code */
 char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const char *psz_prefix, const char *psz_extension )
 {
+    playlist_t *pl = pl_Get(p_obj);
+    input_thread_t *input = playlist_CurrentInput(pl);
     char *psz_file;
     DIR *path;
 
@@ -3113,7 +3115,7 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha
     {
         closedir( path );
 
-        char *psz_tmp = str_format( pl_Get(p_obj), psz_prefix );
+        char *psz_tmp = str_format( input, psz_prefix );
         if( !psz_tmp )
             return NULL;
 
@@ -3129,9 +3131,8 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha
     }
     else
     {
-        psz_file = str_format( pl_Get(p_obj), psz_path );
+        psz_file = str_format( input, psz_path );
         path_sanitize( psz_file );
         return psz_file;
     }
 }
-
diff --git a/src/text/strings.c b/src/text/strings.c
index 712116d..7d7a83a 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -42,7 +42,7 @@
 /* Needed by str_format_meta */
 #include <vlc_input.h>
 #include <vlc_meta.h>
-#include <vlc_playlist.h>
+#include <vlc_aout.h>
 
 #include <vlc_strings.h>
 #include <vlc_charset.h>
@@ -526,13 +526,12 @@ static void format_duration (char *buf, size_t len, int64_t duration)
                         memcpy( dst+d, string, len );               \
                         d += len;                                   \
                     }
-char *str_format_meta( playlist_t *p_playlist, const char *s )
+char *str_format_meta( input_thread_t *p_input, const char *s )
 {
     char *dst = strdup( s );
     if( unlikely(dst == NULL) )
         return NULL;
 
-    input_thread_t *p_input = playlist_CurrentInput( p_playlist );
     input_item_t *p_item = p_input ? input_GetItem(p_input) : NULL;
     size_t i_size = strlen( s ) + 1; /* +1 to store '\0' */
     size_t d = 0;
@@ -730,11 +729,17 @@ char *str_format_meta( playlist_t *p_playlist, const char *s )
                     break;
                 case 'V':
                 {
-                    float vol = playlist_VolumeGet( p_object );
+                    float vol = 0.f;
+
+                    if( p_input )
+                    {
+                        audio_output_t *aout = input_GetAout( p_input );
+                        if( aout )
+                            vol = aout_VolumeGet( aout );
+                    }
                     if( vol >= 0.f )
                     {
-                        snprintf( buf, 10, "%ld",
-                                  lroundf(vol * AOUT_VOLUME_DEFAULT ) );
+                        snprintf( buf, 10, "%ld", lroundf(vol * 256.f) );
                         INSERT_STRING_NO_FREE( buf );
                     }
                     else



More information about the vlc-commits mailing list