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

Plugins: push cancellation down

parent 974a5e40
......@@ -363,6 +363,7 @@ static void* Raw1394EventThread( vlc_object_t *p_this )
access_t *p_access = (access_t *) p_ev->p_access;
access_sys_t *p_sys = (access_sys_t *) p_access->p_sys;
int result = 0;
int canc = vlc_savecancel ();
AVCPlay( p_access, p_sys->i_node );
......@@ -386,6 +387,7 @@ static void* Raw1394EventThread( vlc_object_t *p_this )
}
AVCStop( p_access, p_sys->i_node );
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -1263,6 +1263,8 @@ static void* EventThread( vlc_object_t *p_this )
p_ev->i_key_action = 0;
p_ev->b_still = false;
int canc = vlc_savecancel ();
/* catch all key event */
var_AddCallback( p_ev->p_libvlc, "key-action", EventKey, p_ev );
......@@ -1373,7 +1375,7 @@ static void* EventThread( vlc_object_t *p_this )
vlc_object_release( p_vout );
}
var_DelCallback( p_ev->p_libvlc, "key-action", EventKey, p_ev );
vlc_restorecancel (canc);
vlc_mutex_destroy( &p_ev->lock );
return NULL;
......
......@@ -1609,6 +1609,7 @@ static void* KeepAliveThread( vlc_object_t *p_this )
vlc_object_lock( p_thread );
while( vlc_object_alive( p_thread) )
{
int canc = vlc_savecancel ();
b_paused = p_thread->b_paused;
if( b_paused && b_was_paused )
......@@ -1616,6 +1617,7 @@ static void* KeepAliveThread( vlc_object_t *p_this )
b_was_paused = b_paused;
vlc_object_timedwait( p_thread, mdate() + 10000000 );
vlc_restorecancel (canc);
}
vlc_object_unlock( p_thread );
return NULL;
......
......@@ -507,6 +507,7 @@ static void* ThreadControl( vlc_object_t *p_this )
{
rtmp_control_thread_t *p_thread = (rtmp_control_thread_t *) p_this;
rtmp_packet_t *rtmp_packet;
int canc = vlc_savecancel ();
rtmp_init_handler( p_thread->rtmp_handler );
......@@ -543,5 +544,6 @@ static void* ThreadControl( vlc_object_t *p_this )
block_FifoWake( p_thread->p_fifo_input );
}
}
vlc_restorecancel (canc);
return NULL;
}
......@@ -279,6 +279,7 @@ static void* Thread( vlc_object_t* p_this )
access_t *p_src = p_access->p_source;
block_t *p_block;
int canc = vlc_savecancel ();
while( vlc_object_alive (p_access) )
{
/* Get a new block from the source */
......@@ -357,6 +358,7 @@ static void* Thread( vlc_object_t* p_this )
/* Send dummy packet to avoid deadlock in Block() */
block_FifoPut( p_sys->p_fifo, block_New( p_access, 0 ) );
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -186,11 +186,13 @@ static void* poll_iterate_thread( vlc_object_t *p_this )
{
poll_thread_t *p_pt = (poll_thread_t*)p_this;
vlc_thread_ready( p_pt );
int canc = vlc_savecancel ();
while( vlc_object_alive (p_pt) )
if( avahi_simple_poll_iterate( p_pt->simple_poll, 100 ) != 0 )
break;
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -383,6 +383,7 @@ static void* ThreadControl( vlc_object_t *p_this )
{
rtmp_control_thread_t *p_thread = (rtmp_control_thread_t *) p_this;
rtmp_packet_t *rtmp_packet;
int canc = vlc_savecancel ();
rtmp_init_handler( p_thread->rtmp_handler );
......@@ -416,5 +417,6 @@ static void* ThreadControl( vlc_object_t *p_this )
p_thread->b_die = 1;
}
}
vlc_restorecancel (canc);
return NULL;
}
......@@ -443,6 +443,7 @@ static void* ThreadWrite( vlc_object_t *p_this )
mtime_t i_date_last = -1;
mtime_t i_to_send = p_thread->i_group;
int i_dropped_packets = 0;
int canc = vlc_savecancel ();
while( vlc_object_alive (p_thread) )
{
......@@ -519,5 +520,6 @@ static void* ThreadWrite( vlc_object_t *p_this )
i_date_last = i_date;
}
vlc_restorecancel (canc);
return NULL;
}
......@@ -764,6 +764,7 @@ static void* ALSAThread( 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;
int canc = vlc_savecancel ();
p_sys->p_status = (snd_pcm_status_t *)malloc(snd_pcm_status_sizeof());
/* Wait for the exact time to start playing (avoids resampling) */
......@@ -785,6 +786,7 @@ static void* ALSAThread( vlc_object_t* p_this )
cleanup:
snd_pcm_drop( p_sys->p_snd_pcm );
free( p_aout->output.p_sys->p_status );
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -1054,6 +1054,7 @@ static void* DirectSoundThread( vlc_object_t *p_this )
mtime_t last_time;
HRESULT dsresult;
long l_queued = 0;
int canc = vlc_savecancel ();
/* We don't want any resampling when using S/PDIF output */
b_sleek = p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i');
......@@ -1148,6 +1149,7 @@ static void* DirectSoundThread( vlc_object_t *p_this )
/* free the event */
CloseHandle( p_notif->event );
vlc_restorecancel (canc);
msg_Dbg( p_notif, "DirectSoundThread exiting" );
return NULL;
}
......@@ -222,6 +222,7 @@ static void* Thread( vlc_object_t *p_this )
aout_buffer_t * p_buffer;
struct aout_sys_t * p_sys = p_aout->output.p_sys;
PCMAudioPlayer * pPlayer = p_sys->pPlayer;
int canc = vlc_savecancel ();
while( vlc_object_alive (p_aout) )
{
......@@ -254,6 +255,7 @@ static void* Thread( vlc_object_t *p_this )
#undef i
}
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -590,6 +590,7 @@ static void* OSSThread( 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;
mtime_t next_date = 0;
int canc = vlc_savecancel ();
while ( vlc_object_alive (p_aout) )
{
......@@ -690,5 +691,6 @@ static void* OSSThread( vlc_object_t *p_this )
}
}
vlc_restorecancel (canc);
return NULL;
}
......@@ -573,6 +573,7 @@ static void* PORTAUDIOThread( vlc_object_t *p_this )
aout_instance_t *p_aout;
aout_sys_t *p_sys;
int i_err;
int canc = vlc_savecancel ();
while( vlc_object_alive (pa_thread) )
{
......@@ -645,6 +646,7 @@ static void* PORTAUDIOThread( vlc_object_t *p_this )
vlc_cond_signal( &pa_thread->wait );
vlc_mutex_unlock( &pa_thread->lock_wait );
}
vlc_restorecancel (canc);
return NULL;
}
#endif
......@@ -982,6 +982,7 @@ static void* WaveOutThread( vlc_object_t *p_this )
bool b_sleek;
mtime_t next_date;
uint32_t i_buffer_length = 64;
int canc = vlc_savecancel ();
/* We don't want any resampling when using S/PDIF */
b_sleek = p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i');
......@@ -1108,6 +1109,7 @@ static void* WaveOutThread( vlc_object_t *p_this )
}
#undef waveout_warn
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -706,6 +706,7 @@ int OpenEncoder( vlc_object_t *p_this )
static void* FfmpegThread( vlc_object_t *p_this )
{
struct thread_context_t *p_context = (struct thread_context_t *)p_this;
int canc = vlc_savecancel ();
while ( vlc_object_alive (p_context) && !p_context->b_error )
{
vlc_mutex_lock( &p_context->lock );
......@@ -730,6 +731,7 @@ static void* FfmpegThread( vlc_object_t *p_this )
vlc_mutex_unlock( &p_context->lock );
}
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -1737,6 +1737,7 @@ static void* TimeoutPrevention( vlc_object_t * p_this )
vlc_thread_ready( p_timeout );
int canc = vlc_savecancel ();
/* Avoid lock */
while( vlc_object_alive (p_timeout) )
{
......@@ -1759,6 +1760,7 @@ static void* TimeoutPrevention( vlc_object_t * p_this )
p_timeout->i_remain -= 200000;
msleep( 200000 ); /* 200 ms */
}
vlc_restorecancel (canc);
}
/*****************************************************************************
......
......@@ -2770,6 +2770,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
event_thread_t *p_ev = (event_thread_t*)p_this;
demux_sys_t *p_sys = p_ev->p_demux->p_sys;
vlc_object_t *p_vout = NULL;
int canc = vlc_savecancel ();
p_ev->b_moved = false;
p_ev->b_clicked = false;
......@@ -3071,6 +3072,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
vlc_mutex_destroy( &p_ev->lock );
vlc_restorecancel (canc);
return VLC_SUCCESS;
}
......
......@@ -265,6 +265,7 @@ static void* QNXaoutThread( 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;
int canc = vlc_savecancel ();
while ( vlc_object_alive (p_aout) )
{
......@@ -321,6 +322,7 @@ static void* QNXaoutThread( vlc_object_t *p_this )
}
}
vlc_restorecancel (canc);
return NULL;
}
......@@ -311,6 +311,7 @@ static void *Init( vlc_object_t *obj )
char dummy[] = "";
char *argv[] = { dummy };
int argc = 1;
int canc = vlc_savecancel ();
Q_INIT_RESOURCE( vlc );
......@@ -464,6 +465,8 @@ static void *Init( vlc_object_t *obj )
/* Save the path */
config_PutPsz( p_intf, "qt-filedialog-path", p_intf->p_sys->psz_filepath );
free( psz_path );
vlc_restorecancel (canc);
return NULL;
}
/*****************************************************************************
......
......@@ -213,6 +213,7 @@ static void* MainLoop( vlc_object_t * p_this )
intf_thread_t *p_intf = (intf_thread_t*)p_this;
MSG msg;
Interface *intf = 0;
int canc = vlc_savecancel ();
if( !hInstance ) hInstance = GetModuleHandle(NULL);
......@@ -268,6 +269,7 @@ static void* MainLoop( vlc_object_t * p_this )
/* Uninitialize OLE/COM */
CoUninitialize();
#endif
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -299,6 +299,7 @@ static void* Init( vlc_object_t * p_this )
static char *p_args[] = { "" };
int i_args = 1;
#endif
int canc = vlc_savecancel ();
/* Hack to pass the p_intf pointer to the new wxWidgets Instance object */
#ifdef wxTheApp
......@@ -321,6 +322,7 @@ static void* Init( vlc_object_t * p_this )
#else
wxEntry( i_args, p_args );
#endif
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -525,6 +525,7 @@ static void* FontBuilderThread( vlc_object_t *p_this )
if( p_fontconfig )
{
mtime_t t1, t2;
int canc = vlc_savecancel ();
//msg_Dbg( p_this, "Building font database..." );
msg_Dbg( p_this, "Building font database..." );
......@@ -548,6 +549,7 @@ static void* FontBuilderThread( vlc_object_t *p_this )
vlc_mutex_unlock( p_lock );
var_SetBool( p_this, "build-done", true );
vlc_restorecancel (canc);
}
return NULL;
}
......
......@@ -167,6 +167,7 @@ static void* GtkMain( vlc_object_t *p_this )
static char **pp_args = p_args;
#endif
static int i_args = 1;
int canc = vlc_savecancel ();
/* FIXME: deprecated ? */
#if defined(MODULE_NAME_IS_gtk2_main) || defined(MODULE_NAME_IS_gnome2_main)
......@@ -197,5 +198,6 @@ static void* GtkMain( vlc_object_t *p_this )
gtk_main();
gdk_threads_leave();
vlc_restorecancel (canc);
return NULL;
}
......@@ -162,6 +162,7 @@ static void* QteMain( vlc_object_t* p_vlc_obj )
{
qte_thread_t *p_this = (qte_thread_t*)p_vlc_obj;
int i_argc = 1;
int canc = vlc_savecancel ();
p_this->b_gui_server = false;
if( config_GetInt( p_this, "qte-guiserver" ) )
......@@ -191,5 +192,6 @@ static void* QteMain( vlc_object_t* p_vlc_obj )
vlc_thread_ready( p_this );
p_this->p_qte_application->exec();
vlc_restorecancel (canc);
return NULL;
}
......@@ -816,6 +816,7 @@ static void* CommandThread( vlc_object_t *p_this )
{
vod_t *p_vod = (vod_t*)p_this;
vod_sys_t *p_sys = p_vod->p_sys;
int canc = vlc_savecancel ();
while( vlc_object_alive (p_vod) )
{
......@@ -883,6 +884,8 @@ static void* CommandThread( vlc_object_t *p_this )
free( cmd.psz_session );
free( cmd.psz_arg );
}
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -242,10 +242,13 @@ static void * MyThread( vlc_object_t *p_this )
while( vlc_object_alive (p_this) )
{
int i = (int) (100.0 * rand() / (RAND_MAX));
/* FIXME: not thread-safe */
sprintf( psz_var, "blork-%i", i );
val.i_int = i + 200;
int canc = vlc_savecancel ();
var_Set( p_parent, psz_var, val );
vlc_restorecancel (canc);
/* This is quite heavy, but we only have 10 threads. Keep cool. */
msleep( 1000 );
......
......@@ -1434,6 +1434,7 @@ static void* ThreadSend( vlc_object_t *p_this )
{
sout_stream_id_t *id = (sout_stream_id_t *)p_this;
unsigned i_caching = id->i_caching;
int canc = vlc_savecancel ();
while( vlc_object_alive (id) )
{
......@@ -1499,6 +1500,7 @@ static void* ThreadSend( vlc_object_t *p_this )
rtp_add_sink( id, fd, true );
}
}
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -2102,6 +2102,7 @@ static void* EncoderThread( vlc_object_t* p_this )
sout_stream_sys_t *p_sys = (sout_stream_sys_t*)p_this;
sout_stream_id_t *id = p_sys->id_video;
picture_t *p_pic;
int canc = vlc_savecancel ();
while( vlc_object_alive (p_sys) && !p_sys->b_error )
{
......@@ -2142,6 +2143,7 @@ static void* EncoderThread( vlc_object_t* p_this )
}
block_ChainRelease( p_sys->p_buffers );
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -72,11 +72,14 @@ void *CThread::ThreadProc(vlc_object_t *obj)
atmo_thread_t *pAtmoThread = (atmo_thread_t *)obj;
CThread *pThread = (CThread *)pAtmoThread->p_thread;
if(pThread) {
int canc;
// give feedback I'am running?
vlc_thread_ready( pThread->m_pAtmoThread );
pThread->Execute();
canc = vlc_savecancel ();
pThread->Execute();
vlc_restorecancel (canc);
}
return NULL;
}
......
......@@ -1741,6 +1741,7 @@ static void *FadeToColorThread(vlc_object_t *obj)
uint8_t *p_source = NULL;
int canc = vlc_savecancel ();
/* initialize AtmoWin for this thread! */
AtmoInitialize(p_fadethread->p_filter , true);
......@@ -1825,6 +1826,7 @@ static void *FadeToColorThread(vlc_object_t *obj)
}
/* call indirect to OleUnitialize() for this thread */
AtmoFinalize(p_fadethread->p_filter, 0);
vlc_restorecancel (canc);
}
/*****************************************************************************
......
......@@ -677,6 +677,7 @@ static void* vnc_worker_thread( vlc_object_t *p_thread_obj )
filter_t* p_filter = (filter_t*)(p_thread_obj->p_parent);
filter_sys_t *p_sys = p_filter->p_sys;
vlc_object_t *p_update_request_thread;
int canc = vlc_savecancel ();
msg_Dbg( p_filter, "VNC worker thread started" );
......@@ -799,6 +800,7 @@ exit:
vlc_mutex_unlock( &p_sys->lock );
msg_Dbg( p_filter, "VNC message reader thread ended" );
vlc_restorecancel (canc);
return NULL;
}
......@@ -806,6 +808,7 @@ static void* update_request_thread( vlc_object_t *p_thread_obj )
{
filter_t* p_filter = (filter_t*)(p_thread_obj->p_parent);
filter_sys_t *p_sys = p_filter->p_sys;
int canc = vlc_savecancel ();
msg_Dbg( p_filter, "VNC update request thread started" );
......@@ -848,6 +851,7 @@ static void* update_request_thread( vlc_object_t *p_thread_obj )
}
msg_Dbg( p_filter, "VNC update request thread ended" );
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -100,6 +100,7 @@ void* EventThread( vlc_object_t *p_this )
vlc_value_t val;
unsigned int i_width, i_height, i_x, i_y;
HMODULE hkernel32;
int canc = vlc_savecancel ();
/* Initialisation */
p_event->p_vout->pf_control = Control;
......@@ -376,6 +377,7 @@ void* EventThread( vlc_object_t *p_this )
p_event->p_vout->p_sys->i_changes = 0;
DirectXCloseWindow( p_event->p_vout );
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -591,6 +591,7 @@ static void CloseDisplay( vout_thread_t *p_vout )
static void* RunQtThread( vlc_object_t *p_this )
{
event_thread_t *p_event = (event_thread_t *)p_this;
int canc = vlc_savecancel ();
msg_Dbg( p_event->p_vout, "RunQtThread starting" );
#ifdef NEED_QTE_MAIN
......@@ -669,6 +670,7 @@ static void* RunQtThread( vlc_object_t *p_this )
#endif
msg_Dbg( p_event->p_vout, "RunQtThread terminating" );
vlc_restorecancel (canc);
return NULL;
}
......@@ -197,12 +197,16 @@ static void* Thread( vlc_object_t *p_this )
int timed=0;
int timestart=0;
int mspf=0;
int canc = vlc_savecancel ();
/* Get on OpenGL provider */
p_thread->p_opengl =
(vout_thread_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL );
if( p_thread->p_opengl == NULL )
{
vlc_restorecancel (canc);
return NULL;
}
vlc_object_attach( p_thread->p_opengl, p_this );
/* Initialize vout parameters */
......@@ -228,6 +232,7 @@ static void* Thread( vlc_object_t *p_this )
msg_Err( p_thread, "unable to initialize OpenGL" );
vlc_object_detach( p_thread->p_opengl );
vlc_object_release( p_thread->p_opengl );
vlc_restorecancel (canc);
return NULL;
}
......@@ -267,6 +272,7 @@ static void* Thread( vlc_object_t *p_this )
module_Unneed( p_thread->p_opengl, p_thread->p_module );
vlc_object_detach( p_thread->p_opengl );
vlc_object_release( p_thread->p_opengl );
vlc_restorecancel (canc);
return NULL;
}
......
......@@ -325,6 +325,7 @@ static void* Thread( vlc_object_t *p_this )
int16_t p_data[2][512];
int i_data = 0, i_count = 0;
PluginInfo *p_plugin_info;
int canc = vlc_savecancel ();
var_Get( p_this, "goom-width", &width );
var_Get( p_this, "goom-height", &height );
......@@ -375,6 +376,7 @@ static void* Thread( vlc_object_t *p_this )
}
goom_close( p_plugin_info );
vlc_restorecancel (canc);
return 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