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

Use vlc_object_kill(). Needs triple checking.

This also seems to make the pre-existing Qt4 crash more obvious.
parent bc387d3d
......@@ -119,6 +119,9 @@ VLC_EXPORT( libvlc_int_t *, vlc_current_object, ( int ) );
__vlc_object_destroy( VLC_OBJECT(a) ); \
(a) = NULL; } while(0)
#define vlc_object_kill(a) \
__vlc_object_kill( VLC_OBJECT(a) )
#define vlc_object_detach(a) \
__vlc_object_detach( VLC_OBJECT(a) )
......
......@@ -252,7 +252,7 @@ static void Close( vlc_object_t *p_this )
if( p_sys->p_ev )
{
/* stop the event handler */
p_sys->p_ev->b_die = VLC_TRUE;
vlc_object_kill( p_sys->p_ev );
if( p_sys->p_raw1394 )
raw1394_stop_iso_rcv( p_sys->p_raw1394, p_sys->i_channel );
......
......@@ -352,7 +352,7 @@ static void Close( vlc_object_t *p_this )
int i;
/* stop the event handler */
p_sys->p_ev->b_die = VLC_TRUE;
vlc_object_kill( p_sys->p_ev );
vlc_thread_join( p_sys->p_ev );
vlc_object_destroy( p_sys->p_ev );
......
......@@ -179,7 +179,7 @@ static void Close( vlc_object_t *p_this )
msg_Dbg( p_access, "plugin notified" );
/* stop receiver thread */
p_sys->p_thread->b_die = VLC_TRUE;
vlc_object_kill( p_sys->p_thread );
vlc_mutex_lock( &p_sys->p_thread->lock );
vlc_cond_signal( &p_sys->p_thread->wait );
vlc_mutex_unlock( &p_sys->p_thread->lock );
......
......@@ -291,7 +291,7 @@ void bonjour_stop_service( void *_p_sys )
if( p_sys->poll_thread->b_thread )
{
p_sys->poll_thread->b_die = 1;
vlc_object_kill( p_sys->poll_thread );
vlc_thread_join( p_sys->poll_thread );
}
......
......@@ -419,7 +419,7 @@ static void Close( vlc_object_t * p_this )
sout_access_out_sys_t *p_sys = p_access->p_sys;
int i;
p_sys->p_thread->b_die = 1;
vlc_object_kill( p_sys->p_thread );
for( i = 0; i < 10; i++ )
{
block_t *p_dummy = block_New( p_access, p_sys->i_mtu );
......
......@@ -725,7 +725,7 @@ static void Close( vlc_object_t *p_this )
vlc_cond_signal( &p_aout->output.p_sys->wait );
vlc_mutex_unlock( &p_aout->output.p_sys->lock );
p_aout->b_die = VLC_TRUE;
vlc_object_kill( p_aout );
vlc_thread_join( p_aout );
p_aout->b_die = VLC_FALSE;
......
......@@ -589,7 +589,7 @@ static void CloseAudio( vlc_object_t *p_this )
vlc_object_detach( p_sys->p_notif );
if( p_sys->p_notif->b_thread )
{
p_sys->p_notif->b_die = 1;
vlc_object_kill( p_sys->p_notif );
/* wake up the audio thread if needed */
if( !p_sys->b_playing ) SetEvent( p_sys->p_notif->event );
......
......@@ -192,7 +192,7 @@ static void Close( vlc_object_t * p_this )
aout_instance_t * p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys = p_aout->output.p_sys;
p_aout->b_die = VLC_TRUE;
vlc_object_kill( p_aout );
vlc_thread_join( p_aout );
p_aout->b_die = VLC_FALSE;
......
......@@ -541,7 +541,7 @@ static void Close( vlc_object_t * p_this )
aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys = p_aout->output.p_sys;
p_aout->b_die = VLC_TRUE;
vlc_object_kill( p_aout );
vlc_thread_join( p_aout );
p_aout->b_die = VLC_FALSE;
......
......@@ -486,7 +486,7 @@ static void Close( vlc_object_t *p_this )
aout_sys_t *p_sys = p_aout->output.p_sys;
/* Before calling waveOutClose we must reset the device */
p_aout->b_die = VLC_TRUE;
vlc_object_kill( p_aout );
waveOutReset( p_sys->h_waveout );
......
......@@ -1014,7 +1014,7 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
(struct thread_context_t **)p_sys->p_context->thread_opaque;
for ( i = 0; i < p_enc->i_threads; i++ )
{
pp_contexts[i]->b_die = 1;
vlc_object_kill( pp_contexts[i] );
vlc_cond_signal( &pp_contexts[i]->cond );
vlc_thread_join( pp_contexts[i] );
vlc_mutex_destroy( &pp_contexts[i]->lock );
......
......@@ -157,7 +157,7 @@ DBUS_METHOD( Quit )
playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this );
playlist_Stop( p_playlist );
pl_Release( ((vlc_object_t*) p_this) );
((vlc_object_t*)p_this)->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill(((vlc_object_t*)p_this)->p_libvlc);
REPLY_SEND;
}
......
......@@ -422,7 +422,7 @@ static void RunIntf( intf_thread_t *p_intf )
break;
case GESTURE(DOWN,LEFT,NONE,NONE):
/* FIXME: Should close the vout!"*/
p_intf->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_intf->p_libvlc );
break;
case GESTURE(DOWN,LEFT,UP,RIGHT):
case GESTURE(UP,RIGHT,DOWN,LEFT):
......
......@@ -236,7 +236,7 @@ static void Run( intf_thread_t *p_intf )
if( i_action == ACTIONID_QUIT )
{
p_intf->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_intf->p_libvlc );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
if( p_vout )
......
......@@ -518,7 +518,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
case MVLC_SHUTDOWN:
{
msg_Dbg( p_intf, "requested shutdown" );
p_intf->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_intf->p_libvlc );
break;
}
/* vlm */
......
......@@ -164,7 +164,7 @@ static void Run( intf_thread_t *p_intf )
}
/* Make sure we exit (In case other interfaces have been spawned) */
p_intf->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_intf->p_libvlc );
}
/*****************************************************************************
......
......@@ -457,7 +457,7 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->hConsoleIn == INVALID_HANDLE_VALUE )
{
msg_Err( p_intf, "couldn't find user input handle" );
p_intf->b_die = VLC_TRUE;
vlc_object_kill( p_intf );
}
#endif
......@@ -1447,7 +1447,7 @@ static int Quit( vlc_object_t *p_this, char const *psz_cmd,
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
}
p_this->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_this->p_libvlc );
return VLC_SUCCESS;
}
......@@ -1962,7 +1962,7 @@ vlc_bool_t ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
}
else
/* Standard input closed: exit */
p_intf->b_die = VLC_TRUE;
vlc_object_kill( p_intf );
p_buffer[ *pi_size ] = 0;
return VLC_TRUE;
......
......@@ -432,7 +432,7 @@ static void Run( intf_thread_t *p_intf )
else if( !strncmp( cl->buffer_read, "shutdown", 8 ) )
{
msg_Err( p_intf, "shutdown requested" );
p_intf->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_intf->p_libvlc );
}
else if( *cl->buffer_read == '@'
&& strchr( cl->buffer_read, ' ' ) )
......
......@@ -594,7 +594,7 @@ aviindex:
else if( i_create == DIALOG_CANCELLED )
{
/* Kill input */
p_demux->p_parent->b_die = VLC_TRUE;
vlc_object_kill( p_demux->p_parent );
goto error;
}
}
......
......@@ -370,7 +370,7 @@ error:
if( p_sys->env ) p_sys->env->reclaim();
if( p_sys->p_timeout )
{
p_sys->p_timeout->b_die = VLC_TRUE;
vlc_object_kill( p_sys->p_timeout );
vlc_thread_join( p_sys->p_timeout );
vlc_object_detach( p_sys->p_timeout );
vlc_object_destroy( p_sys->p_timeout );
......@@ -409,7 +409,7 @@ static void Close( vlc_object_t *p_this )
if( p_sys->env ) p_sys->env->reclaim();
if( p_sys->p_timeout )
{
p_sys->p_timeout->b_die = VLC_TRUE;
vlc_object_kill( p_sys->p_timeout );
vlc_thread_join( p_sys->p_timeout );
vlc_object_detach( p_sys->p_timeout );
vlc_object_destroy( p_sys->p_timeout );
......
......@@ -2610,8 +2610,7 @@ void demux_sys_t::StopUiThread()
{
if ( b_ui_hooked )
{
p_ev->b_die = VLC_TRUE;
vlc_object_kill( p_ev );
vlc_thread_join( p_ev );
vlc_object_destroy( p_ev );
......
......@@ -804,7 +804,7 @@ bool InterfaceWindow::QuitRequested()
_StoreSettings();
p_intf->b_die = 1;
vlc_object_kill( p_intf );
return( true );
}
......
......@@ -1717,7 +1717,7 @@ static VLCMain *_o_sharedMainInstance = nil;
/* write cached user defaults to disk */
[[NSUserDefaults standardUserDefaults] synchronize];
p_intf->b_die = VLC_TRUE;
vlc_object_kill( p_intf );
/* Go back to Run() and make libvlc exit properly */
longjmp( jmpbuffer, 1 );
......
......@@ -839,7 +839,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
case 'q':
case 'Q':
case 0x1b: /* Esc */
p_intf->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_intf->p_libvlc );
return 0;
/* Box switching */
......
......@@ -343,7 +343,7 @@ gboolean onPDADeleteEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data
intf_thread_t *p_intf = GtkGetIntf( widget );
vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_intf->p_libvlc );
vlc_mutex_unlock( &p_intf->change_lock );
msg_Dbg( p_intf, "about to exit vlc ... signaled" );
......
......@@ -242,7 +242,7 @@ void E_(CloseAudio) ( vlc_object_t *p_this )
aout_instance_t *p_aout = (aout_instance_t *)p_this;
int i_ret;
p_aout->b_die = 1;
vlc_object_kill( p_aout );
vlc_thread_join( p_aout );
if( ( i_ret = snd_pcm_close( p_aout->output.p_sys->p_pcm_handle ) ) < 0 )
......
......@@ -299,7 +299,7 @@ static int QNXManage( vout_thread_t *p_vout )
PhEvent_t *p_event;
vlc_bool_t b_repos = 0;
if (p_vout->b_die == 1)
if (p_vout->b_die)
{
return ( 0 );
}
......@@ -338,7 +338,7 @@ static int QNXManage( vout_thread_t *p_vout )
switch( p_ev->event_f )
{
case Ph_WM_CLOSE:
p_vout->p_libvlc->b_die = 1;
p_vout->p_libvlc->b_die = VLC_TRUE;
break;
case Ph_WM_MOVE:
......@@ -368,7 +368,7 @@ static int QNXManage( vout_thread_t *p_vout )
{
case Pk_q:
case Pk_Q:
p_vout->p_libvlc->b_die = 1;
p_vout->p_libvlc->b_die = VLC_TRUE;
break;
case Pk_f:
......
......@@ -71,7 +71,7 @@ DialogsProvider::~DialogsProvider()
void DialogsProvider::quit()
{
p_intf->b_die = VLC_TRUE;
vlc_object_kill( p_intf );
QApplication::quit();
}
......
......@@ -857,7 +857,7 @@ void MainInterface::updateOnTimer()
void MainInterface::closeEvent( QCloseEvent *e )
{
hide();
p_intf->b_die = VLC_TRUE;
vlc_object_kill( p_intf );
}
void MainInterface::updateVolume( int sliderVolume )
......
......@@ -213,7 +213,8 @@ static int Demux( demux_t *p_demux )
switch( p_sys->i_command )
{
case COMMAND_QUIT:
b_eof = p_demux->p_libvlc->b_die = VLC_TRUE;
b_eof = VLC_TRUE;
vlc_object_kill( p_demux->p_libvlc );
break;
case COMMAND_PAUSE:
......
......@@ -324,7 +324,7 @@ static void Close( vlc_object_t * p_this )
vod_sys_t *p_sys = p_vod->p_sys;
/* Stop command thread */
p_vod->b_die = VLC_TRUE;
vlc_object_kill( p_vod );
CommandPush( p_vod, RTSP_CMD_TYPE_NONE, NULL, NULL, 0.0, NULL );
vlc_thread_join( p_vod );
......
......@@ -175,7 +175,7 @@ static int Callback( vlc_object_t *p_this, char const *psz_cmd,
for( i = 0; i < 10; i++ )
{
pp_objects[i]->b_die = VLC_TRUE;
vlc_object_kill( pp_objects[i] );
vlc_thread_join( pp_objects[i] );
vlc_object_detach( pp_objects[i] );
vlc_object_destroy( pp_objects[i] );
......
......@@ -359,7 +359,7 @@ static int Manage( vout_thread_t *p_vout )
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
}
p_vout->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_vout->p_libvlc );
break;
}
#endif
......
......@@ -381,7 +381,7 @@ static int Manage( vout_thread_t *p_vout )
switch( buf )
{
case 'q':
p_vout->p_libvlc->b_die = 1;
vlc_object_kill( p_vout->p_libvlc );
break;
default:
......
......@@ -293,7 +293,7 @@ static int Manage( vout_thread_t *p_vout )
case 'q':
case 'Q':
case GIIUC_Escape:
p_vout->p_libvlc->b_die = 1;
vlc_object_kill( p_vout->p_libvlc );
break;
default:
......
......@@ -207,7 +207,7 @@ static int Manage( vout_thread_t *p_vout )
switch( (char)buf )
{
case 'q':
p_vout->p_libvlc->b_die = 1;
vlc_object_kill( p_vout->p_libvlc );
break;
default:
......
......@@ -270,7 +270,7 @@ static void CloseVideo( vlc_object_t *p_this )
vlc_object_detach( p_vout->p_sys->p_event );
/* Kill Vout EventThread */
p_vout->p_sys->p_event->b_die = VLC_TRUE;
vlc_object_kill( p_vout->p_sys->p_event );
/* we need to be sure Vout EventThread won't stay stuck in
* GetMessage, so we send a fake message */
......
......@@ -493,7 +493,7 @@ static void CloseVideo( vlc_object_t *p_this )
vlc_object_detach( p_vout->p_sys->p_event );
/* Kill Vout EventThread */
p_vout->p_sys->p_event->b_die = VLC_TRUE;
vlc_object_kill( p_vout->p_sys->p_event );
/* we need to be sure Vout EventThread won't stay stuck in
* GetMessage, so we send a fake message */
......
......@@ -225,7 +225,7 @@ static void CloseVideo( vlc_object_t *p_this )
vlc_object_detach( p_vout->p_sys->p_event );
/* Kill Vout EventThread */
p_vout->p_sys->p_event->b_die = VLC_TRUE;
vlc_object_kill( p_vout->p_sys->p_event );
/* we need to be sure Vout EventThread won't stay stuck in
* GetMessage, so we send a fake message */
......
......@@ -313,7 +313,7 @@ static void CloseVideo ( vlc_object_t *p_this )
vlc_object_detach( p_vout->p_sys->p_event );
/* Kill Vout EventThread */
p_vout->p_sys->p_event->b_die = VLC_TRUE;
vlc_object_kill( p_vout->p_sys->p_event );
/* we need to be sure Vout EventThread won't stay stuck in
* GetMessage, so we send a fake message */
......
......@@ -185,7 +185,7 @@ static void Close ( vlc_object_t *p_this )
vlc_object_detach( p_vout->p_sys->p_event );
/* Kill RunQtThread */
p_vout->p_sys->p_event->b_die = VLC_TRUE;
vlc_object_kill( p_vout->p_sys->p_event );
CloseDisplay(p_vout);
vlc_thread_join( p_vout->p_sys->p_event );
......
......@@ -423,7 +423,7 @@ static int Manage( vout_thread_t *p_vout )
break;
case SDL_QUIT:
p_vout->p_libvlc->b_die = 1;
vlc_object_kill( p_vout->p_libvlc );
break;
case SDL_KEYDOWN: /* if a key is pressed */
......@@ -437,12 +437,12 @@ static int Manage( vout_thread_t *p_vout )
}
else
{
p_vout->p_libvlc->b_die = 1;
vlc_object_kill( p_vout->p_libvlc );
}
break;
case SDLK_q: /* quit */
p_vout->p_libvlc->b_die = 1;
vlc_object_kill( p_vout->p_libvlc );
break;
case SDLK_f: /* switch to fullscreen */
......
......@@ -231,7 +231,7 @@ static int Manage( vout_thread_t *p_vout )
if( keyboard_keypressed(SCANCODE_ESCAPE)
|| keyboard_keypressed(SCANCODE_Q ) )
{
p_vout->p_libvlc->b_die = VLC_TRUE;
vlc_object_kill( p_vout->p_libvlc );
}
return VLC_SUCCESS;
......
......@@ -245,7 +245,7 @@ static void Thread( vlc_object_t *p_this )
mspf = 1000 / 60;
if( galaktos_update( p_thread ) == 1 )
{
p_thread->b_die = 1;
vlc_object_kill( p_thread );
}
if( p_thread->psz_title )
{
......@@ -282,7 +282,7 @@ static void Close( vlc_object_t *p_this )
aout_filter_sys_t *p_sys = p_filter->p_sys;
/* Stop galaktos Thread */
p_sys->p_thread->b_die = VLC_TRUE;
vlc_object_kill( p_sys->p_thread );
galaktos_done( p_sys->p_thread );
......
......@@ -384,7 +384,7 @@ static void Close( vlc_object_t *p_this )
aout_filter_sys_t *p_sys = p_filter->p_sys;
/* Stop Goom Thread */
p_sys->p_thread->b_die = VLC_TRUE;
vlc_object_kill( p_sys->p_thread );
vlc_mutex_lock( &p_sys->p_thread->lock );
vlc_cond_signal( &p_sys->p_thread->wait );
......
......@@ -191,7 +191,7 @@ decoder_t *input_DecoderNew( input_thread_t *p_input,
*/
void input_DecoderDelete( decoder_t *p_dec )
{
p_dec->b_die = VLC_TRUE;
vlc_object_kill( p_dec );
if( p_dec->p_owner->b_own_thread )
{
......
......@@ -359,8 +359,9 @@ void stream_DemuxDelete( stream_t *s )
d_stream_sys_t *p_sys = (d_stream_sys_t*)s->p_sys;
block_t *p_empty;
s->b_die = VLC_TRUE;
if( p_sys->p_demux ) p_sys->p_demux->b_die = VLC_TRUE;
vlc_object_kill( s );
if( p_sys->p_demux )
vlc_object_kill( p_sys->p_demux );
p_empty = block_New( s, 1 ); p_empty->i_buffer = 0;
block_FifoPut( p_sys->p_fifo, p_empty );
vlc_thread_join( s );
......@@ -534,7 +535,7 @@ static int DStreamThread( stream_t *s )
if( p_demux->pf_demux( p_demux ) <= 0 ) break;
}
p_demux->b_die = VLC_TRUE;
vlc_object_kill( p_demux );
return VLC_SUCCESS;
}
......
......@@ -417,7 +417,8 @@ void input_StopThread( input_thread_t *p_input )
int i;
/* Set die for input */
p_input->b_die = VLC_TRUE;
vlc_object_kill( p_input );
/* FIXME: seems to be duplicated in ControlPush(INPUT_CONTROL_SET_DIE) */
/* We cannot touch p_input fields directly (we come from another thread),
* so use the vlc_object_find way, it's perfectly safe */
......@@ -426,7 +427,7 @@ void input_StopThread( input_thread_t *p_input )
p_list = vlc_list_find( p_input, VLC_OBJECT_ACCESS, FIND_CHILD );
for( i = 0; i < p_list->i_count; i++ )
{
p_list->p_values[i].p_object->b_die = VLC_TRUE;
vlc_object_kill( p_list->p_values[i].p_object );
}
vlc_list_release( p_list );
......@@ -434,7 +435,7 @@ void input_StopThread( input_thread_t *p_input )
p_list = vlc_list_find( p_input, VLC_OBJECT_STREAM, FIND_CHILD );
for( i = 0; i < p_list->i_count; i++ )
{
p_list->p_values[i].p_object->b_die = VLC_TRUE;
vlc_object_kill( p_list->p_values[i].p_object );
}
vlc_list_release( p_list );
......@@ -442,7 +443,7 @@ void input_StopThread( input_thread_t *p_input )
p_list = vlc_list_find( p_input, VLC_OBJECT_DEMUX, FIND_CHILD );
for( i = 0; i < p_list->i_count; i++ )
{
p_list->p_values[i].p_object->b_die = VLC_TRUE;
vlc_object_kill( p_list->p_values[i].p_object );
}
vlc_list_release( p_list );
......@@ -1452,12 +1453,12 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
msg_Dbg( p_input, "control: stopping input" );
/* Mark all submodules to die */
if( p_input->p->input.p_access )
p_input->p->input.p_access->b_die = VLC_TRUE;
vlc_object_kill( p_input->p->input.p_access );
if( p_input->p->input.p_stream )
p_input->p->input.p_stream->b_die = VLC_TRUE;
p_input->p->input.p_demux->b_die = VLC_TRUE;
vlc_object_kill( p_input->p->input.p_stream );
vlc_object_kill( p_input->p->input.p_demux );
p_input->b_die = VLC_TRUE;
vlc_object_kill( p_input );
break;
case INPUT_CONTROL_SET_POSITION:
......
......@@ -174,7 +174,7 @@ void vlm_Delete( vlm_t *p_vlm )
return;
}
p_vlm->b_die = VLC_TRUE;
vlc_object_kill( p_vlm );
vlc_thread_join( p_vlm );
vlc_object_detach( p_vlm );
......
......@@ -171,7 +171,7 @@ int intf_RunThread( intf_thread_t *p_intf )
while( !intf_ShouldDie( p_intf ) )
msleep( INTF_IDLE_SLEEP * 2);
}
p_intf->b_die = VLC_TRUE;