Commit a98b6aba authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

demux: remove redundant calls to vlc_object_alive()

If the input is dead, the source stream (demux_t.s) return an
error. There is no point checking that the demux is dead separately. In
fact, there is even a race where the stream will be dead but the demux
will not.
parent ce799fe3
...@@ -355,13 +355,6 @@ static int Open ( vlc_object_t *p_this ) ...@@ -355,13 +355,6 @@ static int Open ( vlc_object_t *p_this )
{ {
int i_read = stream_Read( p_demux->s, &p_sdp[i_sdp], int i_read = stream_Read( p_demux->s, &p_sdp[i_sdp],
i_sdp_max - i_sdp - 1 ); i_sdp_max - i_sdp - 1 );
if( !vlc_object_alive (p_demux) )
{
free( p_sdp );
goto error;
}
if( i_read < 0 ) if( i_read < 0 )
{ {
msg_Err( p_demux, "failed to read SDP" ); msg_Err( p_demux, "failed to read SDP" );
......
...@@ -205,8 +205,6 @@ static int Demux( demux_t *p_demux ) ...@@ -205,8 +205,6 @@ static int Demux( demux_t *p_demux )
mtime_t i_time_begin = GetMoviePTS( p_sys ); mtime_t i_time_begin = GetMoviePTS( p_sys );
int i_result; int i_result;
if( !vlc_object_alive (p_demux) )
break;
#if 0 #if 0
/* FIXME: returns EOF too early for some mms streams */ /* FIXME: returns EOF too early for some mms streams */
if( p_sys->i_data_end >= 0 && if( p_sys->i_data_end >= 0 &&
......
...@@ -718,9 +718,6 @@ aviindex: ...@@ -718,9 +718,6 @@ aviindex:
(mtime_t)p_avih->i_microsecperframe / (mtime_t)p_avih->i_microsecperframe /
CLOCK_FREQ ) CLOCK_FREQ )
{ {
if( !vlc_object_alive( p_demux) )
goto error;
msg_Warn( p_demux, "broken or missing index, 'seek' will be " msg_Warn( p_demux, "broken or missing index, 'seek' will be "
"approximative or will exhibit strange behavior" ); "approximative or will exhibit strange behavior" );
if( (i_do_index == 0 || i_do_index == 3) && !b_index ) if( (i_do_index == 0 || i_do_index == 3) && !b_index )
...@@ -1128,7 +1125,6 @@ static int Demux_Seekable( demux_t *p_demux ) ...@@ -1128,7 +1125,6 @@ static int Demux_Seekable( demux_t *p_demux )
* affect the reading speed too much. */ * affect the reading speed too much. */
if( !(++i_loop_count % 1024) ) if( !(++i_loop_count % 1024) )
{ {
if( !vlc_object_alive (p_demux) ) return -1;
msleep( 10000 ); msleep( 10000 );
if( !(i_loop_count % (1024 * 10)) ) if( !(i_loop_count % (1024 * 10)) )
...@@ -1775,8 +1771,6 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream ) ...@@ -1775,8 +1771,6 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
for( ;; ) for( ;; )
{ {
if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
if( AVI_PacketGetHeader( p_demux, &avi_pk ) ) if( AVI_PacketGetHeader( p_demux, &avi_pk ) )
{ {
msg_Warn( p_demux, "cannot get packet header" ); msg_Warn( p_demux, "cannot get packet header" );
...@@ -1795,7 +1789,6 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream ) ...@@ -1795,7 +1789,6 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
* affect the reading speed too much. */ * affect the reading speed too much. */
if( !(++i_loop_count % 1024) ) if( !(++i_loop_count % 1024) )
{ {
if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
msleep( 10000 ); msleep( 10000 );
if( !(i_loop_count % (1024 * 10)) ) if( !(i_loop_count % (1024 * 10)) )
...@@ -2233,8 +2226,6 @@ static int AVI_PacketSearch( demux_t *p_demux ) ...@@ -2233,8 +2226,6 @@ static int AVI_PacketSearch( demux_t *p_demux )
* this code is called only on broken files). */ * this code is called only on broken files). */
if( !(++i_count % 1024) ) if( !(++i_count % 1024) )
{ {
if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
msleep( 10000 ); msleep( 10000 );
if( !(i_count % (1024 * 10)) ) if( !(i_count % (1024 * 10)) )
msg_Warn( p_demux, "trying to resync..." ); msg_Warn( p_demux, "trying to resync..." );
...@@ -2572,9 +2563,6 @@ static void AVI_IndexCreate( demux_t *p_demux ) ...@@ -2572,9 +2563,6 @@ static void AVI_IndexCreate( demux_t *p_demux )
{ {
avi_packet_t pk; avi_packet_t pk;
if( !vlc_object_alive (p_demux) )
break;
/* Don't update/check dialog too often */ /* Don't update/check dialog too often */
if( p_dialog && mdate() - i_dialog_update > 100000 ) if( p_dialog && mdate() - i_dialog_update > 100000 )
{ {
......
...@@ -239,13 +239,14 @@ static int OpenCommon( demux_t *p_demux, ...@@ -239,13 +239,14 @@ static int OpenCommon( demux_t *p_demux,
} }
} }
while( vlc_object_alive( p_demux ) ) for( ;; )
{ {
if( Parse( p_demux, &p_sys->p_packetized_data ) ) if( Parse( p_demux, &p_sys->p_packetized_data ) )
break; break;
if( p_sys->p_packetized_data ) if( p_sys->p_packetized_data )
break; break;
} }
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int OpenAudio( vlc_object_t *p_this ) static int OpenAudio( vlc_object_t *p_this )
......
...@@ -364,9 +364,6 @@ static int Demux( demux_t *p_demux ) ...@@ -364,9 +364,6 @@ static int Demux( demux_t *p_demux )
for( ;; ) for( ;; )
{ {
if( !vlc_object_alive (p_demux) )
return -1;
if( FrameHeaderLoad( p_demux, &fh ) ) if( FrameHeaderLoad( p_demux, &fh ) )
return 0; return 0;
...@@ -573,7 +570,7 @@ static int ControlSetPosition( demux_t *p_demux, int64_t i_pos, bool b_guess ) ...@@ -573,7 +570,7 @@ static int ControlSetPosition( demux_t *p_demux, int64_t i_pos, bool b_guess )
} }
} }
while( vlc_object_alive (p_demux) ) for( ;; )
{ {
frame_header_t fh; frame_header_t fh;
int64_t i_tell; int64_t i_tell;
......
...@@ -251,7 +251,7 @@ static void FindLength( demux_t *p_demux ) ...@@ -251,7 +251,7 @@ static void FindLength( demux_t *p_demux )
/* Check beginning */ /* Check beginning */
int i = 0; int i = 0;
i_current_pos = stream_Tell( p_demux->s ); i_current_pos = stream_Tell( p_demux->s );
while( vlc_object_alive (p_demux) && i < 40 && Demux2( p_demux, false ) > 0 ) i++; while( i < 40 && Demux2( p_demux, false ) > 0 ) i++;
/* Check end */ /* Check end */
i_size = stream_Size( p_demux->s ); i_size = stream_Size( p_demux->s );
...@@ -259,7 +259,7 @@ static void FindLength( demux_t *p_demux ) ...@@ -259,7 +259,7 @@ static void FindLength( demux_t *p_demux )
stream_Seek( p_demux->s, i_size - i_end ); stream_Seek( p_demux->s, i_size - i_end );
i = 0; i = 0;
while( vlc_object_alive (p_demux) && i < 400 && Demux2( p_demux, true ) > 0 ) i++; while( i < 400 && Demux2( p_demux, true ) > 0 ) i++;
if( i_current_pos >= 0 ) stream_Seek( p_demux->s, i_current_pos ); if( i_current_pos >= 0 ) stream_Seek( p_demux->s, i_current_pos );
} }
......
...@@ -1182,7 +1182,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -1182,7 +1182,7 @@ static int Open( vlc_object_t *p_this )
} }
} }
while( p_sys->i_pmt_es <= 0 && vlc_object_alive( p_demux ) while( p_sys->i_pmt_es <= 0
&& (!p_sys->pid[0].b_seen && !p_sys->patfix.b_pat_deadline) ) && (!p_sys->pid[0].b_seen && !p_sys->patfix.b_pat_deadline) )
{ {
if( Demux( p_demux ) != 1 ) if( Demux( p_demux ) != 1 )
...@@ -1193,7 +1193,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -1193,7 +1193,7 @@ static int Open( vlc_object_t *p_this )
if( p_sys->i_pmt_es == 0 && !p_sys->pid[0].b_seen ) if( p_sys->i_pmt_es == 0 && !p_sys->pid[0].b_seen )
MissingPATPMTFixup( p_demux ); MissingPATPMTFixup( p_demux );
while( p_sys->i_pmt_es <= 0 && vlc_object_alive( p_demux ) ) while( p_sys->i_pmt_es <= 0 )
{ {
if( Demux( p_demux ) != 1 ) if( Demux( p_demux ) != 1 )
break; break;
...@@ -2397,7 +2397,7 @@ static block_t* ReadTSPacket( demux_t *p_demux ) ...@@ -2397,7 +2397,7 @@ static block_t* ReadTSPacket( demux_t *p_demux )
{ {
msg_Warn( p_demux, "lost synchro" ); msg_Warn( p_demux, "lost synchro" );
block_Release( p_pkt ); block_Release( p_pkt );
while( vlc_object_alive (p_demux) ) for( ;; )
{ {
const uint8_t *p_peek; const uint8_t *p_peek;
int i_peek, i_skip = 0; int i_peek, i_skip = 0;
...@@ -2520,7 +2520,7 @@ static int SeekToPCR( demux_t *p_demux, int64_t i_pos ) ...@@ -2520,7 +2520,7 @@ static int SeekToPCR( demux_t *p_demux, int64_t i_pos )
if( stream_Seek( p_sys->stream, i_pos ) ) if( stream_Seek( p_sys->stream, i_pos ) )
return VLC_EGENERIC; return VLC_EGENERIC;
while( vlc_object_alive( p_demux ) ) for( ;; )
{ {
block_t *p_pkt; block_t *p_pkt;
...@@ -2630,7 +2630,7 @@ static void GetFirstPCR( demux_t *p_demux ) ...@@ -2630,7 +2630,7 @@ static void GetFirstPCR( demux_t *p_demux )
if( stream_Seek( p_sys->stream, 0 ) ) if( stream_Seek( p_sys->stream, 0 ) )
return; return;
while( vlc_object_alive (p_demux) ) for( ;; )
{ {
block_t *p_pkt; block_t *p_pkt;
...@@ -2671,7 +2671,7 @@ static void GetLastPCR( demux_t *p_demux ) ...@@ -2671,7 +2671,7 @@ static void GetLastPCR( demux_t *p_demux )
if( i_pos < 0 && i_pos >= i_stream_size ) if( i_pos < 0 && i_pos >= i_stream_size )
return; return;
while( vlc_object_alive( p_demux ) ) for( ;; )
{ {
if( SeekToPCR( p_demux, i_pos ) ) if( SeekToPCR( p_demux, i_pos ) )
break; break;
...@@ -2698,7 +2698,7 @@ static void CheckPCR( demux_t *p_demux ) ...@@ -2698,7 +2698,7 @@ static void CheckPCR( demux_t *p_demux )
p_sys->p_pcrs[0] = p_sys->i_first_pcr; p_sys->p_pcrs[0] = p_sys->i_first_pcr;
p_sys->p_pos[0] = i_initial_pos; p_sys->p_pos[0] = i_initial_pos;
for( i = 1; i < p_sys->i_pcrs_num && vlc_object_alive( p_demux ); ++i ) for( i = 1; i < p_sys->i_pcrs_num; ++i )
{ {
/* Round i_pos to a multiple of p_sys->i_packet_size */ /* Round i_pos to a multiple of p_sys->i_packet_size */
int64_t i_pos = i_size / p_sys->i_pcrs_num * i; int64_t i_pos = i_size / p_sys->i_pcrs_num * i;
......
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