# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <assert.h>
/* Needed by str_format_time */
{
char buffer[255];
time_t curtime;
-#if defined(HAVE_LOCALTIME_R)
struct tm loctime;
-#else
- struct tm *loctime;
-#endif
/* Get the current time. */
curtime = time( NULL );
/* Convert it to local time representation. */
-#if defined(HAVE_LOCALTIME_R)
localtime_r( &curtime, &loctime );
strftime( buffer, 255, tformat, &loctime );
-#else
- loctime = localtime( &curtime );
- strftime( buffer, 255, tformat, loctime );
-#endif
return strdup( buffer );
}
d += len; \
free( string ); \
} \
- else \
+ else if( !b_empty_if_na ) \
{ \
*(dst+d) = '-'; \
d++; \
char *__str_format_meta( vlc_object_t *p_object, const char *string )
{
const char *s = string;
- int b_is_format = 0;
- int b_empty_if_na = 0;
+ bool b_is_format = false;
+ bool b_empty_if_na = false;
char buf[10];
int i_size = strlen( string ) + 1; /* +1 to store '\0' */
- char *dst = malloc( i_size );
+ char *dst = strdup( string );
+ if( !dst ) return NULL;
int d = 0;
- playlist_t *p_playlist = pl_Yield( p_object );
- input_thread_t *p_input = p_playlist->p_input;
+ playlist_t *p_playlist = pl_Hold( p_object );
+ input_thread_t *p_input = playlist_CurrentInput( p_playlist );
input_item_t *p_item = NULL;
pl_Release( p_object );
if( p_input )
{
- vlc_object_yield( p_input );
p_item = input_GetItem(p_input);
}
- sprintf( dst, string );
-
while( *s )
{
if( b_is_format )
INSERT_STRING( input_item_GetEncodedBy( p_item ) );
}
break;
+ case 'f':
+ if( p_item && p_item->p_stats )
+ {
+ snprintf( buf, 10, "%d",
+ p_item->p_stats->i_displayed_pictures );
+ }
+ else
+ {
+ sprintf( buf, b_empty_if_na ? "" : "-" );
+ }
+ INSERT_STRING_NO_FREE( buf );
+ break;
case 'g':
if( p_item )
{
break;
case ' ':
- b_empty_if_na = 1;
+ b_empty_if_na = true;
break;
default:
break;
}
if( *s != ' ' )
- b_is_format = 0;
+ b_is_format = false;
}
else if( *s == '$' )
{
- b_is_format = 1;
- b_empty_if_na = 0;
+ b_is_format = true;
+ b_empty_if_na = false;
}
else
{