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

modules: use vlc_object_alive()

parent d10dffca
......@@ -548,7 +548,7 @@ static block_t *Block( access_t *p_access )
block_t *p_block;
long l_buffer_len;
if( p_access->b_die )
if( !vlc_object_alive (p_access) )
return NULL;
l_buffer_len = dvb_GetBufferSize( p_access );
......
......@@ -1639,7 +1639,7 @@ static block_t *ReadCompressed( access_t *p_access )
while( 1 )
{
if( p_access->b_die || p_access->b_error ) return 0;
if( !vlc_object_alive (p_access) || p_access->b_error ) return 0;
/* Get new sample/frame from the elementary stream (blocking). */
vlc_mutex_lock( &p_sys->lock );
......
......@@ -368,7 +368,7 @@ static int Raw1394EventThread( vlc_object_t *p_this )
vlc_thread_ready( p_this );
while( !p_sys->p_ev->b_die )
while( vlc_object_alive (p_sys->p_ev) )
{
while( ( result = poll( &(p_sys->raw1394_poll), 1, 200 ) ) < 0 )
{
......@@ -380,7 +380,7 @@ static int Raw1394EventThread( vlc_object_t *p_this )
if( p_sys->p_ev->b_die )
break;
}
if( p_sys->p_ev->b_die )
if( !vlc_object_alive (p_sys->p_ev) )
break;
if( result > 0 && ( ( p_sys->raw1394_poll.revents & POLLIN )
|| ( p_sys->raw1394_poll.revents & POLLPRI ) ) )
......
......@@ -430,7 +430,7 @@ static block_t *Block( access_t *p_access )
/* Find if some data is available */
i_ret = poll( ufds, 2, 500 );
if ( p_access->b_die )
if ( !vlc_object_alive (p_access) )
return NULL;
if ( i_ret < 0 )
......
......@@ -1910,7 +1910,7 @@ int en50221_Init( access_t * p_access )
#if HLCI_WAIT_CAM_READY
while( ca_msg.msg[8] == 0xff && ca_msg.msg[9] == 0xff )
{
if( p_access->b_die ) return VLC_EGENERIC;
if( !vlc_object_alive (p_access) ) return VLC_EGENERIC;
msleep(1);
msg_Dbg( p_access, "CAM: please wait" );
APDUSend( p_access, 1, AOT_APPLICATION_INFO_ENQ, NULL, 0 );
......
......@@ -1234,7 +1234,7 @@ static int EventThread( vlc_object_t *p_this )
var_AddCallback( p_ev->p_libvlc, "key-action", EventKey, p_ev );
/* main loop */
while( !p_ev->b_die )
while( vlc_object_alive (p_ev) )
{
bool b_activated = false;
......@@ -1297,7 +1297,7 @@ static int EventThread( vlc_object_t *p_this )
p_ev->b_clicked = false;
vlc_mutex_unlock( &p_ev->lock );
}
if( p_vout && p_vout->b_die )
if( p_vout && !vlc_object_alive (p_vout) )
{
var_DelCallback( p_vout, "mouse-moved", EventMouse, p_ev );
var_DelCallback( p_vout, "mouse-clicked", EventMouse, p_ev );
......
......@@ -415,7 +415,7 @@ connect:
p_sys->i_version = 0;
p_sys->b_seekable = false;
if( p_access->b_die || Connect( p_access, 0 ) )
if( !vlc_object_alive (p_access) || Connect( p_access, 0 ) )
goto error;
#ifndef NDEBUG
......@@ -1079,7 +1079,7 @@ static int Connect( access_t *p_access, int64_t i_tell )
free( psz );
if( p_access->b_die || p_access->b_error )
if( !vlc_object_alive (p_access) || p_access->b_error )
{
Disconnect( p_access );
return -1;
......@@ -1265,7 +1265,7 @@ static int Request( access_t *p_access, int64_t i_tell )
goto error;
}
if( p_access->b_die || p_access->b_error )
if( !vlc_object_alive (p_access) || p_access->b_error )
{
free( psz );
goto error;
......
......@@ -326,7 +326,7 @@ static int Seek( access_t *p_access, int64_t i_pos )
Stop( p_access );
Start( p_access, i_packet * p_sys->asfh.i_min_data_packet_size );
while( !p_access->b_die )
while( vlc_object_alive (p_access) )
{
msg_Warn( p_access, "GetPacket 1" );
if( GetPacket( p_access, &ck ) )
......
......@@ -389,7 +389,7 @@ static int Seek( access_t * p_access, int64_t i_pos )
var_buffer_free( &buffer );
while( !p_access->b_die )
while( vlc_object_alive (p_access) )
{
if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 )
{
......@@ -404,7 +404,7 @@ static int Seek( access_t * p_access, int64_t i_pos )
}
}
while( !p_access->b_die )
while( vlc_object_alive (p_access) )
{
if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 )
{
......@@ -1116,7 +1116,7 @@ static int NetFillBuffer( access_t *p_access )
return -1;
}
if( p_access->b_die || p_access->b_error ) return -1;
if( !vlc_object_alive (p_access) || p_access->b_error ) return -1;
//msg_Dbg( p_access, "NetFillBuffer: trying again (select)" );
......@@ -1552,7 +1552,7 @@ static int mms_HeaderMediaRead( access_t *p_access, int i_type )
{
int i_status;
if( p_access->b_die )
if( !vlc_object_alive (p_access) )
return -1;
i_status = mms_ReceivePacket( p_access );
......
......@@ -1083,7 +1083,7 @@ static ssize_t Read( access_t * p_access, uint8_t * p_buffer, size_t i_len )
do
{
if( p_access->b_die )
if( !vlc_object_alive (p_access) )
return 0;
ufd.revents = 0;
......
......@@ -311,7 +311,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
while( i_len_tmp < i_len )
{
if( p_sys->p_thread->result_stop || p_access->info.b_eof || p_access->b_die )
if( p_sys->p_thread->result_stop || p_access->info.b_eof || !vlc_object_alive (p_access) )
{
p_access->info.b_eof = true;
return 0;
......@@ -510,7 +510,7 @@ static void ThreadControl( vlc_object_t *p_this )
rtmp_init_handler( p_thread->rtmp_handler );
while( !p_thread->b_die )
while( vlc_object_alive (p_thread) )
{
rtmp_packet = rtmp_read_net_packet( p_thread );
if( rtmp_packet != NULL )
......
......@@ -1440,7 +1440,7 @@ static uint8_t *GrabCapture( demux_t *p_demux )
return NULL;
}
if( p_demux->b_die )
if( !vlc_object_alive (p_demux) )
{
return NULL;
}
......
......@@ -1323,7 +1323,7 @@ static ssize_t AccessRead( access_t * p_access, uint8_t * p_buffer, size_t i_len
do
{
if( p_access->b_die )
if( !vlc_object_alive (p_access) )
return 0;
ufd.revents = 0;
......
......@@ -124,7 +124,7 @@ RunIntf( intf_thread_t *p_intf )
dbg_print( INPUT_DBG_CALL, "intf initialized" );
/* Main loop */
while( !p_intf->b_die )
while( vlc_object_alive (p_intf) )
{
vlc_mutex_lock( &p_intf->change_lock );
......@@ -317,7 +317,7 @@ RunIntf( intf_thread_t *p_intf )
static int InitThread( intf_thread_t * p_intf )
{
/* We might need some locking here */
if( !p_intf->b_die )
if( vlc_object_alive (p_intf) )
{
input_thread_t * p_input;
......
......@@ -275,7 +275,7 @@ static void Thread( access_t *p_access )
access_t *p_src = p_access->p_source;
block_t *p_block;
while( !p_access->b_die )
while( vlc_object_alive (p_access) )
{
/* Get a new block from the source */
if( p_src->pf_block )
......@@ -320,7 +320,7 @@ static void Thread( access_t *p_access )
/* Read from file to fill up the fifo */
while( block_FifoSize( p_sys->p_fifo ) < TIMESHIFT_FIFO_MIN &&
!p_access->b_die )
vlc_object_alive (p_access) )
{
p_block = ReadBlockFromFile( p_access );
if( !p_block ) break;
......@@ -331,12 +331,12 @@ static void Thread( access_t *p_access )
msg_Dbg( p_access, "timeshift: no more input data" );
while( !p_access->b_die &&
while( vlc_object_alive (p_access) &&
(p_sys->p_read_list || block_FifoSize( p_sys->p_fifo ) ) )
{
/* Read from file to fill up the fifo */
while( block_FifoSize( p_sys->p_fifo ) < TIMESHIFT_FIFO_MIN &&
!p_access->b_die && p_sys->p_read_list )
vlc_object_alive (p_access) && p_sys->p_read_list )
{
p_block = ReadBlockFromFile( p_access );
if( !p_block ) break;
......
......@@ -185,7 +185,7 @@ static void poll_iterate_thread( poll_thread_t *p_pt )
{
vlc_thread_ready( p_pt );
while( !p_pt->b_die )
while( vlc_object_alive (p_pt) )
if( avahi_simple_poll_iterate( p_pt->simple_poll, 100 ) != 0 )
break;
}
......
......@@ -386,7 +386,7 @@ static void ThreadControl( vlc_object_t *p_this )
rtmp_init_handler( p_thread->rtmp_handler );
while( !p_thread->b_die )
while( vlc_object_alive (p_thread) )
{
rtmp_packet = rtmp_read_net_packet( p_thread );
if( rtmp_packet != NULL )
......
......@@ -444,7 +444,7 @@ static void ThreadWrite( vlc_object_t *p_this )
mtime_t i_to_send = p_thread->i_group;
int i_dropped_packets = 0;
while( !p_thread->b_die )
while( vlc_object_alive (p_thread) )
{
block_t *p_pk;
mtime_t i_date, i_sent;
......
......@@ -764,16 +764,16 @@ static int ALSAThread( aout_instance_t * p_aout )
/* Wait for the exact time to start playing (avoids resampling) */
vlc_mutex_lock( &p_sys->lock );
while( !p_sys->start_date && !p_aout->b_die )
while( !p_sys->start_date && vlc_object_alive (p_aout) )
vlc_cond_wait( &p_sys->wait, &p_sys->lock );
vlc_mutex_unlock( &p_sys->lock );
if( p_aout->b_die )
if( !vlc_object_alive (p_aout) )
goto cleanup;
mwait( p_sys->start_date - AOUT_PTS_TOLERANCE / 4 );
while ( !p_aout->b_die )
while ( vlc_object_alive (p_aout) )
{
ALSAFill( p_aout );
}
......@@ -876,7 +876,7 @@ static void ALSAFill( aout_instance_t * p_aout )
* (stream is suspended and waiting for an application recovery) */
msg_Dbg( p_aout, "entering in suspend mode, trying to resume..." );
while( !p_aout->b_die && !p_aout->p_libvlc->b_die &&
while( vlc_object_alive (p_aout) && vlc_object_alive (p_aout->p_libvlc) &&
( i_snd_rc = snd_pcm_resume( p_sys->p_snd_pcm ) ) == -EAGAIN )
{
msleep( 1000000 );
......
......@@ -1064,7 +1064,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
/* Wait here until Play() is called */
WaitForSingleObject( p_notif->event, INFINITE );
if( !p_notif->b_die )
if( vlc_object_alive (p_notif) )
{
mwait( p_notif->start_date - AOUT_PTS_TOLERANCE / 2 );
......@@ -1089,7 +1089,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
}
last_time = mdate();
while( !p_notif->b_die )
while( vlc_object_alive (p_notif) )
{
long l_read, l_free_slots;
mtime_t mtime = mdate();
......
......@@ -222,7 +222,7 @@ static int Thread( aout_instance_t * p_aout )
struct aout_sys_t * p_sys = p_aout->output.p_sys;
PCMAudioPlayer * pPlayer = p_sys->pPlayer;
while( !p_aout->b_die )
while( vlc_object_alive (p_aout) )
{
pPlayer->WaitForBuffer();
......
......@@ -589,7 +589,7 @@ static int OSSThread( aout_instance_t * p_aout )
struct aout_sys_t * p_sys = p_aout->output.p_sys;
mtime_t next_date = 0;
while ( !p_aout->b_die )
while ( vlc_object_alive (p_aout) )
{
aout_buffer_t * p_buffer = NULL;
int i_tmp, i_size;
......@@ -646,7 +646,7 @@ static int OSSThread( aout_instance_t * p_aout )
}
}
while( !p_aout->b_die && ! ( p_buffer =
while( vlc_object_alive (p_aout) && ! ( p_buffer =
aout_OutputNextBuffer( p_aout, next_date, true ) ) )
{
msleep( 1000 );
......
......@@ -578,7 +578,7 @@ static void PORTAUDIOThread( pa_thread_t *pa_thread )
aout_sys_t *p_sys;
int i_err;
while( !pa_thread->b_die )
while( vlc_object_alive (pa_thread) )
{
/* Wait for start of stream */
vlc_mutex_lock( &pa_thread->lock_signal );
......
......@@ -908,7 +908,7 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
if( uMsg != WOM_DONE ) return;
if( p_aout->b_die ) return;
if( !vlc_object_alive (p_aout) ) return;
/* Find out the current latency */
for( i = 0; i < FRAMES_NUM; i++ )
......@@ -984,9 +984,9 @@ static void WaveOutThread( notification_thread_t *p_notif )
b_sleek = p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i');
// wait for first call to "play()"
while( !p_sys->start_date && !p_aout->b_die )
while( !p_sys->start_date && vlc_object_alive (p_aout) )
WaitForSingleObject( p_sys->event, INFINITE );
if( p_aout->b_die )
if( !vlc_object_alive (p_aout) )
return;
msg_Dbg( p_aout, "will start to play in %"PRId64" us",
......@@ -1003,12 +1003,12 @@ static void WaveOutThread( notification_thread_t *p_notif )
p_aout->output.b_starving, msg);
next_date = mdate();
while( !p_aout->b_die )
while( vlc_object_alive (p_aout) )
{
/* Cleanup and find out the current latency */
i_queued_frames = WaveOutClearDoneBuffers( p_sys );
if( p_aout->b_die ) return;
if( !vlc_object_alive (p_aout) ) return;
/* Try to fill in as many frame buffers as possible */
for( i = 0; i < FRAMES_NUM; i++ )
......@@ -1084,7 +1084,7 @@ static void WaveOutThread( notification_thread_t *p_notif )
}
}
if( p_aout->b_die ) return;
if( !vlc_object_alive (p_aout) ) return;
/*
deal with the case that the loop didn't fillup the buffer to the
......
......@@ -702,16 +702,16 @@ int OpenEncoder( vlc_object_t *p_this )
****************************************************************************/
static int FfmpegThread( struct thread_context_t *p_context )
{
while ( !p_context->b_die && !p_context->b_error )
while ( vlc_object_alive (p_context) && !p_context->b_error )
{
vlc_mutex_lock( &p_context->lock );
while ( !p_context->b_work && !p_context->b_die && !p_context->b_error )
while ( !p_context->b_work && vlc_object_alive (p_context) && !p_context->b_error )
{
vlc_cond_wait( &p_context->cond, &p_context->lock );
}
p_context->b_work = 0;
vlc_mutex_unlock( &p_context->lock );
if ( p_context->b_die || p_context->b_error )
if ( !vlc_object_alive (p_context) || p_context->b_error )
break;
if ( p_context->pf_func )
......
......@@ -189,10 +189,10 @@ static void RunIntf( intf_thread_t *p_intf )
#endif
/* Main loop */
while( !p_intf->b_die )
while( vlc_object_alive (p_intf) )
{
/* if video output is dying, disassociate ourselves from it */
if( p_vout && p_vout->b_die )
if( p_vout && !vlc_object_alive (p_vout) )
{
var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
vlc_object_release( p_vout );
......@@ -334,7 +334,7 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
static int InitThread( intf_thread_t * p_intf )
{
/* We might need some locking here */
if( !p_intf->b_die )
if( vlc_object_alive (p_intf) )
{
input_thread_t * p_input;
decoder_t *p_cmml_decoder;
......
......@@ -327,7 +327,7 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t *p_spu,
}
/* We need to check for quit commands here */
if( p_dec->b_die )
if( !vlc_object_alive (p_dec) )
{
return VLC_EGENERIC;
}
......
......@@ -420,7 +420,7 @@ static void RunIntf( intf_thread_t *p_intf )
/*
* video output
*/
if( p_intf->p_sys->p_vout && p_intf->p_sys->p_vout->b_die )
if( p_intf->p_sys->p_vout && !vlc_object_alive (p_intf->p_sys->p_vout) )
{
var_DelCallback( p_intf->p_sys->p_vout, "mouse-moved",
MouseEvent, p_intf );
......
......@@ -517,7 +517,7 @@ static void Run( intf_thread_t *p_intf )
/* New input has been registered */
if( p_input )
{
if( !p_input->b_dead || !p_input->b_die )
if( !p_input->b_dead || vlc_object_alive (p_input) )
{
char *psz_uri =
input_item_GetURI( input_GetItem( p_input ) );
......@@ -554,7 +554,7 @@ static void Run( intf_thread_t *p_intf )
}
}
if( (p_input != NULL) && !p_input->b_dead && !p_input->b_die &&
if( (p_input != NULL) && !p_input->b_dead && vlc_object_alive (p_input) &&
(p_playlist != NULL) )
{
vlc_object_lock( p_playlist );
......
......@@ -135,7 +135,7 @@ static void RunIntf( intf_thread_t *p_intf )
/* Take care of the video output */
if( p_intf->p_sys->p_vout && p_intf->p_sys->p_vout->b_die )
if( p_intf->p_sys->p_vout && !vlc_object_alive (p_intf->p_sys->p_vout) )
{
var_DelCallback( p_intf->p_sys->p_vout, "mouse-moved",
MouseEvent, p_intf );
......
......@@ -150,7 +150,7 @@ static int Demux( demux_t *p_demux )
mtime_t i_time_begin = GetMoviePTS( p_sys );
int i_result;
if( p_demux->b_die )
if( !vlc_object_alive (p_demux) )
break;
#if 0
/* FIXME: returns EOF too early for some mms streams */
......
......@@ -977,7 +977,7 @@ static int Demux_Seekable( demux_t *p_demux )
* affect the reading speed too much. */
if( !(++i_loop_count % 1024) )
{
if( p_demux->b_die ) return -1;
if( !vlc_object_alive (p_demux) ) return -1;
msleep( 10000 );
if( !(i_loop_count % (1024 * 10)) )
......@@ -1595,7 +1595,7 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
for( ;; )
{
if( p_demux->b_die ) return VLC_EGENERIC;
if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
if( AVI_PacketGetHeader( p_demux, &avi_pk ) )
{
......@@ -1615,7 +1615,7 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
* affect the reading speed too much. */
if( !(++i_loop_count % 1024) )
{
if( p_demux->b_die ) return VLC_EGENERIC;
if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
msleep( 10000 );
if( !(i_loop_count % (1024 * 10)) )
......@@ -2098,7 +2098,7 @@ static int AVI_PacketSearch( demux_t *p_demux )
* this code is called only on broken files). */
if( !(++i_count % 1024) )
{
if( p_demux->b_die ) return VLC_EGENERIC;
if( !vlc_object_alive (p_demux) ) return VLC_EGENERIC;
msleep( 10000 );
if( !(i_count % (1024 * 10)) )
......@@ -2394,7 +2394,7 @@ static void AVI_IndexCreate( demux_t *p_demux )
{
avi_packet_t pk;
if( p_demux->b_die )
if( !vlc_object_alive (p_demux) )
{
return;
}
......
......@@ -323,7 +323,7 @@ static int Open ( vlc_object_t *p_this )
int i_read = stream_Read( p_demux->s, &p_sdp[i_sdp],
i_sdp_max - i_sdp - 1 );
if( p_demux->b_die || p_demux->b_error )
if( !vlc_object_alive (p_demux) || p_demux->b_error )
{
free( p_sdp );
goto error;
......@@ -507,7 +507,7 @@ static int Connect( demux_t *p_demux )
i_lefttries = 3;
createnew:
i_lefttries--;
if( p_demux->b_die || p_demux->b_error )
if( !vlc_object_alive (p_demux) || p_demux->b_error )
{
free( psz_user );
free( psz_pwd );
......@@ -669,7 +669,7 @@ static int SessionsSetup( demux_t *p_demux )
Boolean bInit;
live_track_t *tk;
if( p_demux->b_die || p_demux->b_error )
if( !vlc_object_alive (p_demux) || p_demux->b_error )
{
delete iter;
return VLC_EGENERIC;
......@@ -1796,7 +1796,7 @@ static void TimeoutPrevention( timeout_thread_t *p_timeout )
vlc_thread_ready( p_timeout );
/* Avoid lock */
while( !p_timeout->b_die )
while( vlc_object_alive (p_timeout) )
{
if( p_timeout->i_remain <= 0 )
{
......
......@@ -2796,7 +2796,7 @@ int demux_sys_t::EventThread( vlc_object_t *p_this )
var_AddCallback( p_ev->p_libvlc, "key-action", EventKey, p_ev );
/* main loop */
while( !p_ev->b_die )
while( vlc_object_alive (p_ev) )
{
if ( !p_sys->b_pci_packet_set )
{
......@@ -3054,7 +3054,7 @@ int demux_sys_t::EventThread( vlc_object_t *p_this )
}
/* VOUT part */
if( p_vout && p_vout->b_die )
if( p_vout && !vlc_object_alive (p_vout) )
{
var_DelCallback( p_vout, "mouse-moved", EventMouse, p_ev );
var_DelCallback( p_vout, "mouse-clicked", EventMouse, p_ev );
......
......@@ -387,7 +387,7 @@ static int ReSynch( demux_t *p_demux )
int i_skip;
int i_peek;