[vlc-commits] Updated update code to vlc_clone().
Laurent Aimar
git at videolan.org
Mon May 23 21:16:29 CEST 2011
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon May 23 21:14:25 2011 +0200| [9b34074c6e2fcb9baea5a3057da9b94a361607d4] | committer: Laurent Aimar
Updated update code to vlc_clone().
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9b34074c6e2fcb9baea5a3057da9b94a361607d4
---
src/misc/update.c | 34 +++++++++++++++-------------------
src/misc/update.h | 5 ++++-
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/src/misc/update.c b/src/misc/update.c
index 02adb3a..06a4f42 100644
--- a/src/misc/update.c
+++ b/src/misc/update.c
@@ -130,15 +130,14 @@ void update_Delete( update_t *p_update )
if( p_update->p_check )
{
- vlc_object_kill( p_update->p_check );
- vlc_thread_join( p_update->p_check );
- vlc_object_release( p_update->p_check );
+ vlc_join( p_update->p_check->thread, NULL );
+ free( p_update->p_check );
}
if( p_update->p_download )
{
vlc_object_kill( p_update->p_download );
- vlc_thread_join( p_update->p_download );
+ vlc_join( p_update->p_download->thread, NULL );
vlc_object_release( p_update->p_download );
}
@@ -373,7 +372,7 @@ error:
return false;
}
-static void* update_CheckReal( vlc_object_t *p_this );
+static void* update_CheckReal( void * );
/**
* Check for updates
@@ -390,14 +389,11 @@ void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ), void
// If the object already exist, destroy it
if( p_update->p_check )
{
- vlc_object_kill( p_update->p_check );
- vlc_thread_join( p_update->p_check );
- vlc_object_release( p_update->p_check );
+ vlc_join( p_update->p_check->thread, NULL );
+ free( p_update->p_check );
}
- update_check_thread_t *p_uct =
- vlc_custom_create( p_update->p_libvlc, sizeof( *p_uct ),
- VLC_OBJECT_GENERIC, "update check" );
+ update_check_thread_t *p_uct = calloc( 1, sizeof( *p_uct ) );
if( !p_uct ) return;
p_uct->p_update = p_update;
@@ -405,12 +401,12 @@ void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ), void
p_uct->pf_callback = pf_callback;
p_uct->p_data = p_data;
- vlc_thread_create( p_uct, update_CheckReal, VLC_THREAD_PRIORITY_LOW );
+ vlc_clone( &p_uct->thread, update_CheckReal, p_uct, VLC_THREAD_PRIORITY_LOW );
}
-void* update_CheckReal( vlc_object_t* p_this )
+void* update_CheckReal( void *obj )
{
- update_check_thread_t *p_uct = (update_check_thread_t *)p_this;
+ update_check_thread_t *p_uct = (update_check_thread_t *)obj;
bool b_ret;
int canc;
@@ -486,7 +482,7 @@ static char *size_str( long int l_size )
return i_retval == -1 ? NULL : psz_tmp;
}
-static void* update_DownloadReal( vlc_object_t *p_this );
+static void* update_DownloadReal( void * );
/**
* Download the file given in the update_t
@@ -503,7 +499,7 @@ void update_Download( update_t *p_update, const char *psz_destdir )
if( p_update->p_download )
{
vlc_object_kill( p_update->p_download );
- vlc_thread_join( p_update->p_download );
+ vlc_join( p_update->p_download->thread, NULL );
vlc_object_release( p_update->p_download );
}
@@ -517,12 +513,12 @@ 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_thread_create( p_udt, update_DownloadReal, VLC_THREAD_PRIORITY_LOW );
+ vlc_clone( &p_udt->thread, update_DownloadReal, p_udt, VLC_THREAD_PRIORITY_LOW );
}
-static void* update_DownloadReal( vlc_object_t *p_this )
+static void* update_DownloadReal( void *obj )
{
- update_download_thread_t *p_udt = (update_download_thread_t *)p_this;
+ update_download_thread_t *p_udt = (update_download_thread_t *)obj;
dialog_progress_bar_t *p_progress = NULL;
long int l_size;
long int l_downloaded = 0;
diff --git a/src/misc/update.h b/src/misc/update.h
index f00d8be..71032af 100644
--- a/src/misc/update.h
+++ b/src/misc/update.h
@@ -150,6 +150,8 @@ typedef struct public_key_t public_key_t;
typedef struct
{
VLC_COMMON_MEMBERS
+
+ vlc_thread_t thread;
update_t *p_update;
char *psz_destdir;
} update_download_thread_t;
@@ -159,7 +161,8 @@ typedef struct
*/
typedef struct
{
- VLC_COMMON_MEMBERS
+ vlc_thread_t thread;
+
update_t *p_update;
void (*pf_callback)( void *, bool );
void *p_data;
More information about the vlc-commits
mailing list