Commit 68bc7fd9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

str_format_meta: take input thread pointer rather than playlist

parent 098f3844
...@@ -45,12 +45,12 @@ VLC_API size_t vlc_b64_decode_binary( uint8_t **pp_dst, const char *psz_src ); ...@@ -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 * vlc_b64_decode( const char *psz_src );
VLC_API char * str_format_time( const char * ); 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 *s1 = str_format_time( fmt );
char *s2 = str_format_meta( pl, s1 ); char *s2 = str_format_meta( input, s1 );
free( s1 ); free( s1 );
return s2; return s2;
} }
......
...@@ -270,7 +270,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -270,7 +270,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
NSString *o_name; NSString *o_name;
char *format = var_InheritString(VLCIntf, "input-title-format"); 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); free(format);
o_name = [NSString stringWithUTF8String:formated]; o_name = [NSString stringWithUTF8String:formated];
free(formated); free(formated);
......
...@@ -663,7 +663,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -663,7 +663,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
if (!config_GetPsz(VLCIntf, "video-title")) { if (!config_GetPsz(VLCIntf, "video-title")) {
char *format = var_InheritString(VLCIntf, "input-title-format"); 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); free(format);
aString = [NSString stringWithUTF8String:formated]; aString = [NSString stringWithUTF8String:formated];
free(formated); free(formated);
......
...@@ -468,7 +468,7 @@ void InputManager::UpdateName() ...@@ -468,7 +468,7 @@ void InputManager::UpdateName()
/* Try to get the nowplaying */ /* Try to get the nowplaying */
char *format = var_InheritString( p_intf, "input-title-format" ); 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 ); free( format );
name = qfu(formated); name = qfu(formated);
free( formated ); free( formated );
......
...@@ -739,7 +739,7 @@ void VlcProc::update_current_input() ...@@ -739,7 +739,7 @@ void VlcProc::update_current_input()
{ {
// Update short name (as defined by --input-title-format) // Update short name (as defined by --input-title-format)
char *psz_fmt = var_InheritString( getIntf(), "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 ) ); SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
free( psz_fmt ); free( psz_fmt );
free( psz_name ); free( psz_name );
......
...@@ -3105,6 +3105,8 @@ void input_UpdateStatistic( input_thread_t *p_input, ...@@ -3105,6 +3105,8 @@ void input_UpdateStatistic( input_thread_t *p_input,
/* TODO FIXME nearly the same logic that snapshot code */ /* 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 ) 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; char *psz_file;
DIR *path; DIR *path;
...@@ -3113,7 +3115,7 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha ...@@ -3113,7 +3115,7 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha
{ {
closedir( path ); closedir( path );
char *psz_tmp = str_format( pl_Get(p_obj), psz_prefix ); char *psz_tmp = str_format( input, psz_prefix );
if( !psz_tmp ) if( !psz_tmp )
return NULL; return NULL;
...@@ -3129,9 +3131,8 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha ...@@ -3129,9 +3131,8 @@ char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const cha
} }
else else
{ {
psz_file = str_format( pl_Get(p_obj), psz_path ); psz_file = str_format( input, psz_path );
path_sanitize( psz_file ); path_sanitize( psz_file );
return psz_file; return psz_file;
} }
} }
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
/* Needed by str_format_meta */ /* Needed by str_format_meta */
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_meta.h> #include <vlc_meta.h>
#include <vlc_playlist.h> #include <vlc_aout.h>
#include <vlc_strings.h> #include <vlc_strings.h>
#include <vlc_charset.h> #include <vlc_charset.h>
...@@ -526,13 +526,12 @@ static void format_duration (char *buf, size_t len, int64_t duration) ...@@ -526,13 +526,12 @@ static void format_duration (char *buf, size_t len, int64_t duration)
memcpy( dst+d, string, len ); \ memcpy( dst+d, string, len ); \
d += 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 ); char *dst = strdup( s );
if( unlikely(dst == NULL) ) if( unlikely(dst == NULL) )
return NULL; return NULL;
input_thread_t *p_input = playlist_CurrentInput( p_playlist );
input_item_t *p_item = p_input ? input_GetItem(p_input) : NULL; 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 i_size = strlen( s ) + 1; /* +1 to store '\0' */
size_t d = 0; size_t d = 0;
...@@ -730,11 +729,17 @@ char *str_format_meta( playlist_t *p_playlist, const char *s ) ...@@ -730,11 +729,17 @@ char *str_format_meta( playlist_t *p_playlist, const char *s )
break; break;
case 'V': 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 ) if( vol >= 0.f )
{ {
snprintf( buf, 10, "%ld", snprintf( buf, 10, "%ld", lroundf(vol * 256.f) );
lroundf(vol * AOUT_VOLUME_DEFAULT ) );
INSERT_STRING_NO_FREE( buf ); INSERT_STRING_NO_FREE( buf );
} }
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment