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 );
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;
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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;
}
}
......@@ -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
......
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