static void __msg_rc( intf_thread_t *p_intf, const char *psz_fmt, ... )
{
va_list args;
+ char fmt_eol[strlen (psz_fmt) + 3];
+
+ snprintf (fmt_eol, sizeof (fmt_eol), "%s\r\n", psz_fmt);
va_start( args, psz_fmt );
if( p_intf->p_sys->i_socket == -1 )
- {
- utf8_vfprintf( stdout, psz_fmt, args );
- printf( "\r\n" );
- }
+ utf8_vfprintf( stdout, fmt_eol, args );
else
- {
- net_vaPrintf( p_intf, p_intf->p_sys->i_socket, NULL, psz_fmt, args );
- net_Write( p_intf, p_intf->p_sys->i_socket, NULL, (uint8_t*)"\r\n", 2 );
- }
+ net_vaPrintf( p_intf, p_intf->p_sys->i_socket, NULL, fmt_eol, args );
va_end( args );
}
FIND_ANYWHERE );
if( p_input )
{
- p_playlist = pl_Yield( p_input );
+ p_playlist = pl_Hold( p_input );
}
}
/* New input has been registered */
if( p_playlist )
{
- vlc_object_lock( p_playlist );
+ PL_LOCK;
p_intf->p_sys->i_last_state = (int) PLAYLIST_STOPPED;
msg_rc( STATUS_CHANGE "( stop state: 0 )" );
- vlc_object_unlock( p_playlist );
+ PL_UNLOCK;
}
}
if( (p_input != NULL) && !p_input->b_dead && vlc_object_alive (p_input) &&
(p_playlist != NULL) )
{
- vlc_object_lock( p_playlist );
- if( (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
- (p_playlist->status.i_status == PLAYLIST_STOPPED) )
+ PL_LOCK;
+ int status = playlist_Status( p_playlist );
+ if( (p_intf->p_sys->i_last_state != status) &&
+ (status == PLAYLIST_STOPPED) )
{
p_intf->p_sys->i_last_state = PLAYLIST_STOPPED;
msg_rc( STATUS_CHANGE "( stop state: 5 )" );
}
else if(
- (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
- (p_playlist->status.i_status == PLAYLIST_RUNNING) )
+ (p_intf->p_sys->i_last_state != status) &&
+ (status == PLAYLIST_RUNNING) )
{
- p_intf->p_sys->i_last_state = p_playlist->status.i_status;
+ p_intf->p_sys->i_last_state = PLAYLIST_RUNNING;
msg_rc( STATUS_CHANGE "( play state: 3 )" );
}
else if(
- (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
- (p_playlist->status.i_status == PLAYLIST_PAUSED) )
+ (p_intf->p_sys->i_last_state != status) &&
+ (status == PLAYLIST_PAUSED) )
{
- p_intf->p_sys->i_last_state = p_playlist->status.i_status;
+ p_intf->p_sys->i_last_state = PLAYLIST_PAUSED;
msg_rc( STATUS_CHANGE "( pause state: 4 )" );
}
- vlc_object_unlock( p_playlist );
+ PL_UNLOCK;
}
if( p_input && b_showpos )
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input )
{
- p_playlist = pl_Yield( p_input );
+ p_playlist = pl_Hold( p_input );
char cmd[6];
- switch( p_playlist->status.i_status )
+ switch( playlist_Status( p_playlist ) )
{
case PLAYLIST_STOPPED:
strcpy( cmd, "stop" );
vlc_value_t val;
intf_thread_t *p_intf = (intf_thread_t*)p_this;
- playlist_t *p_playlist = pl_Yield( p_this );
+ playlist_t *p_playlist = pl_Hold( p_this );
+ input_thread_t * p_input = playlist_CurrentInput( p_playlist );
- PL_LOCK;
- if( p_playlist->p_input )
+ if( p_input )
{
- var_Get( p_playlist->p_input, "state", &val );
+ var_Get( p_input, "state", &val );
+ vlc_object_release( p_input );
+
if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )
{
msg_rc( _("Type 'menu select' or 'pause' to continue.") );
- vlc_object_release( p_playlist );
- PL_UNLOCK;
+ pl_Release( p_this );
return VLC_EGENERIC;
}
}
- PL_UNLOCK;
/* Parse commands that require a playlist */
if( !strcmp( psz_cmd, "prev" ) )
}
else if( !strcmp( psz_cmd, "status" ) )
{
- if( p_playlist->p_input )
+ input_thread_t * p_input = playlist_CurrentInput( p_playlist );
+ if( p_input )
{
/* Replay the current state of the system. */
char *psz_uri =
- input_item_GetURI( input_GetItem( p_playlist->p_input ) );
+ input_item_GetURI( input_GetItem( p_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" ));
PL_LOCK;
- switch( p_playlist->status.i_status )
+ switch( playlist_Status(p_playlist) )
{
case PLAYLIST_STOPPED:
msg_rc( STATUS_CHANGE "( stop state: 5 )" );
break;
}
PL_UNLOCK;
+ vlc_object_release( p_input );
}
}
msg_rc( "unknown command!" );
}
- vlc_object_release( p_playlist );
+ pl_Release( p_this );
return VLC_SUCCESS;
}
VLC_UNUSED(oldval); VLC_UNUSED(newval);
playlist_t *p_playlist;
- p_playlist = pl_Yield( p_this );
+ p_playlist = pl_Hold( p_this );
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
return VLC_EGENERIC;
}
- p_playlist = pl_Yield( p_this );
+ p_playlist = pl_Hold( p_this );
+ input_thread_t * p_input = playlist_CurrentInput( p_playlist );
- if( p_playlist->p_input )
+ if( p_input )
{
- var_Get( p_playlist->p_input, "state", &val );
+ var_Get( p_input, "state", &val );
+ vlc_object_release( p_input );
+
if( ( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) ) &&
( strcmp( newval.psz_string, "select" ) != 0 ) )
{
msg_rc( _("Type 'menu select' or 'pause' to continue.") );
- vlc_object_release( p_playlist );
+ pl_Release( p_this );
return VLC_EGENERIC;
}
}
- vlc_object_release( p_playlist );
+ pl_Release( p_this );
val.psz_string = strdup( newval.psz_string );
if( !val.psz_string )