Commit a0ae0628 authored by Stéphane Borel's avatar Stéphane Borel

-added eof for ts seekable streams
-close netlist when ts input ends
parent 3e22409a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ts.c: TS demux and netlist management * input_ts.c: TS demux and netlist management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input_ts.c,v 1.39 2001/11/28 15:08:05 massiot Exp $ * $Id: input_ts.c,v 1.40 2001/12/03 17:34:08 stef Exp $
* *
* Authors: Henri Fallon <henri@videolan.org> * Authors: Henri Fallon <henri@videolan.org>
* *
...@@ -225,7 +225,9 @@ static void TSEnd( input_thread_t * p_input ) ...@@ -225,7 +225,9 @@ static void TSEnd( input_thread_t * p_input )
if( p_pat_es != NULL ) if( p_pat_es != NULL )
input_DelES( p_input, p_pat_es ); input_DelES( p_input, p_pat_es );
free(p_input->p_plugin_data); free(p_input->p_plugin_data);
input_NetlistEnd( p_input );
} }
/***************************************************************************** /*****************************************************************************
...@@ -300,6 +302,7 @@ static int TSRead( input_thread_t * p_input, ...@@ -300,6 +302,7 @@ static int TSRead( input_thread_t * p_input,
if( (i_read == -1) && ( (errno == EAGAIN) || (errno = EWOULDBLOCK) ) ) if( (i_read == -1) && ( (errno == EAGAIN) || (errno = EWOULDBLOCK) ) )
{ {
/* just ignore that error */ /* just ignore that error */
intf_ErrMsg( "input error: 0 bytes read" );
i_read = 0; i_read = 0;
} }
#endif #endif
...@@ -308,9 +311,15 @@ static int TSRead( input_thread_t * p_input, ...@@ -308,9 +311,15 @@ static int TSRead( input_thread_t * p_input,
intf_ErrMsg( "input error: TS readv error" ); intf_ErrMsg( "input error: TS readv error" );
return( -1 ); return( -1 );
} }
/* EOF */
if( i_read == 0 && p_input->stream.b_seekable )
{
return( 1 );
}
input_NetlistMviovec( p_input->p_method_data, input_NetlistMviovec( p_input->p_method_data,
(int)(i_read/TS_PACKET_SIZE) , pp_packets ); (int)(((i_read-1)/TS_PACKET_SIZE)+1) , pp_packets );
/* check correct TS header */ /* check correct TS header */
for( i_loop=0; i_loop * TS_PACKET_SIZE < i_read; i_loop++ ) for( i_loop=0; i_loop * TS_PACKET_SIZE < i_read; i_loop++ )
...@@ -320,6 +329,10 @@ static int TSRead( input_thread_t * p_input, ...@@ -320,6 +329,10 @@ static int TSRead( input_thread_t * p_input,
"0x%.2x, should be 0x47)", "0x%.2x, should be 0x47)",
pp_packets[i_loop]->p_buffer[0] ); pp_packets[i_loop]->p_buffer[0] );
} }
for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
{
pp_packets[i_loop] = NULL;
}
p_input->stream.p_selected_area->i_tell += i_read; p_input->stream.p_selected_area->i_tell += i_read;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* will only be given back to netlist when refcount is zero. * will only be given back to netlist when refcount is zero.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input_netlist.c,v 1.46 2001/12/02 17:32:19 stef Exp $ * $Id: input_netlist.c,v 1.47 2001/12/03 17:34:08 stef Exp $
* *
* Authors: Henri Fallon <henri@videolan.org> * Authors: Henri Fallon <henri@videolan.org>
* Stphane Borel <stef@videolan.org> * Stphane Borel <stef@videolan.org>
...@@ -289,7 +289,7 @@ struct iovec * input_NetlistGetiovec( void * p_method_data ) ...@@ -289,7 +289,7 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
(p_netlist->i_iovec_end - p_netlist->i_iovec_start) (p_netlist->i_iovec_end - p_netlist->i_iovec_start)
& p_netlist->i_nb_iovec ) < p_netlist->i_read_once ) & p_netlist->i_nb_iovec ) < p_netlist->i_read_once )
{ {
intf_WarnMsg( 12, "input info: waiting for free iovec" ); intf_WarnMsg( 4, "input info: waiting for free iovec" );
msleep( INPUT_IDLE_SLEEP ); msleep( INPUT_IDLE_SLEEP );
while( ( while( (
...@@ -299,14 +299,14 @@ struct iovec * input_NetlistGetiovec( void * p_method_data ) ...@@ -299,14 +299,14 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
msleep( INPUT_IDLE_SLEEP ); msleep( INPUT_IDLE_SLEEP );
} }
intf_WarnMsg( 12, "input info: found free iovec" ); intf_WarnMsg( 4, "input info: found free iovec" );
} }
if( ( if( (
(p_netlist->i_data_end - p_netlist->i_data_start) (p_netlist->i_data_end - p_netlist->i_data_start)
& p_netlist->i_nb_data ) < p_netlist->i_read_once ) & p_netlist->i_nb_data ) < p_netlist->i_read_once )
{ {
intf_WarnMsg( 12, "input info: waiting for free data packet" ); intf_WarnMsg( 4, "input info: waiting for free data packet" );
msleep( INPUT_IDLE_SLEEP ); msleep( INPUT_IDLE_SLEEP );
while( ( while( (
...@@ -316,7 +316,7 @@ struct iovec * input_NetlistGetiovec( void * p_method_data ) ...@@ -316,7 +316,7 @@ struct iovec * input_NetlistGetiovec( void * p_method_data )
msleep( INPUT_IDLE_SLEEP ); msleep( INPUT_IDLE_SLEEP );
} }
intf_WarnMsg( 12, "input info: found free data packet" ); intf_WarnMsg( 4, "input info: found free data packet" );
} }
/* readv only takes contiguous buffers /* readv only takes contiguous buffers
...@@ -373,7 +373,11 @@ void input_NetlistMviovec( void * p_method_data, int i_nb_iovec, ...@@ -373,7 +373,11 @@ void input_NetlistMviovec( void * p_method_data, int i_nb_iovec,
pp_data[i_loop]->pi_refcount = p_netlist->pi_refcount + pp_data[i_loop]->pi_refcount = p_netlist->pi_refcount +
p_netlist->i_iovec_start; p_netlist->i_iovec_start;
//(*pp_data[i_loop]->pi_refcount)++; if( (*pp_data[i_loop]->pi_refcount) != 0)
{
intf_ErrMsg( "netlist error: refcount should be 0 (%d)",
(*pp_data[i_loop]->pi_refcount) );
}
(*pp_data[i_loop]->pi_refcount) = 1; (*pp_data[i_loop]->pi_refcount) = 1;
p_netlist->i_iovec_start ++; p_netlist->i_iovec_start ++;
...@@ -485,7 +489,11 @@ struct data_packet_s * input_NetlistNewPacket( void * p_method_data, ...@@ -485,7 +489,11 @@ struct data_packet_s * input_NetlistNewPacket( void * p_method_data,
p_packet->b_discard_payload = 0; p_packet->b_discard_payload = 0;
p_packet->pi_refcount = p_netlist->pi_refcount + p_netlist->i_iovec_start; p_packet->pi_refcount = p_netlist->pi_refcount + p_netlist->i_iovec_start;
//(*p_packet->pi_refcount)++; if( (*p_packet->pi_refcount) != 0)
{
intf_ErrMsg( "netlist error: refcount should be 0 (%d)",
(*p_packet->pi_refcount) );
}
(*p_packet->pi_refcount) = 1; (*p_packet->pi_refcount) = 1;
p_netlist->i_iovec_start ++; p_netlist->i_iovec_start ++;
...@@ -568,7 +576,7 @@ void input_NetlistDeletePacket( void * p_method_data, data_packet_t * p_data ) ...@@ -568,7 +576,7 @@ void input_NetlistDeletePacket( void * p_method_data, data_packet_t * p_data )
/* Update reference counter */ /* Update reference counter */
(*p_data->pi_refcount)--; (*p_data->pi_refcount)--;
if( (*p_data->pi_refcount) <= 0 ) if( (*p_data->pi_refcount) == 0 )
{ {
(*p_data->pi_refcount) = 0; (*p_data->pi_refcount) = 0;
p_netlist->i_iovec_end++; p_netlist->i_iovec_end++;
...@@ -576,6 +584,11 @@ void input_NetlistDeletePacket( void * p_method_data, data_packet_t * p_data ) ...@@ -576,6 +584,11 @@ void input_NetlistDeletePacket( void * p_method_data, data_packet_t * p_data )
p_netlist->p_free_iovec[p_netlist->i_iovec_end].iov_base = p_netlist->p_free_iovec[p_netlist->i_iovec_end].iov_base =
p_data->p_buffer; p_data->p_buffer;
} }
else if( (*p_data->pi_refcount) < 0 )
{
intf_ErrMsg( "netlist error: refcount can't be negative (%d)",
(*p_data->pi_refcount) );
}
/* unlock */ /* unlock */
vlc_mutex_unlock (&p_netlist->lock); vlc_mutex_unlock (&p_netlist->lock);
...@@ -615,7 +628,7 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes ) ...@@ -615,7 +628,7 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes )
/* Update reference counter */ /* Update reference counter */
(*p_current_packet->pi_refcount)--; (*p_current_packet->pi_refcount)--;
if( (*p_current_packet->pi_refcount) <= 0 ) if( (*p_current_packet->pi_refcount) == 0 )
{ {
(*p_current_packet->pi_refcount) = 0; (*p_current_packet->pi_refcount) = 0;
p_netlist->i_iovec_end++; p_netlist->i_iovec_end++;
...@@ -623,6 +636,11 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes ) ...@@ -623,6 +636,11 @@ void input_NetlistDeletePES( void * p_method_data, pes_packet_t * p_pes )
p_netlist->p_free_iovec[p_netlist->i_iovec_end].iov_base = p_netlist->p_free_iovec[p_netlist->i_iovec_end].iov_base =
p_current_packet->p_buffer; p_current_packet->p_buffer;
} }
else if( (*p_current_packet->pi_refcount) < 0 )
{
intf_ErrMsg( "netlist error: refcount can't be negative (%d)",
(*p_current_packet->pi_refcount) );
}
p_next_packet = p_current_packet->p_next; p_next_packet = p_current_packet->p_next;
p_current_packet->p_next = NULL; p_current_packet->p_next = NULL;
......
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