[vlc-commits] update: use vlc_atomic_* instead of vlc_object_(kill|alive)

Rémi Denis-Courmont git at videolan.org
Wed May 9 18:53:08 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May  9 18:34:45 2012 +0300| [21efe6492e4baeffceb3d26b155d31f9c49b7574] | committer: Rémi Denis-Courmont

update: use vlc_atomic_* instead of vlc_object_(kill|alive)

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

 src/misc/update.c |    9 +++++----
 src/misc/update.h |    2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/misc/update.c b/src/misc/update.c
index ad58887..d6a25f4 100644
--- a/src/misc/update.c
+++ b/src/misc/update.c
@@ -143,7 +143,7 @@ void update_Delete( update_t *p_update )
 
     if( p_update->p_download )
     {
-        vlc_object_kill( p_update->p_download );
+        vlc_atomic_set( &p_update->p_download->aborted, 1 );
         vlc_join( p_update->p_download->thread, NULL );
         vlc_object_release( p_update->p_download );
     }
@@ -494,7 +494,7 @@ void update_Download( update_t *p_update, const char *psz_destdir )
     // If the object already exist, destroy it
     if( p_update->p_download )
     {
-        vlc_object_kill( p_update->p_download );
+        vlc_atomic_set( &p_udt->p_download->aborted, 1 );
         vlc_join( p_update->p_download->thread, NULL );
         vlc_object_release( p_update->p_download );
     }
@@ -509,6 +509,7 @@ void update_Download( update_t *p_update, const char *psz_destdir )
     p_update->p_download = p_udt;
     p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
 
+    vlc_atomic_set(&p_udt->aborted, 0);
     vlc_clone( &p_udt->thread, update_DownloadReal, p_udt, VLC_THREAD_PRIORITY_LOW );
 }
 
@@ -589,7 +590,7 @@ static void* update_DownloadReal( void *obj )
     if( p_progress == NULL )
         goto end;
 
-    while( vlc_object_alive( p_udt ) &&
+    while( !vlc_atomic_get( &p_udt->aborted ) &&
            ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
            !dialog_ProgressCancelled( p_progress ) )
     {
@@ -617,7 +618,7 @@ static void* update_DownloadReal( void *obj )
     fclose( p_file );
     p_file = NULL;
 
-    if( vlc_object_alive( p_udt ) &&
+    if( !vlc_atomic_get( &p_udt->aborted ) &&
         !dialog_ProgressCancelled( p_progress ) )
     {
         dialog_ProgressDestroy( p_progress );
diff --git a/src/misc/update.h b/src/misc/update.h
index 41de2d2..83d0723 100644
--- a/src/misc/update.h
+++ b/src/misc/update.h
@@ -38,6 +38,7 @@
  */
 
 #include <vlc_update.h>
+#include <vlc_atomic.h>
 
 enum    /* Public key algorithms */
 {
@@ -152,6 +153,7 @@ typedef struct
     VLC_COMMON_MEMBERS
 
     vlc_thread_t thread;
+    vlc_atomic_t aborted;
     update_t *p_update;
     char *psz_destdir;
 } update_download_thread_t;



More information about the vlc-commits mailing list