Commit f82f7f25 authored by Sam Hocevar's avatar Sam Hocevar

  * Made the remote command plugin usable even with no stream.
  * Fixed a deadlock in the remote command plugin.
  * Fixed a deadlock in the SPU decoder.
parent e57dfae1
......@@ -66,6 +66,8 @@ typedef struct intf_sys_s
} intf_sys_t;
#define MAX_LINE_LENGTH 256
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
......@@ -138,7 +140,7 @@ static void intf_Close( intf_thread_t *p_intf )
*****************************************************************************/
static void intf_Run( intf_thread_t *p_intf )
{
char p_cmd[ 32 ];
char p_cmd[ MAX_LINE_LENGTH + 1 ];
int i_cmd_pos;
boolean_t b_complete = 0;
......@@ -153,10 +155,10 @@ static void intf_Run( intf_thread_t *p_intf )
while( !p_intf->b_die )
{
#define S p_intf->p_input->stream
if( p_intf->p_input != NULL )
{
/* Get position */
#define S p_intf->p_input->stream
if( S.i_mux_rate )
{
f_ratio = 1.0 / ( 50 * S.i_mux_rate );
......@@ -170,6 +172,7 @@ static void intf_Run( intf_thread_t *p_intf )
S.p_selected_area->i_size ) );
}
}
}
#undef S
b_complete = 0;
......@@ -183,7 +186,8 @@ static void intf_Run( intf_thread_t *p_intf )
if( select( 32, &fds, NULL, NULL, &tv ) )
{
while( i_cmd_pos < 32
while( !p_intf->b_die
&& i_cmd_pos < MAX_LINE_LENGTH
&& read( STDIN_FILENO, p_cmd + i_cmd_pos, 1 ) > 0
&& p_cmd[ i_cmd_pos ] != '\r'
&& p_cmd[ i_cmd_pos ] != '\n' )
......@@ -191,7 +195,8 @@ static void intf_Run( intf_thread_t *p_intf )
i_cmd_pos++;
}
if( i_cmd_pos == 31 || p_cmd[ i_cmd_pos ] == '\r'
if( i_cmd_pos == MAX_LINE_LENGTH
|| p_cmd[ i_cmd_pos ] == '\r'
|| p_cmd[ i_cmd_pos ] == '\n' )
{
p_cmd[ i_cmd_pos ] = 0;
......@@ -206,7 +211,10 @@ static void intf_Run( intf_thread_t *p_intf )
{
case 'p':
case 'P':
if( p_intf->p_input != NULL )
{
input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
}
break;
case 'f':
......@@ -245,8 +253,12 @@ static void intf_Run( intf_thread_t *p_intf )
case 'r':
case 'R':
for( i_dummy = 1; i_dummy < 32 && p_cmd[ i_dummy ] >= '0'
&& p_cmd[ i_dummy ] <= '9'; ++i_dummy )
if( p_intf->p_input != NULL )
{
for( i_dummy = 1;
i_dummy < MAX_LINE_LENGTH && p_cmd[ i_dummy ] >= '0'
&& p_cmd[ i_dummy ] <= '9';
i_dummy++ )
{
;
}
......@@ -255,14 +267,14 @@ static void intf_Run( intf_thread_t *p_intf )
f_cpos = atof( p_cmd + 1 );
input_Seek( p_intf->p_input, (off_t) (f_cpos / f_ratio) );
/* rcreseek(f_cpos); */
}
break;
default:
intf_Msg( "rc: unknown command: %s", p_cmd );
intf_Msg( "rc: unknown command `%s'", p_cmd );
break;
}
}
}
p_intf->pf_manage( p_intf );
msleep( INTF_IDLE_SLEEP );
......
......@@ -2,7 +2,7 @@
* spu_decoder.c : spu decoder thread
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: spu_decoder.c,v 1.47 2001/06/02 01:09:03 sam Exp $
* $Id: spu_decoder.c,v 1.48 2001/08/06 13:13:06 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -319,6 +319,7 @@ static void ParsePacket( spudec_thread_t *p_spudec )
{
GetChunk( &p_spudec->bit_stream, p_src + i_offset, SPU_CHUNK_SIZE );
/* Abort subtitle parsing if we were requested to stop */
if( p_spudec->p_fifo->b_die )
{
free( p_src );
......@@ -336,7 +337,7 @@ static void ParsePacket( spudec_thread_t *p_spudec )
#endif
/* Getting the control part */
if( p_spudec->p_fifo->b_die || ParseControlSequences( p_spudec, p_spu ) )
if( ParseControlSequences( p_spudec, p_spu ) )
{
/* There was a parse error, delete the subpicture */
free( p_src );
......@@ -344,6 +345,10 @@ static void ParsePacket( spudec_thread_t *p_spudec )
return;
}
/* At this point, no more GetBit() command is needed, so we have all
* the data we need to tell whether the subtitle is valid. Thus we
* try to display it and we ignore b_die. */
if( ParseRLE( p_spudec, p_spu, p_src ) )
{
/* There was a parse error, delete the subpicture */
......@@ -489,6 +494,12 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
return( 1 );
}
/* We need to check for quit commands here */
if( p_spudec->p_fifo->b_die )
{
return( 1 );
}
} while( i_command != SPU_CMD_END );
} while( i_index == i_next_seq );
......@@ -534,7 +545,7 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
* we can deal with it */
default:
intf_WarnMsg( 2, "spudec warning: %i padding bytes, we usually "
"get 1 or none",
"get 0 or 1 of them",
p_spudec->i_spu_size - i_index );
while( i_index < p_spudec->i_spu_size )
......@@ -632,7 +643,7 @@ static int ParseRLE( spudec_thread_t *p_spudec,
{
intf_ErrMsg( "spudec error: out of bounds, %i at (%i,%i) is "
"out of %ix%i",
i_code >> 2, i_x, i_y, i_width, i_height);
i_code >> 2, i_x, i_y, i_width, i_height );
return( 1 );
}
......
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