Commit dbc6f2fb authored by Gildas Bazin's avatar Gildas Bazin

* modules/control/rc.c: proper fix for the high CPU useage with --rc-quiet.

parent 182669a7
...@@ -97,6 +97,7 @@ struct intf_sys_t ...@@ -97,6 +97,7 @@ struct intf_sys_t
#ifdef WIN32 #ifdef WIN32
HANDLE hConsoleIn; HANDLE hConsoleIn;
vlc_bool_t b_quiet;
#endif #endif
}; };
...@@ -265,7 +266,8 @@ static int Activate( vlc_object_t *p_this ) ...@@ -265,7 +266,8 @@ static int Activate( vlc_object_t *p_this )
p_intf->pf_run = Run; p_intf->pf_run = Run;
#ifdef WIN32 #ifdef WIN32
if( !config_GetInt( p_intf, "rc-quiet" ) ) { CONSOLE_INTRO_MSG; } p_intf->p_sys->b_quiet = config_GetInt( p_intf, "rc-quiet" );
if( !p_intf->p_sys->b_quiet ) { CONSOLE_INTRO_MSG; }
#else #else
CONSOLE_INTRO_MSG; CONSOLE_INTRO_MSG;
#endif #endif
...@@ -392,30 +394,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -392,30 +394,10 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->i_socket_listen != - 1 && if( p_intf->p_sys->i_socket_listen != - 1 &&
p_intf->p_sys->i_socket == -1 ) p_intf->p_sys->i_socket == -1 )
{ {
#ifdef WIN32
/* If rc-quiet is specified, only check for socket connections
once per second, to not flood the CPU. */
if( config_GetInt( p_intf, "rc-quiet" ) )
{
do
{
p_intf->p_sys->i_socket = p_intf->p_sys->i_socket =
net_Accept( p_intf, p_intf->p_sys->i_socket_listen, 0 ); net_Accept( p_intf, p_intf->p_sys->i_socket_listen, 0 );
msleep( 1000 );
} while ( p_intf->p_sys->i_socket == -1 );
}
else
{
p_intf->p_sys->i_socket =
net_Accept( p_intf, p_intf->p_sys->i_socket_listen, 0 );
}
#else
p_intf->p_sys->i_socket =
net_Accept( p_intf, p_intf->p_sys->i_socket_listen, 0 );
#endif
} }
b_complete = ReadCommand( p_intf, p_buffer, &i_size ); b_complete = ReadCommand( p_intf, p_buffer, &i_size );
/* Manage the input part */ /* Manage the input part */
...@@ -1172,8 +1154,13 @@ vlc_bool_t ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size ) ...@@ -1172,8 +1154,13 @@ vlc_bool_t ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
int i_read = 0; int i_read = 0;
#ifdef WIN32 #ifdef WIN32
if( p_intf->p_sys->i_socket == -1 ) if( p_intf->p_sys->i_socket == -1 && !p_intf->p_sys->b_quiet )
return ReadWin32( p_intf, p_buffer, pi_size ); return ReadWin32( p_intf, p_buffer, pi_size );
else if( p_intf->p_sys->i_socket == -1 )
{
msleep( INTF_IDLE_SLEEP );
return VLC_FALSE;
}
#endif #endif
while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH && while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH &&
......
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