#include <vlc_plugin.h>
#include <errno.h> /* ENOMEM */
-#include <ctype.h>
#include <signal.h>
#include <assert.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
#include <sys/types.h>
#include <vlc_network.h>
/* status changes */
vlc_mutex_t status_lock;
- playlist_status_t i_last_state;
+ int i_last_state;
playlist_t *p_playlist;
bool b_input_buffering;
#ifndef WIN32
#if defined(HAVE_ISATTY)
/* Check that stdin is a TTY */
- if( !config_GetInt( p_intf, "rc-fake-tty" ) && !isatty( 0 ) )
+ if( !var_InheritBool( p_intf, "rc-fake-tty" ) && !isatty( 0 ) )
{
msg_Warn( p_intf, "fd 0 is not a TTY" );
return VLC_EGENERIC;
}
#endif
- psz_unix_path = config_GetPsz( p_intf, "rc-unix" );
+ psz_unix_path = var_InheritString( p_intf, "rc-unix" );
if( psz_unix_path )
{
int i_socket;
#endif /* !WIN32 */
if( ( pi_socket == NULL ) &&
- ( psz_host = config_GetPsz( p_intf, "rc-host" ) ) != NULL )
+ ( psz_host = var_InheritString( p_intf, "rc-host" ) ) != NULL )
{
vlc_url_t url;
p_intf->pf_run = Run;
#ifdef WIN32
- p_intf->p_sys->b_quiet = config_GetInt( p_intf, "rc-quiet" );
+ p_intf->p_sys->b_quiet = var_InheritBool( p_intf, "rc-quiet" );
if( !p_intf->p_sys->b_quiet ) { CONSOLE_INTRO_MSG; }
#else
CONSOLE_INTRO_MSG;
static void Run( intf_thread_t *p_intf )
{
input_thread_t * p_input = NULL;
- playlist_t * p_playlist = pl_Hold( p_intf );
+ playlist_t * p_playlist = pl_Get( p_intf );
char p_buffer[ MAX_LINE_LENGTH + 1 ];
- bool b_showpos = config_GetInt( p_intf, "rc-show-pos" );
+ bool b_showpos = var_InheritBool( p_intf, "rc-show-pos" );
bool b_longhelp = false;
int i_size = 0;
/* status callbacks */
/* Listen to audio volume updates */
- var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, p_intf );
+ var_AddCallback( p_playlist, "volume-change", VolumeChanged, p_intf );
#ifdef WIN32
/* Get the file descriptor of the console input */
msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
free( psz_uri );
msg_rc( STATUS_CHANGE "( audio volume: %d )",
- config_GetInt( p_intf, "volume" ));
+ (int)config_GetInt( p_intf, "volume" ));
}
var_AddCallback( p_input, "intf-event", InputEvent, p_intf );
}
if( p_playlist )
{
- PL_LOCK;
- p_intf->p_sys->i_last_state = (int) PLAYLIST_STOPPED;
+ p_intf->p_sys->i_last_state = PLAYLIST_STOPPED;
msg_rc( STATUS_CHANGE "( stop state: 0 )" );
- PL_UNLOCK;
}
}
{
PL_LOCK;
int status = playlist_Status( p_playlist );
+ PL_UNLOCK;
+
if( p_intf->p_sys->i_last_state != status )
{
if( status == PLAYLIST_STOPPED )
msg_rc( STATUS_CHANGE "( pause state: 4 )" );
}
}
- PL_UNLOCK;
}
if( p_input && b_showpos )
}
else if( !strcmp( psz_cmd, "key" ) || !strcmp( psz_cmd, "hotkey" ) )
{
- var_SetInteger( p_intf->p_libvlc, "key-pressed",
- config_GetInt( p_intf, psz_arg ) );
+ var_SetInteger( p_intf->p_libvlc, "key-action",
+ vlc_GetActionId( psz_arg ) );
}
else switch( psz_cmd[0] )
{
case 'f':
case 'F':
+ {
+ bool fs;
+
+ if( !strncasecmp( psz_arg, "on", 2 ) )
+ var_SetBool( p_playlist, "fullscreen", fs = true );
+ else if( !strncasecmp( psz_arg, "off", 3 ) )
+ var_SetBool( p_playlist, "fullscreen", fs = false );
+ else
+ fs = var_ToggleBool( p_playlist, "fullscreen" );
+
if( p_input )
{
- vout_thread_t *p_vout;
- p_vout = input_GetVout( p_input );
-
+ vout_thread_t *p_vout = input_GetVout( p_input );
if( p_vout )
{
- vlc_value_t val;
- bool b_update = false;
- var_Get( p_vout, "fullscreen", &val );
- val.b_bool = !val.b_bool;
- if( !strncmp( psz_arg, "on", 2 )
- && ( val.b_bool == true ) )
- {
- b_update = true;
- val.b_bool = true;
- }
- else if( !strncmp( psz_arg, "off", 3 )
- && ( val.b_bool == false ) )
- {
- b_update = true;
- val.b_bool = false;
- }
- else if( strncmp( psz_arg, "off", 3 )
- && strncmp( psz_arg, "on", 2 ) )
- b_update = true;
- if( b_update ) var_Set( p_vout, "fullscreen", val );
+ var_SetBool( p_vout, "fullscreen", fs );
vlc_object_release( p_vout );
}
}
break;
-
+ }
case 's':
case 'S':
;
vlc_object_release( p_input );
}
- pl_Release( p_intf );
-
- var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, p_intf );
+ var_DelCallback( p_playlist, "volume-change", VolumeChanged, p_intf );
vlc_restorecancel( canc );
}
vlc_mutex_lock( &p_intf->p_sys->status_lock );
msg_rc( STATUS_CHANGE "( audio volume: %d )",
- config_GetInt( p_this, "volume") );
+ (int)config_GetInt( p_this, "volume") );
vlc_mutex_unlock( &p_intf->p_sys->status_lock );
return VLC_SUCCESS;
}
input_thread_t *p_input )
{
vlc_mutex_lock( &p_intf->p_sys->status_lock );
- msg_rc( STATUS_CHANGE "( new rate: %d )",
- var_GetInteger( p_input, "rate" ) );
+ msg_rc( STATUS_CHANGE "( new rate: %.3f )",
+ var_GetFloat( p_input, "rate" ) );
vlc_mutex_unlock( &p_intf->p_sys->status_lock );
}
static void PositionChanged( intf_thread_t *p_intf,
{
if( var_GetBool( p_input, "can-rate" ) )
{
- int i_rate = var_GetInteger( p_input, "rate" );
- i_rate = (i_rate < 0) ? -i_rate : i_rate * 2;
- var_SetInteger( p_input, "rate", i_rate );
+ float f_rate = var_GetFloat( p_input, "rate" );
+ f_rate = (f_rate < 0) ? -f_rate : f_rate * 2;
+ var_SetFloat( p_input, "rate", f_rate );
}
else
{
{
if( var_GetBool( p_input, "can-rewind" ) )
{
- int i_rate = var_GetInteger( p_input, "rate" );
- i_rate = (i_rate > 0) ? -i_rate : i_rate / 2;
- var_SetInteger( p_input, "rate", i_rate );
+ float f_rate = var_GetFloat( p_input, "rate" );
+ f_rate = (f_rate > 0) ? -f_rate : f_rate * 2;
+ var_SetFloat( p_input, "rate", f_rate );
}
else
{
}
else if ( !strcmp( psz_cmd, "normal" ) )
{
- var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
+ var_SetFloat( p_input, "rate", 1. );
i_error = VLC_SUCCESS;
}
else if ( !strcmp( psz_cmd, "frame" ) )
for ( i = 0; i < val.p_list->i_count; i++ )
{
if ( i_value == val.p_list->p_values[i].i_int )
- msg_rc( "| %i - %s *", val.p_list->p_values[i].i_int,
+ msg_rc( "| %"PRId64" - %s *",
+ val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
else
- msg_rc( "| %i - %s", val.p_list->p_values[i].i_int,
+ msg_rc( "| %"PRId64" - %s",
+ val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
}
var_FreeList( &val, &text );
}
else if (!strcmp( psz_cmd, "goto" ) )
{
+ PL_LOCK;
int i_pos = atoi( newval.psz_string );
/* The playlist stores 2 times the same item: onelevel & category */
int i_size = p_playlist->items.i_size / 2;
p_item = p_parent = p_playlist->items.p_elems[i_pos*2-1];
while( p_parent->p_parent )
p_parent = p_parent->p_parent;
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked,
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked,
p_parent, p_item );
}
else
msg_rc( _("Playlist has only %d elements"), i_size );
+ PL_UNLOCK;
}
else if( !strcmp( psz_cmd, "stop" ) )
{
else if( !strcmp( psz_cmd, "sort" ))
{
+ PL_LOCK;
playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_onelevel,
SORT_ARTIST, ORDER_NORMAL );
+ PL_UNLOCK;
}
else if( !strcmp( psz_cmd, "status" ) )
{
msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
free( psz_uri );
msg_rc( STATUS_CHANGE "( audio volume: %d )",
- config_GetInt( p_intf, "volume" ));
+ (int)config_GetInt( p_intf, "volume" ));
PL_LOCK;
- switch( playlist_Status(p_playlist) )
+ int status = playlist_Status(p_playlist);
+ PL_UNLOCK;
+ switch( status )
{
case PLAYLIST_STOPPED:
msg_rc( STATUS_CHANGE "( stop state: 5 )" );
msg_rc( STATUS_CHANGE "( unknown state: -1 )" );
break;
}
- PL_UNLOCK;
vlc_object_release( p_input );
}
}
if ( !strcmp(psz_cmd, "volup") )
{
- if ( aout_VolumeUp( p_this, i_nb_steps, &i_volume ) < 0 )
+ if ( aout_VolumeUp( p_intf->p_sys->p_playlist, i_nb_steps, &i_volume ) < 0 )
i_error = VLC_EGENERIC;
}
else
{
- if ( aout_VolumeDown( p_this, i_nb_steps, &i_volume ) < 0 )
+ if ( aout_VolumeDown( p_intf->p_sys->p_playlist, i_nb_steps, &i_volume ) < 0 )
i_error = VLC_EGENERIC;
}
osd_Volume( p_this );
playlist_CurrentInput( p_intf->p_sys->p_playlist );
vout_thread_t * p_vout;
const char * psz_variable = NULL;
- int i_error;
+ int i_error = VLC_SUCCESS;
if( !p_input )
return VLC_ENOOBJ;
}
else if( !strcmp( psz_cmd, "snapshot" ) )
{
- i_error = var_SetBool( p_vout, psz_variable, true );
+ var_TriggerCallback( p_vout, psz_variable );
}
else
{
msg_rc( "+----[ end of %s ]", val_name.psz_string );
free( val_name.psz_string );
-
- i_error = VLC_SUCCESS;
}
vlc_object_release( p_vout );
return i_error;
for ( i = 0; i < val.p_list->i_count; i++ )
{
if ( i_value == val.p_list->p_values[i].i_int )
- msg_rc( "| %i - %s *", val.p_list->p_values[i].i_int,
+ msg_rc( "| %"PRId64" - %s *", val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
else
- msg_rc( "| %i - %s", val.p_list->p_values[i].i_int,
+ msg_rc( "| %"PRId64" - %s", val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
}
var_FreeList( &val, &text );
/* Input */
msg_rc("%s", _("+-[Incoming]"));
- msg_rc(_("| input bytes read : %8.0f kB"),
- (float)(p_item->p_stats->i_read_bytes)/1000 );
+ msg_rc(_("| input bytes read : %8.0f KiB"),
+ (float)(p_item->p_stats->i_read_bytes)/1024 );
msg_rc(_("| input bitrate : %6.0f kb/s"),
(float)(p_item->p_stats->f_input_bitrate)*8000 );
- msg_rc(_("| demux bytes read : %8.0f kB"),
- (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
+ msg_rc(_("| demux bytes read : %8.0f KiB"),
+ (float)(p_item->p_stats->i_demux_read_bytes)/1024 );
msg_rc(_("| demux bitrate : %6.0f kb/s"),
(float)(p_item->p_stats->f_demux_bitrate)*8000 );
+ msg_rc(_("| demux corrupted : %5"PRIi64),
+ p_item->p_stats->i_demux_corrupted );
+ msg_rc(_("| discontinuities : %5"PRIi64),
+ p_item->p_stats->i_demux_discontinuity );
msg_rc("|");
/* Video */
msg_rc("%s", _("+-[Video Decoding]"));
- msg_rc(_("| video decoded : %5i"),
+ msg_rc(_("| video decoded : %5"PRIi64),
p_item->p_stats->i_decoded_video );
- msg_rc(_("| frames displayed : %5i"),
+ msg_rc(_("| frames displayed : %5"PRIi64),
p_item->p_stats->i_displayed_pictures );
- msg_rc(_("| frames lost : %5i"),
+ msg_rc(_("| frames lost : %5"PRIi64),
p_item->p_stats->i_lost_pictures );
msg_rc("|");
/* Audio*/
msg_rc("%s", _("+-[Audio Decoding]"));
- msg_rc(_("| audio decoded : %5i"),
+ msg_rc(_("| audio decoded : %5"PRIi64),
p_item->p_stats->i_decoded_audio );
- msg_rc(_("| buffers played : %5i"),
+ msg_rc(_("| buffers played : %5"PRIi64),
p_item->p_stats->i_played_abuffers );
- msg_rc(_("| buffers lost : %5i"),
+ msg_rc(_("| buffers lost : %5"PRIi64),
p_item->p_stats->i_lost_abuffers );
msg_rc("|");
/* Sout */
msg_rc("%s", _("+-[Streaming]"));
- msg_rc(_("| packets sent : %5i"), p_item->p_stats->i_sent_packets );
- msg_rc(_("| bytes sent : %8.0f kB"),
- (float)(p_item->p_stats->i_sent_bytes)/1000 );
+ msg_rc(_("| packets sent : %5"PRIi64),
+ p_item->p_stats->i_sent_packets );
+ msg_rc(_("| bytes sent : %8.0f KiB"),
+ (float)(p_item->p_stats->i_sent_bytes)/1024 );
msg_rc(_("| sending bitrate : %6.0f kb/s"),
(float)(p_item->p_stats->f_send_bitrate*8)*1000 );
msg_rc("|");
else if( *psz_item )
{
i_options++;
- ppsz_options = realloc( ppsz_options, i_options * sizeof(char *) );
+ ppsz_options = xrealloc( ppsz_options, i_options * sizeof(char *) );
ppsz_options[i_options - 1] = &psz_item[1];
}