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

Pull cancellation into (most) remaining interfaces

parent 67c077de
...@@ -105,6 +105,7 @@ RunIntf( intf_thread_t *p_intf ) ...@@ -105,6 +105,7 @@ RunIntf( intf_thread_t *p_intf )
the 10_ADD keypresses */ the 10_ADD keypresses */
int number_addend = 0; int number_addend = 0;
int canc = vlc_savecancel();
if( InitThread( p_intf ) < 0 ) if( InitThread( p_intf ) < 0 )
{ {
msg_Err( p_intf, "can't initialize intf" ); msg_Err( p_intf, "can't initialize intf" );
...@@ -121,6 +122,7 @@ RunIntf( intf_thread_t *p_intf ) ...@@ -121,6 +122,7 @@ RunIntf( intf_thread_t *p_intf )
p_vcdplayer = p_intf->p_sys->p_vcdplayer; p_vcdplayer = p_intf->p_sys->p_vcdplayer;
p_access = p_vcdplayer->p_access; p_access = p_vcdplayer->p_access;
int canc = vlc_savecancel();
dbg_print( INPUT_DBG_CALL, "intf initialized" ); dbg_print( INPUT_DBG_CALL, "intf initialized" );
/* Main loop */ /* Main loop */
...@@ -309,6 +311,7 @@ RunIntf( intf_thread_t *p_intf ) ...@@ -309,6 +311,7 @@ RunIntf( intf_thread_t *p_intf )
} }
vlc_object_release( p_intf->p_sys->p_input ); vlc_object_release( p_intf->p_sys->p_input );
vlc_restorecancel( canc );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -177,6 +177,7 @@ void CloseIntf ( vlc_object_t *p_this ) ...@@ -177,6 +177,7 @@ void CloseIntf ( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void RunIntf( intf_thread_t *p_intf ) static void RunIntf( intf_thread_t *p_intf )
{ {
int canc = vlc_savecancel();
vout_thread_t * p_vout = NULL; vout_thread_t * p_vout = NULL;
if( InitThread( p_intf ) < 0 ) if( InitThread( p_intf ) < 0 )
...@@ -250,6 +251,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -250,6 +251,7 @@ static void RunIntf( intf_thread_t *p_intf )
} }
vlc_object_release( p_intf->p_sys->p_input ); vlc_object_release( p_intf->p_sys->p_input );
vlc_restorecancel( canc );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -826,10 +826,12 @@ static void Close ( vlc_object_t *p_this ) ...@@ -826,10 +826,12 @@ static void Close ( vlc_object_t *p_this )
static void Run ( intf_thread_t *p_intf ) static void Run ( intf_thread_t *p_intf )
{ {
while( !intf_ShouldDie( p_intf ) ) for( ;; )
{ {
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
int canc = vlc_savecancel();
dbus_connection_read_write_dispatch( p_intf->p_sys->p_conn, 0 ); dbus_connection_read_write_dispatch( p_intf->p_sys->p_conn, 0 );
vlc_restorecancel( canc );
} }
} }
......
...@@ -168,6 +168,7 @@ void Close ( vlc_object_t *p_this ) ...@@ -168,6 +168,7 @@ void Close ( vlc_object_t *p_this )
static void RunIntf( intf_thread_t *p_intf ) static void RunIntf( intf_thread_t *p_intf )
{ {
playlist_t * p_playlist = NULL; playlist_t * p_playlist = NULL;
int canc = vlc_savecancel();
vlc_mutex_lock( &p_intf->change_lock ); vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_sys->p_vout = NULL; p_intf->p_sys->p_vout = NULL;
...@@ -450,6 +451,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -450,6 +451,7 @@ static void RunIntf( intf_thread_t *p_intf )
} }
EndThread( p_intf ); EndThread( p_intf );
vlc_restorecancel( canc );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -139,6 +139,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -139,6 +139,7 @@ static void Run( intf_thread_t *p_intf )
vlc_value_t val; vlc_value_t val;
int i; int i;
playlist_t *p_playlist = pl_Yield( p_intf ); playlist_t *p_playlist = pl_Yield( p_intf );
int canc = vlc_savecancel();
/* Initialize hotkey structure */ /* Initialize hotkey structure */
for( struct hotkey *p_hotkey = p_intf->p_libvlc->p_hotkeys; for( struct hotkey *p_hotkey = p_intf->p_libvlc->p_hotkeys;
...@@ -830,6 +831,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -830,6 +831,7 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
pl_Release( p_intf ); pl_Release( p_intf );
vlc_restorecancel( canc );
} }
static int GetAction( intf_thread_t *p_intf ) static int GetAction( intf_thread_t *p_intf )
......
...@@ -138,11 +138,14 @@ static void Close( vlc_object_t *p_this ) ...@@ -138,11 +138,14 @@ static void Close( vlc_object_t *p_this )
static void Run( intf_thread_t *p_intf ) static void Run( intf_thread_t *p_intf )
{ {
char *code, *c; char *code, *c;
int canc = vlc_savecancel();
while( !intf_ShouldDie( p_intf ) ) for( ;; )
{ {
/* Sleep a bit */ /* Sleep a bit */
vlc_restorecancel(canc);
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
canc = vlc_savecancel();
/* We poll the lircsocket */ /* We poll the lircsocket */
if( lirc_nextcode(&code) != 0 ) if( lirc_nextcode(&code) != 0 )
...@@ -199,4 +202,5 @@ static void Run( intf_thread_t *p_intf ) ...@@ -199,4 +202,5 @@ static void Run( intf_thread_t *p_intf )
} }
free( code ); free( code );
} }
vlc_restorecancel(canc);
} }
...@@ -182,7 +182,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -182,7 +182,7 @@ static void RunIntf( intf_thread_t *p_intf )
int p_oldx[FILTER_LENGTH]; int p_oldx[FILTER_LENGTH];
memset( p_oldx, 0, FILTER_LENGTH * sizeof( int ) ); memset( p_oldx, 0, FILTER_LENGTH * sizeof( int ) );
while( !intf_ShouldDie( p_intf ) ) for( ;; )
{ {
vout_thread_t *p_vout; vout_thread_t *p_vout;
const char *psz_filter, *psz_type; const char *psz_filter, *psz_type;
...@@ -191,6 +191,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -191,6 +191,7 @@ static void RunIntf( intf_thread_t *p_intf )
/* Wait a bit, get orientation, change filter if necessary */ /* Wait a bit, get orientation, change filter if necessary */
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
int canc = vlc_savecancel();
i_x = GetOrientation( p_intf ); i_x = GetOrientation( p_intf );
i_sum += i_x - p_oldx[i]; i_sum += i_x - p_oldx[i];
p_oldx[i++] = i_x; p_oldx[i++] = i_x;
...@@ -212,7 +213,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -212,7 +213,7 @@ static void RunIntf( intf_thread_t *p_intf )
vlc_object_release( p_obj ); vlc_object_release( p_obj );
} }
} }
continue; goto loop;
} }
if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD ) if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD )
...@@ -235,24 +236,22 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -235,24 +236,22 @@ static void RunIntf( intf_thread_t *p_intf )
psz_type = "90"; psz_type = "90";
} }
if( !b_change ) if( b_change )
{ {
continue;
}
p_vout = (vout_thread_t *) p_vout = (vout_thread_t *)
vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( !p_vout ) if( p_vout )
{ {
continue;
}
config_PutPsz( p_vout, "transform-type", psz_type ); config_PutPsz( p_vout, "transform-type", psz_type );
var_SetString( p_vout, "vout-filter", psz_filter ); var_SetString( p_vout, "vout-filter", psz_filter );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
i_oldx = i_x; i_oldx = i_x;
} }
}
loop:
vlc_restorecancel( canc );
}
} }
#undef FILTER_LENGTH #undef FILTER_LENGTH
#undef LOW_THRESHOLD #undef LOW_THRESHOLD
......
...@@ -143,6 +143,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -143,6 +143,7 @@ static void Run( intf_thread_t *p_intf )
char *psz_master = NULL; char *psz_master = NULL;
char p_data[MAX_MSG_LENGTH]; char p_data[MAX_MSG_LENGTH];
int i_socket; int i_socket;
int canc = vlc_savecancel();
if( !b_master ) if( !b_master )
{ {
...@@ -312,6 +313,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -312,6 +313,7 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->p_input ) vlc_object_release( p_intf->p_sys->p_input ); if( p_intf->p_sys->p_input ) vlc_object_release( p_intf->p_sys->p_input );
net_Close( i_socket ); net_Close( i_socket );
vlc_restorecancel( canc );
} }
static mtime_t GetClockRef( intf_thread_t *p_intf, mtime_t i_pts ) static mtime_t GetClockRef( intf_thread_t *p_intf, mtime_t i_pts )
......
...@@ -134,6 +134,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -134,6 +134,7 @@ static void Run( intf_thread_t *p_intf )
{ NULL, NULL } { NULL, NULL }
}; };
int canc = vlc_savecancel();
p_global_intf = p_intf; p_global_intf = p_intf;
p_intf->p_sys = &sys; p_intf->p_sys = &sys;
p_intf->p_sys->psz_service = config_GetPsz( p_intf, "ntservice-name" ); p_intf->p_sys->psz_service = config_GetPsz( p_intf, "ntservice-name" );
...@@ -170,6 +171,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -170,6 +171,7 @@ static void Run( intf_thread_t *p_intf )
/* Make sure we exit (In case other interfaces have been spawned) */ /* Make sure we exit (In case other interfaces have been spawned) */
vlc_object_kill( p_intf->p_libvlc ); vlc_object_kill( p_intf->p_libvlc );
vlc_restorecancel( canc );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -456,6 +456,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -456,6 +456,7 @@ static void Run( intf_thread_t *p_intf )
int i_size = 0; int i_size = 0;
int i_oldpos = 0; int i_oldpos = 0;
int i_newpos; int i_newpos;
int canc = vlc_savecancel();
p_buffer[0] = 0; p_buffer[0] = 0;
p_input = NULL; p_input = NULL;
...@@ -846,6 +847,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -846,6 +847,7 @@ static void Run( intf_thread_t *p_intf )
} }
var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, p_intf ); var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, p_intf );
vlc_restorecancel( canc );
} }
static void Help( intf_thread_t *p_intf, bool b_longhelp) static void Help( intf_thread_t *p_intf, bool b_longhelp)
......
...@@ -111,6 +111,7 @@ void Close( vlc_object_t *p_this ) ...@@ -111,6 +111,7 @@ void Close( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void RunIntf( intf_thread_t *p_intf ) static void RunIntf( intf_thread_t *p_intf )
{ {
int canc = vlc_savecancel( );
p_intf->p_sys->p_vout = NULL; p_intf->p_sys->p_vout = NULL;
if( InitThread( p_intf ) < 0 ) if( InitThread( p_intf ) < 0 )
...@@ -170,6 +171,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -170,6 +171,7 @@ static void RunIntf( intf_thread_t *p_intf )
MouseEvent, p_intf ); MouseEvent, p_intf );
vlc_object_release( p_intf->p_sys->p_vout ); vlc_object_release( p_intf->p_sys->p_vout );
} }
vlc_restorecancel( canc );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -1270,6 +1270,7 @@ static bool isRendererReady( intf_thread_t *p_intf ) ...@@ -1270,6 +1270,7 @@ static bool isRendererReady( intf_thread_t *p_intf )
static void Run( intf_thread_t *p_intf ) static void Run( intf_thread_t *p_intf )
{ {
intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys; intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys;
int canc = vlc_savecancel();
while( !intf_ShouldDie( p_intf ) ) while( !intf_ShouldDie( p_intf ) )
{ {
...@@ -1322,6 +1323,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -1322,6 +1323,7 @@ static void Run( intf_thread_t *p_intf )
} }
End( p_intf ); End( p_intf );
vlc_restorecancel( canc );
} }
static int OverlayCallback( vlc_object_t *p_this, char const *psz_cmd, static int OverlayCallback( vlc_object_t *p_this, char const *psz_cmd,
......
...@@ -390,6 +390,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -390,6 +390,7 @@ static void Run( intf_thread_t *p_intf )
int i_key; int i_key;
time_t t_last_refresh; time_t t_last_refresh;
int canc = vlc_savecancel();
/* /*
* force drawing the interface for the first time * force drawing the interface for the first time
...@@ -464,6 +465,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -464,6 +465,7 @@ static void Run( intf_thread_t *p_intf )
var_DelCallback( p_playlist, "intf-change", PlaylistChanged, p_intf ); var_DelCallback( p_playlist, "intf-change", PlaylistChanged, p_intf );
var_DelCallback( p_playlist, "item-append", PlaylistChanged, p_intf ); var_DelCallback( p_playlist, "item-append", PlaylistChanged, p_intf );
var_DelCallback( p_playlist, "item-change", PlaylistChanged, p_intf ); var_DelCallback( p_playlist, "item-change", PlaylistChanged, p_intf );
vlc_restorecancel( canc );
} }
/* following functions are local */ /* following functions are local */
......
...@@ -156,6 +156,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -156,6 +156,7 @@ static void Run( intf_thread_t *p_intf )
GtkTreeViewColumn *p_column = NULL; GtkTreeViewColumn *p_column = NULL;
GtkListStore *p_filelist = NULL; GtkListStore *p_filelist = NULL;
GtkListStore *p_playlist_store = NULL; GtkListStore *p_playlist_store = NULL;
int canc = vlc_savecancel();
#ifndef NEED_GTK2_MAIN #ifndef NEED_GTK2_MAIN
gtk_set_locale (); gtk_set_locale ();
...@@ -348,6 +349,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -348,6 +349,7 @@ static void Run( intf_thread_t *p_intf )
#ifdef NEED_GTK2_MAIN #ifdef NEED_GTK2_MAIN
gdk_threads_leave(); gdk_threads_leave();
#endif #endif
vlc_restorecancel(canc);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -298,7 +298,11 @@ static void Run( intf_thread_t *p_intf ) ...@@ -298,7 +298,11 @@ static void Run( intf_thread_t *p_intf )
msg_Err( p_intf, "failed to create Qt dialogs thread" ); msg_Err( p_intf, "failed to create Qt dialogs thread" );
} }
else else
{
int canc = vlc_savecancel ();
Init( VLC_OBJECT(p_intf) ); Init( VLC_OBJECT(p_intf) );
vlc_restorecancel( canc );
}
} }
static QMutex windowLock; static QMutex windowLock;
......
...@@ -195,6 +195,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -195,6 +195,7 @@ static void Close( vlc_object_t *p_this )
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void Run( intf_thread_t *p_intf ) static void Run( intf_thread_t *p_intf )
{ {
int canc = vlc_savecancel();
// Load a theme // Load a theme
ThemeLoader *pLoader = new ThemeLoader( p_intf ); ThemeLoader *pLoader = new ThemeLoader( p_intf );
char *skin_last = config_GetPsz( p_intf, "skins2-last" ); char *skin_last = config_GetPsz( p_intf, "skins2-last" );
...@@ -253,6 +254,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -253,6 +254,7 @@ static void Run( intf_thread_t *p_intf )
delete p_intf->p_sys->p_theme; delete p_intf->p_sys->p_theme;
p_intf->p_sys->p_theme = NULL; p_intf->p_sys->p_theme = NULL;
} }
vlc_restorecancel(canc);
} }
......
...@@ -203,8 +203,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -203,8 +203,10 @@ static void Run( intf_thread_t *p_intf )
} }
else else
{ {
int canc = vlc_savecancel();
/* The module is used in interface mode */ /* The module is used in interface mode */
MainLoop( p_intf ); MainLoop( p_intf );
vlc_restorecancel( canc );
} }
} }
......
...@@ -287,8 +287,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -287,8 +287,10 @@ static void Run( intf_thread_t *p_intf )
} }
else else
{ {
int canc = vlc_savecancel();
/* The module is used in interface mode */ /* The module is used in interface mode */
Init( p_intf ); Init( p_intf );
vlc_restorecancel( canc );
} }
} }
......
...@@ -254,6 +254,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -254,6 +254,7 @@ static void Run( intf_thread_t *p_intf )
uint8_t p_buffer[1024]; uint8_t p_buffer[1024];
char *p_buffer_pos; char *p_buffer_pos;
int i_post_socket; int i_post_socket;
int canc = vlc_savecancel();
intf_sys_t *p_sys = p_intf->p_sys; intf_sys_t *p_sys = p_intf->p_sys;
...@@ -262,13 +263,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -262,13 +263,10 @@ static void Run( intf_thread_t *p_intf )
{ {
bool b_wait = false; bool b_wait = false;
vlc_restorecancel( canc );
vlc_object_lock( p_intf ); vlc_object_lock( p_intf );
if( !vlc_object_alive( p_intf ) ) vlc_cleanup_push( __vlc_object_unlock, p_intf );
{
vlc_object_unlock( p_intf );
msg_Dbg( p_intf, "audioscrobbler is dying");
return;
}
if( mdate() < p_sys->next_exchange ) if( mdate() < p_sys->next_exchange )
/* wait until we can resubmit, i.e. */ /* wait until we can resubmit, i.e. */
b_wait = vlc_object_timedwait( p_intf, p_sys->next_exchange ) == 0; b_wait = vlc_object_timedwait( p_intf, p_sys->next_exchange ) == 0;
...@@ -276,7 +274,8 @@ static void Run( intf_thread_t *p_intf ) ...@@ -276,7 +274,8 @@ static void Run( intf_thread_t *p_intf )
/* wait for data to submit */ /* wait for data to submit */
/* we are signaled each time there is a song to submit */ /* we are signaled each time there is a song to submit */
vlc_object_wait( p_intf ); vlc_object_wait( p_intf );
vlc_object_unlock( p_intf ); vlc_cleanup_run();
canc = vlc_savecancel();
if( b_wait ) if( b_wait )
continue; /* holding on until next_exchange */ continue; /* holding on until next_exchange */
...@@ -456,6 +455,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -456,6 +455,7 @@ static void Run( intf_thread_t *p_intf )
continue; continue;
} }
} }
vlc_restorecancel( canc );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -219,13 +219,12 @@ static int UnInhibit( intf_thread_t *p_intf ) ...@@ -219,13 +219,12 @@ static int UnInhibit( intf_thread_t *p_intf )
*****************************************************************************/ *****************************************************************************/
static void Run( intf_thread_t *p_intf ) static void Run( intf_thread_t *p_intf )
{ {
vlc_object_lock( p_intf ); for( ;; )
while( vlc_object_alive( p_intf ) )
{ {
input_thread_t *p_input; input_thread_t *p_input;
/* Check playing state every 30 seconds */ /* Check playing state every 30 seconds */
vlc_object_timedwait( p_intf, mdate() + 30000000 ); msleep( 30 * CLOCK_FREQ );
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input ) if( p_input )
...@@ -250,7 +249,4 @@ static void Run( intf_thread_t *p_intf ) ...@@ -250,7 +249,4 @@ static void Run( intf_thread_t *p_intf )
break; break;
} }
} }
end:
vlc_object_unlock( p_intf );
} }
...@@ -321,14 +321,17 @@ static void Close( vlc_object_t *p_this ) ...@@ -321,14 +321,17 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void Run( intf_thread_t *p_intf ) static void Run( intf_thread_t *p_intf )
{ {
while( vlc_object_alive (p_intf) ) for( ;; )
{ {
int canc = vlc_savecancel();
FlushQueue( p_intf->p_sys->p_sub, p_intf->p_sys->p_file, FlushQueue( p_intf->p_sys->p_sub, p_intf->p_sys->p_file,
p_intf->p_sys->i_mode, p_intf->p_sys->i_mode,
var_CreateGetInteger( p_intf, "verbose" ) ); var_CreateGetInteger( p_intf, "verbose" ) );
if( p_intf->p_sys->p_rrd ) if( p_intf->p_sys->p_rrd )
DoRRD( p_intf ); DoRRD( p_intf );
vlc_restorecancel( canc );
/* FIXME: this is WRONG. */
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
} }
} }
......
...@@ -281,6 +281,7 @@ void Close_LuaIntf( vlc_object_t *p_this ) ...@@ -281,6 +281,7 @@ void Close_LuaIntf( vlc_object_t *p_this )