[vlc-devel] commit: SD: pull down cancellation safety on those SD with lame threads ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Aug 28 21:39:20 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Thu Aug 28 22:38:30 2008 +0300| [c6d9fff0be9732e0e2bc116525c115e20acd0b13] | committer: Rémi Denis-Courmont 

SD: pull down cancellation safety on those SD with lame threads

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c6d9fff0be9732e0e2bc116525c115e20acd0b13
---

 modules/services_discovery/hal.c     |    5 +++++
 modules/services_discovery/podcast.c |   11 +++++++----
 modules/services_discovery/shout.c   |    2 ++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/modules/services_discovery/hal.c b/modules/services_discovery/hal.c
index b45b5fd..3d6c32e 100644
--- a/modules/services_discovery/hal.c
+++ b/modules/services_discovery/hal.c
@@ -300,6 +300,7 @@ static void Run( services_discovery_t *p_sd )
     int i, i_devices;
     char **devices;
     services_discovery_sys_t    *p_sys  = p_sd->p_sys;
+    int canc = vlc_savecancel();
 
     /* parse existing devices first */
     if( ( devices = libhal_get_all_devices( p_sys->p_ctx, &i_devices, NULL ) ) )
@@ -310,12 +311,16 @@ static void Run( services_discovery_t *p_sd )
             libhal_free_string( devices[ i ] );
         }
     }
+
+    /* FIXME: Totally lame. There are DBus watch functions to do this properly.
+     * -- Courmisch, 28/08/2008 */
     while( vlc_object_alive (p_sd) )
     {
         /* look for events on the bus, blocking 1 second */
         dbus_connection_read_write_dispatch( p_sys->p_connection, 1000 );
         /* HAL 0.5.8.1 can use libhal_ctx_get_dbus_connection(p_sys->p_ctx) */
     }
+    vlc_restorecancel (canc);
 }
 
 void DeviceAdded( LibHalContext *p_ctx, const char *psz_udi )
diff --git a/modules/services_discovery/podcast.c b/modules/services_discovery/podcast.c
index 2c4e8f2..95d4ba6 100644
--- a/modules/services_discovery/podcast.c
+++ b/modules/services_discovery/podcast.c
@@ -159,9 +159,12 @@ static void Run( services_discovery_t *p_sd )
     var_Create( p_sd, "podcast-urls", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_AddCallback( p_sd, "podcast-urls", UrlsChange, p_sys );
 
-    while( vlc_object_alive (p_sd) )
+    for( ;; )
     {
-        int i;
+        /* FIXME: That's 2000 wake up per seconds too many. */
+        msleep( 500 );
+
+        int canc = vlc_savecancel (); /* <- FIXME: should not be needed */
         if( p_sys->b_update == true )
         {
             msg_Dbg( p_sd, "Update required" );
@@ -172,7 +175,7 @@ static void Run( services_discovery_t *p_sd )
             p_sys->b_update = false;
         }
 
-        for( i = 0; i < p_sd->p_sys->i_input; i++ )
+        for( int i = 0; i < p_sd->p_sys->i_input; i++ )
         {
             if( p_sd->p_sys->pp_input[i]->b_eof
                 || p_sd->p_sys->pp_input[i]->b_error )
@@ -184,7 +187,7 @@ static void Run( services_discovery_t *p_sd )
                 i--;
             }
         }
-        msleep( 500 );
+        vlc_restorecancel (canc);
     }
 }
 
diff --git a/modules/services_discovery/shout.c b/modules/services_discovery/shout.c
index bab1f02..277cf72 100644
--- a/modules/services_discovery/shout.c
+++ b/modules/services_discovery/shout.c
@@ -215,6 +215,7 @@ static void Run( services_discovery_t *p_sd )
 {
     enum type_e i_type = (enum type_e)p_sd->p_sys;
     int i, j;
+    int canc = vlc_savecancel();
     
     if( !p_items[i_type].p_children )
     {
@@ -238,6 +239,7 @@ static void Run( services_discovery_t *p_sd )
             vlc_gc_decref( p_input );
         }
     }
+    vlc_restorecancel(canc);
 }
 
 /*****************************************************************************




More information about the vlc-devel mailing list