]> git.sesse.net Git - vlc/commitdiff
Pull cancellation into (most) remaining interfaces
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 3 Sep 2008 19:31:17 +0000 (22:31 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 3 Sep 2008 19:46:22 +0000 (22:46 +0300)
25 files changed:
modules/access/vcdx/intf.c
modules/codec/cmml/intf.c
modules/control/dbus.c
modules/control/gestures.c
modules/control/hotkeys.c
modules/control/lirc.c
modules/control/motion.c
modules/control/netsync.c
modules/control/ntservice.c
modules/control/rc.c
modules/control/showintf.c
modules/gui/fbosd.c
modules/gui/ncurses.c
modules/gui/pda/pda.c
modules/gui/qt4/qt4.cpp
modules/gui/skins2/src/skin_main.cpp
modules/gui/wince/wince.cpp
modules/gui/wxwidgets/wxwidgets.cpp
modules/misc/audioscrobbler.c
modules/misc/inhibit.c
modules/misc/logger.c
modules/misc/lua/intf.c
modules/misc/notify/xosd.c
modules/misc/probe/hal.c
modules/misc/screensaver.c

index 38be5c7abda9eb0223fd284ddbfc282b73d8b45d..efd8cfcac1643b02d72752fc9cfbaaf8af988014 100644 (file)
@@ -105,6 +105,7 @@ RunIntf( intf_thread_t *p_intf )
        the 10_ADD keypresses */
     int number_addend = 0;
 
+    int canc = vlc_savecancel();
     if( InitThread( p_intf ) < 0 )
     {
         msg_Err( p_intf, "can't initialize intf" );
@@ -121,6 +122,7 @@ RunIntf( intf_thread_t *p_intf )
     p_vcdplayer = p_intf->p_sys->p_vcdplayer;
     p_access    = p_vcdplayer->p_access;
 
+    int canc = vlc_savecancel();
     dbg_print( INPUT_DBG_CALL, "intf initialized" );
 
     /* Main loop */
@@ -309,6 +311,7 @@ RunIntf( intf_thread_t *p_intf )
     }
 
     vlc_object_release( p_intf->p_sys->p_input );
+    vlc_restorecancel( canc );
 }
 
 /*****************************************************************************
index 97040969b2222b16fda313f2f82dd912eb866249..389465c4429468a892f143cf00b3718339ccf49c 100644 (file)
@@ -177,6 +177,7 @@ void CloseIntf ( vlc_object_t *p_this )
  *****************************************************************************/
 static void RunIntf( intf_thread_t *p_intf )
 {
+    int canc = vlc_savecancel();
     vout_thread_t * p_vout = NULL;
 
     if( InitThread( p_intf ) < 0 )
@@ -250,6 +251,7 @@ static void RunIntf( intf_thread_t *p_intf )
     }
 
     vlc_object_release( p_intf->p_sys->p_input );
+    vlc_restorecancel( canc );
 }
 
 /*****************************************************************************
index 7c8a1c9431258f3661aa1f08d356be6934eaefa7..80dee19e21acc88e54630ce6316818a6b66b6059 100644 (file)
@@ -826,10 +826,12 @@ static void Close   ( vlc_object_t *p_this )
 
 static void Run          ( intf_thread_t *p_intf )
 {
-    while( !intf_ShouldDie( p_intf ) )
+    for( ;; )
     {
         msleep( INTF_IDLE_SLEEP );
+        int canc = vlc_savecancel();
         dbus_connection_read_write_dispatch( p_intf->p_sys->p_conn, 0 );
+        vlc_restorecancel( canc );
     }
 }
 
index df9f8079e1620183e660a5f3f1aac66d70f06b9d..e849d0dfca298ff75a73687a11bb87061b76d8a7 100644 (file)
@@ -168,6 +168,7 @@ void Close ( vlc_object_t *p_this )
 static void RunIntf( intf_thread_t *p_intf )
 {
     playlist_t * p_playlist = NULL;
+    int canc = vlc_savecancel();
 
     vlc_mutex_lock( &p_intf->change_lock );
     p_intf->p_sys->p_vout = NULL;
@@ -450,6 +451,7 @@ static void RunIntf( intf_thread_t *p_intf )
     }
 
     EndThread( p_intf );
+    vlc_restorecancel( canc );
 }
 
 /*****************************************************************************
index c5fbc19eee8626ee3e21324588fcb4477e4e42d1..c3c7dc1116c8d8ff0924fac7a9b1262d172578ef 100644 (file)
@@ -139,6 +139,7 @@ static void Run( intf_thread_t *p_intf )
     vlc_value_t val;
     int i;
     playlist_t *p_playlist = pl_Yield( p_intf );
+    int canc = vlc_savecancel();
 
     /* Initialize hotkey structure */
     for( struct hotkey *p_hotkey = p_intf->p_libvlc->p_hotkeys;
@@ -830,6 +831,7 @@ static void Run( intf_thread_t *p_intf )
             vlc_object_release( p_input );
     }
     pl_Release( p_intf );
+    vlc_restorecancel( canc );
 }
 
 static int GetAction( intf_thread_t *p_intf )
index de500e10972c8e68254c0c43df98e9aa58de7c20..fb0e37f898e34ff83aa26f8710ee09ecae375614 100644 (file)
@@ -138,11 +138,14 @@ static void Close( vlc_object_t *p_this )
 static void Run( intf_thread_t *p_intf )
 {
     char *code, *c;
+    int canc = vlc_savecancel();
 
-    while( !intf_ShouldDie( p_intf ) )
+    for( ;; )
     {
         /* Sleep a bit */
+        vlc_restorecancel(canc);
         msleep( INTF_IDLE_SLEEP );
+        canc = vlc_savecancel();
 
         /* We poll the lircsocket */
         if( lirc_nextcode(&code) != 0 )
@@ -199,4 +202,5 @@ static void Run( intf_thread_t *p_intf )
         }
         free( code );
     }
+    vlc_restorecancel(canc);
 }
index 59d6ba2c516f5ffcdcee03407d25e0ae1f2613f8..6219f7b6c1b80e97f6d498f7c84baec4611b5fc5 100644 (file)
@@ -182,7 +182,7 @@ static void RunIntf( intf_thread_t *p_intf )
     int p_oldx[FILTER_LENGTH];
     memset( p_oldx, 0, FILTER_LENGTH * sizeof( int ) );
 
-    while( !intf_ShouldDie( p_intf ) )
+    for( ;; )
     {
         vout_thread_t *p_vout;
         const char *psz_filter, *psz_type;
@@ -191,6 +191,7 @@ static void RunIntf( intf_thread_t *p_intf )
         /* Wait a bit, get orientation, change filter if necessary */
         msleep( INTF_IDLE_SLEEP );
 
+        int canc = vlc_savecancel();
         i_x = GetOrientation( p_intf );
         i_sum += i_x - p_oldx[i];
         p_oldx[i++] = i_x;
@@ -212,7 +213,7 @@ static void RunIntf( intf_thread_t *p_intf )
                     vlc_object_release( p_obj );
                 }
             }
-            continue;
+            goto loop;
         }
 
         if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD )
@@ -235,23 +236,21 @@ static void RunIntf( intf_thread_t *p_intf )
             psz_type = "90";
         }
 
-        if( !b_change )
+        if( b_change )
         {
-            continue;
-        }
+            p_vout = (vout_thread_t *)
+                vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+            if( p_vout )
+            {
+                config_PutPsz( p_vout, "transform-type", psz_type );
+                var_SetString( p_vout, "vout-filter", psz_filter );
+                vlc_object_release( p_vout );
 
-        p_vout = (vout_thread_t *)
-            vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
-        if( !p_vout )
-        {
-            continue;
+                i_oldx = i_x;
+            }
         }
-
-        config_PutPsz( p_vout, "transform-type", psz_type );
-        var_SetString( p_vout, "vout-filter", psz_filter );
-        vlc_object_release( p_vout );
-
-        i_oldx = i_x;
+loop:
+        vlc_restorecancel( canc );
     }
 }
 #undef FILTER_LENGTH
index 8be09774b1e4104c626d0226ab742345829795a1..28722d8dc39751651075fbe5b98b00f6d64b7cb2 100644 (file)
@@ -143,6 +143,7 @@ static void Run( intf_thread_t *p_intf )
     char *psz_master = NULL;
     char p_data[MAX_MSG_LENGTH];
     int i_socket;
+    int canc = vlc_savecancel();
 
     if( !b_master )
     {
@@ -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 );
     net_Close( i_socket );
+    vlc_restorecancel( canc );
 }
 
 static mtime_t GetClockRef( intf_thread_t *p_intf, mtime_t i_pts )
index ed02e68ab1961c8bb5cbbfe23fe36152df3b6371..403fe1690ae057a33ddddb5cf539988101821407 100644 (file)
@@ -134,6 +134,7 @@ static void Run( intf_thread_t *p_intf )
         { NULL, NULL }
     };
 
+    int canc = vlc_savecancel();
     p_global_intf = p_intf;
     p_intf->p_sys = &sys;
     p_intf->p_sys->psz_service = config_GetPsz( p_intf, "ntservice-name" );
@@ -170,6 +171,7 @@ static void Run( intf_thread_t *p_intf )
 
     /* Make sure we exit (In case other interfaces have been spawned) */
     vlc_object_kill( p_intf->p_libvlc );
+    vlc_restorecancel( canc );
 }
 
 /*****************************************************************************
index 5e45c61a6272ef15f651812a5e85d39c30ae68a5..ad6150a7d5df1707de13876afacf2752b6c91ade 100644 (file)
@@ -449,13 +449,14 @@ static void Run( intf_thread_t *p_intf )
     input_thread_t * p_input;
     playlist_t *     p_playlist;
 
-    char       p_buffer[ MAX_LINE_LENGTH + 1 ];
+    char p_buffer[ MAX_LINE_LENGTH + 1 ];
     bool b_showpos = config_GetInt( p_intf, "rc-show-pos" );
     bool b_longhelp = false;
 
-    int        i_size = 0;
-    int        i_oldpos = 0;
-    int        i_newpos;
+    int  i_size = 0;
+    int  i_oldpos = 0;
+    int  i_newpos;
+    int  canc = vlc_savecancel();
 
     p_buffer[0] = 0;
     p_input = NULL;
@@ -846,6 +847,7 @@ static void Run( intf_thread_t *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)
index bebf0679b1f8b559b07dd466ab61ffcfe5dcfe85..d1360dfdf8ecf7aa0fb6002ba71281be8aa499d2 100644 (file)
@@ -111,6 +111,7 @@ void Close( vlc_object_t *p_this )
  *****************************************************************************/
 static void RunIntf( intf_thread_t *p_intf )
 {
+    int canc = vlc_savecancel( );
     p_intf->p_sys->p_vout = NULL;
 
     if( InitThread( p_intf ) < 0 )
@@ -170,6 +171,7 @@ static void RunIntf( intf_thread_t *p_intf )
                          MouseEvent, p_intf );
         vlc_object_release( p_intf->p_sys->p_vout );
     }
+    vlc_restorecancel( canc );
 }
 
 /*****************************************************************************
index fcfb3c53fd1484ad7f3b7de6192b8ae1531c7551..4723feac0c8edcbccb31004787583d3010655c00 100644 (file)
@@ -1270,6 +1270,7 @@ static bool isRendererReady( 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;
+    int canc = vlc_savecancel();
 
     while( !intf_ShouldDie( p_intf ) )
     {
@@ -1322,6 +1323,7 @@ static void Run( intf_thread_t *p_intf )
     }
 
     End( p_intf );
+    vlc_restorecancel( canc );
 }
 
 static int OverlayCallback( vlc_object_t *p_this, char const *psz_cmd,
index d93d0a7deefd672fa244674277b3f6b5129f4517..7b490c07b5f3d9b16fda79815e6b2fd70b0af336 100644 (file)
@@ -390,6 +390,7 @@ static void Run( intf_thread_t *p_intf )
 
     int i_key;
     time_t t_last_refresh;
+    int canc = vlc_savecancel();
 
     /*
      * force drawing the interface for the first time
@@ -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, "item-append", PlaylistChanged, p_intf );
     var_DelCallback( p_playlist, "item-change", PlaylistChanged, p_intf );
+    vlc_restorecancel( canc );
 }
 
 /* following functions are local */
index 15719707632955b6c90b5457560578033c0bd00c..429a5f13875a250a50961df838392b996471615b 100644 (file)
@@ -156,6 +156,7 @@ static void Run( intf_thread_t *p_intf )
     GtkTreeViewColumn *p_column   = NULL;
     GtkListStore      *p_filelist = NULL;
     GtkListStore      *p_playlist_store = NULL;
+    int canc = vlc_savecancel();
 
 #ifndef NEED_GTK2_MAIN
     gtk_set_locale ();
@@ -348,6 +349,7 @@ static void Run( intf_thread_t *p_intf )
 #ifdef NEED_GTK2_MAIN
     gdk_threads_leave();
 #endif
+    vlc_restorecancel(canc);
 }
 
 /*****************************************************************************
index eb0c937cfad22ac9ed32e61cfab275061175b7e7..5abd56973abd4b940567e9ffddf66125139d2ee1 100644 (file)
@@ -298,7 +298,11 @@ static void Run( intf_thread_t *p_intf )
             msg_Err( p_intf, "failed to create Qt dialogs thread" );
     }
     else
+    {
+        int canc = vlc_savecancel ();
         Init( VLC_OBJECT(p_intf) );
+        vlc_restorecancel( canc );
+    }
 }
 
 static QMutex windowLock;
index a78cc6abcf8842ade68e09a16fbf52d653beb6a7..5d5728616866a6fe82ed1fe046326bd29001c08f 100644 (file)
@@ -195,6 +195,7 @@ static void Close( vlc_object_t *p_this )
 //---------------------------------------------------------------------------
 static void Run( intf_thread_t *p_intf )
 {
+    int canc = vlc_savecancel();
     // Load a theme
     ThemeLoader *pLoader = new ThemeLoader( p_intf );
     char *skin_last = config_GetPsz( p_intf, "skins2-last" );
@@ -253,6 +254,7 @@ static void Run( intf_thread_t *p_intf )
         delete p_intf->p_sys->p_theme;
         p_intf->p_sys->p_theme = NULL;
     }
+    vlc_restorecancel(canc);
 }
 
 
index beee18fefc84f88668637b45f2c8596671c1216c..539f6397c494ffee4b7fc872905f449130e803f0 100644 (file)
@@ -203,8 +203,10 @@ static void Run( intf_thread_t *p_intf )
     }
     else
     {
+        int canc = vlc_savecancel();
         /* The module is used in interface mode */
         MainLoop( p_intf );
+        vlc_restorecancel( canc );
     }
 }
 
index d45bee707fd084aa2b4c4caba49a49085bba570e..cf65e0a009feab93b78182eddfa854cae1d11022 100644 (file)
@@ -287,8 +287,10 @@ static void Run( intf_thread_t *p_intf )
     }
     else
     {
+        int canc = vlc_savecancel();
         /* The module is used in interface mode */
         Init( p_intf );
+        vlc_restorecancel( canc );
     }
 }
 
index 5b5935b6471c01664a6a3025c33fb1570332835a..bd333d83d9be1d6a96ac4dafc421a850d6f29b94 100644 (file)
@@ -254,6 +254,7 @@ static void Run( intf_thread_t *p_intf )
     uint8_t                 p_buffer[1024];
     char                    *p_buffer_pos;
     int                     i_post_socket;
+    int                     canc = vlc_savecancel();
 
     intf_sys_t *p_sys = p_intf->p_sys;
 
@@ -262,13 +263,10 @@ static void Run( intf_thread_t *p_intf )
     {
         bool b_wait = false;
 
+        vlc_restorecancel( canc );
         vlc_object_lock( p_intf );
-        if( !vlc_object_alive( p_intf ) )
-        {
-            vlc_object_unlock( p_intf );
-            msg_Dbg( p_intf, "audioscrobbler is dying");
-            return;
-        }
+        vlc_cleanup_push( __vlc_object_unlock, p_intf );
+
         if( mdate() < p_sys->next_exchange )
             /* wait until we can resubmit, i.e.  */
             b_wait = vlc_object_timedwait( p_intf, p_sys->next_exchange ) == 0;
@@ -276,7 +274,8 @@ static void Run( intf_thread_t *p_intf )
             /* wait for data to submit */
             /* we are signaled each time there is a song to submit */
             vlc_object_wait( p_intf );
-        vlc_object_unlock( p_intf );
+        vlc_cleanup_run();
+        canc = vlc_savecancel();
 
         if( b_wait )
             continue; /* holding on until next_exchange */
@@ -456,6 +455,7 @@ static void Run( intf_thread_t *p_intf )
             continue;
         }
     }
+    vlc_restorecancel( canc );
 }
 
 /*****************************************************************************
index da182ae52996d021dbbb154cf70ea0abb77094ff..b50d8e95acc0a744363bd9c03c81ccf4704d997b 100644 (file)
@@ -219,13 +219,12 @@ static int UnInhibit( intf_thread_t *p_intf )
  *****************************************************************************/
 static void Run( intf_thread_t *p_intf )
 {
-    vlc_object_lock( p_intf );
-    while( vlc_object_alive( p_intf ) )
+    for( ;; )
     {
         input_thread_t *p_input;
 
         /* 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 );
         if( p_input )
@@ -250,7 +249,4 @@ static void Run( intf_thread_t *p_intf )
                 break;
         }
     }
-
-end:
-    vlc_object_unlock( p_intf );
 }
index 7bdefc164bf71263aa0d907b33db949544856aa5..00b9d39383fb091aab5b118c84ecc924f8dec0a9 100644 (file)
@@ -321,14 +321,17 @@ static void Close( vlc_object_t *p_this )
  *****************************************************************************/
 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,
                     p_intf->p_sys->i_mode,
                     var_CreateGetInteger( p_intf, "verbose" ) );
         if( p_intf->p_sys->p_rrd )
             DoRRD( p_intf );
 
+        vlc_restorecancel( canc );
+        /* FIXME: this is WRONG. */
         msleep( INTF_IDLE_SLEEP );
     }
 }
index 2c4eb8882eb6d8d4533b986daed275b4b122ad0c..dba8fd5b5b04afa4a8e0f3d61412e5559c787dce 100644 (file)
@@ -281,6 +281,7 @@ void Close_LuaIntf( vlc_object_t *p_this )
 
 static void Run( intf_thread_t *p_intf )
 {
+    int canc = vlc_savecancel( );
     lua_State *L = p_intf->p_sys->L;
 
     if( luaL_dofile( L, p_intf->p_sys->psz_filename ) )
@@ -289,8 +290,6 @@ static void Run( intf_thread_t *p_intf )
                  p_intf->p_sys->psz_filename,
                  lua_tostring( L, lua_gettop( L ) ) );
         lua_pop( L, 1 );
-        p_intf->b_die = true;
-        return;
     }
-    p_intf->b_die = true;
+    vlc_restorecancel( canc );
 }
index 0b61f3eb626b544ccf3ef526cc2c942bfb2ed17e..c135a03d35850e87acb7f3f56ebfe6f45ba75cf5 100644 (file)
@@ -219,8 +219,9 @@ static void Run( intf_thread_t *p_intf )
     char psz_duration[MSTRTIME_MAX_SIZE+2];
     char *psz_display = NULL;
 
-    while( vlc_object_alive (p_intf) )
+    for( ;; )
     {
+        int canc = vlc_savecancel();
         if( p_intf->p_sys->b_need_update == true )
         {
             p_intf->p_sys->b_need_update = false;
@@ -278,6 +279,7 @@ static void Run( intf_thread_t *p_intf )
                             psz_display );
         }
 
+        vlc_restorecancel( canc );
         msleep( INTF_IDLE_SLEEP );
     }
 }
index b131b73c660ae6fead5b8347c7366b834c61e774..29c6c776d536b3500cc3e4f76914c2ce14fdd3d6 100644 (file)
@@ -130,6 +130,7 @@ static void Update( device_probe_t * p_probe )
     int i, i_devices, j;
     char **devices;
     bool b_exists;
+    int canc = vlc_savecancel();
 
     for ( j = 0 ; j < p_sys->i_devices; j++ )
         p_sys->pp_devices[j]->b_seen = false;
@@ -160,6 +161,7 @@ static void Update( device_probe_t * p_probe )
         }
     }
     /// \todo Remove unseen devices
+    vlc_restorecancel( canc );
 }
 
 
index 782333070579c3580f586f2040fe25baae510777..47b2725a3b637cec3e8066aeed95a846fd46dd83 100644 (file)
@@ -166,20 +166,15 @@ static void Execute( intf_thread_t *p_this, const char *const *ppsz_args )
  *****************************************************************************/
 static void Run( intf_thread_t *p_intf )
 {
-    mtime_t deadline = mdate();
-
-    vlc_object_lock( p_intf );
+    int canc = vlc_savecancel();
 #ifdef HAVE_DBUS
     p_intf->p_sys->p_connection = dbus_init( p_intf );
 #endif
 
-    while( vlc_object_alive( p_intf ) )
-    {
+    for( ;; )
+   {
         vlc_object_t *p_vout;
 
-        if( vlc_object_timedwait( p_intf, deadline ) == 0 )
-            continue;
-
         p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
 
         /* If there is a video output, disable xscreensaver */
@@ -213,10 +208,10 @@ static void Run( intf_thread_t *p_intf )
             }
         }
 
+        vlc_restorecancel( canc );
         /* Check screensaver every 30 seconds */
-        deadline = mdate() + 30000000;
+        msleep( 30 * CLOCK_FREQ );
     }
-    vlc_object_unlock( p_intf );
 }
 
 #ifdef HAVE_DBUS