[vlc-commits] addons: Retrieve: narrow lock

Francois Cartegnie git at videolan.org
Thu Feb 20 22:03:10 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Feb 20 22:01:42 2014 +0100| [9c8e23547069a5390afadbd374a33e5521c1f0d0] | committer: Francois Cartegnie

addons: Retrieve: narrow lock

allows UI updates while downloading

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

 modules/misc/addons/fsstorage.c    |    5 +++--
 modules/misc/addons/vorepository.c |   22 ++++++++++++++++++----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/modules/misc/addons/fsstorage.c b/modules/misc/addons/fsstorage.c
index 6db9077..6bdcacb 100644
--- a/modules/misc/addons/fsstorage.c
+++ b/modules/misc/addons/fsstorage.c
@@ -498,14 +498,15 @@ static int Install( addons_storage_t *p_storage, addon_entry_t *p_entry )
                                       p_entry->psz_source_module, true );
     if( p_module )
     {
-        vlc_mutex_lock( &p_entry->lock );
         if ( p_finder->pf_retrieve( p_finder, p_entry ) == VLC_SUCCESS )
         {
             /* Do things while retrieved data is here */
+            vlc_mutex_lock( &p_entry->lock );
             i_ret = InstallAllFiles( p_storage, p_entry );
+            vlc_mutex_unlock( &p_entry->lock );
             /* !Do things while retrieved data is here */
         }
-        vlc_mutex_unlock( &p_entry->lock );
+
         module_unneed( p_finder, p_module );
     }
 
diff --git a/modules/misc/addons/vorepository.c b/modules/misc/addons/vorepository.c
index 93a7065..4ca010e 100644
--- a/modules/misc/addons/vorepository.c
+++ b/modules/misc/addons/vorepository.c
@@ -347,27 +347,39 @@ static int Find( addons_finder_t *p_finder )
 
 static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
 {
+    vlc_mutex_lock( &p_entry->lock );
     if ( !p_entry->psz_archive_uri )
+    {
+        vlc_mutex_unlock( &p_entry->lock );
         return VLC_EGENERIC;
+    }
+    char *psz_archive_uri = strdup( p_entry->psz_archive_uri );
+    vlc_mutex_unlock( &p_entry->lock );
+    if ( !psz_archive_uri )
+        return VLC_ENOMEM;
 
     /* get archive and parse manifest */
     stream_t *p_stream;
 
-    if ( p_entry->psz_archive_uri[0] == '/' )
+    if ( psz_archive_uri[0] == '/' )
     {
         /* Relative path */
         char *psz_uri;
-        if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"%s", p_entry->psz_archive_uri ) )
+        if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"%s", psz_archive_uri ) )
+        {
+            free( psz_archive_uri );
             return VLC_ENOMEM;
+        }
         p_stream = stream_UrlNew( p_finder, psz_uri );
         free( psz_uri );
     }
     else
     {
-        p_stream = stream_UrlNew( p_finder, p_entry->psz_archive_uri );
+        p_stream = stream_UrlNew( p_finder, psz_archive_uri );
     }
 
-    msg_Dbg( p_finder, "downloading archive %s", p_entry->psz_archive_uri );
+    msg_Dbg( p_finder, "downloading archive %s", psz_archive_uri );
+    free ( psz_archive_uri );
     if ( !p_stream ) return VLC_EGENERIC;
 
     /* In case of pf_ reuse */
@@ -430,8 +442,10 @@ static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
         return VLC_EGENERIC;
     }
 
+    vlc_mutex_lock( &p_entry->lock );
     int i_ret = ( ParseManifest( p_finder, p_entry, psz_tempfileuri, p_stream ) > 0 )
                     ? VLC_SUCCESS : VLC_EGENERIC;
+    vlc_mutex_unlock( &p_entry->lock );
     free( psz_tempfileuri );
     stream_Delete( p_stream );
 



More information about the vlc-commits mailing list