[vlc-commits] addons: use predicate on finder thread
Francois Cartegnie
git at videolan.org
Fri Feb 21 15:20:40 CET 2014
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 21 01:29:30 2014 +0100| [fa3433e3c175200585de3f5773114a20e2346c3b] | committer: Francois Cartegnie
addons: use predicate on finder thread
changes use of null uri
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fa3433e3c175200585de3f5773114a20e2346c3b
---
modules/gui/macosx/AddonManager.m | 4 +--
modules/gui/qt4/managers/addons_manager.cpp | 2 +-
modules/misc/addons/vorepository.c | 6 ++--
src/misc/addons.c | 52 +++++++++++++++------------
4 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/modules/gui/macosx/AddonManager.m b/modules/gui/macosx/AddonManager.m
index 1637d30..fa3bc95 100644
--- a/modules/gui/macosx/AddonManager.m
+++ b/modules/gui/macosx/AddonManager.m
@@ -279,7 +279,7 @@ static VLCAddonManager *_o_sharedInstance = nil;
- (void)_findNewAddons
{
[_spinner startAnimation:nil];
- addons_manager_Gather(_manager, NULL);
+ addons_manager_Gather(_manager, "repo://");
}
/* FIXME: un-used */
@@ -321,4 +321,4 @@ static VLCAddonManager *_o_sharedInstance = nil;
}
}
- at end
\ No newline at end of file
+ at end
diff --git a/modules/gui/qt4/managers/addons_manager.cpp b/modules/gui/qt4/managers/addons_manager.cpp
index d0ae3ef..7449acc 100644
--- a/modules/gui/qt4/managers/addons_manager.cpp
+++ b/modules/gui/qt4/managers/addons_manager.cpp
@@ -47,7 +47,7 @@ AddonsManager::~AddonsManager()
void AddonsManager::findNewAddons()
{
- addons_manager_Gather( p_manager, NULL );
+ addons_manager_Gather( p_manager, "repo://" );
}
void AddonsManager::findDesignatedAddon( QString uri )
diff --git a/modules/misc/addons/vorepository.c b/modules/misc/addons/vorepository.c
index 4ca010e..21800f4 100644
--- a/modules/misc/addons/vorepository.c
+++ b/modules/misc/addons/vorepository.c
@@ -492,8 +492,10 @@ static int Open(vlc_object_t *p_this)
if ( !p_finder->p_sys )
return VLC_ENOMEM;
p_finder->p_sys->psz_tempfile = NULL;
- /* We only support listing the whole repo */
- if ( p_finder->psz_uri )
+
+ if ( p_finder->psz_uri &&
+ strcmp( "repo://"ADDONS_MODULE_SHORTCUT, p_finder->psz_uri ) &&
+ memcmp( "repo://", p_finder->psz_uri, 8 ) )
return VLC_EGENERIC;
p_finder->pf_find = Find;
diff --git a/src/misc/addons.c b/src/misc/addons.c
index bd45be1..c42d42d 100644
--- a/src/misc/addons.c
+++ b/src/misc/addons.c
@@ -51,7 +51,7 @@ struct addons_manager_private_t
vlc_cond_t waitcond;
bool b_live;
vlc_mutex_t lock;
- char *psz_uri_hint; /* uri hint for non repo based install */
+ DECL_ARRAY(char*) uris;
DECL_ARRAY(addon_entry_t*) entries;
} finder;
@@ -154,7 +154,7 @@ addons_manager_t *addons_manager_New( vlc_object_t *p_this )
INIT_QUEUE( finder )
INIT_QUEUE( installer )
- p_manager->p_priv->finder.psz_uri_hint = NULL;
+ ARRAY_INIT( p_manager->p_priv->finder.uris );
vlc_event_manager_t *em = p_manager->p_event_manager;
vlc_event_manager_init( em, p_manager );
@@ -201,7 +201,10 @@ void addons_manager_Delete( addons_manager_t *p_manager )
FREE_QUEUE( finder )
FREE_QUEUE( installer )
- free( p_manager->p_priv->finder.psz_uri_hint );
+ FOREACH_ARRAY( char *psz_uri, p_manager->p_priv->finder.uris )
+ free( psz_uri );
+ FOREACH_END();
+ ARRAY_RESET( p_manager->p_priv->finder.uris );
free( p_manager->p_priv );
free( p_manager->p_event_manager );
@@ -210,11 +213,13 @@ void addons_manager_Delete( addons_manager_t *p_manager )
void addons_manager_Gather( addons_manager_t *p_manager, const char *psz_uri )
{
+ if ( !psz_uri )
+ return;
+
vlc_mutex_lock( &p_manager->p_priv->finder.lock );
- if ( psz_uri )
- {
- p_manager->p_priv->finder.psz_uri_hint = strdup( psz_uri );
- }
+
+ ARRAY_APPEND( p_manager->p_priv->finder.uris, strdup( psz_uri ) );
+
if( !p_manager->p_priv->finder.b_live )
{
if( vlc_clone( &p_manager->p_priv->finder.thread, FinderThread, p_manager,
@@ -226,13 +231,10 @@ void addons_manager_Gather( addons_manager_t *p_manager, const char *psz_uri )
return;
}
p_manager->p_priv->finder.b_live = true;
- vlc_mutex_unlock( &p_manager->p_priv->finder.lock );
- }
- else
- {
- vlc_mutex_unlock( &p_manager->p_priv->finder.lock );
- vlc_cond_signal( &p_manager->p_priv->finder.waitcond );
}
+
+ vlc_mutex_unlock( &p_manager->p_priv->finder.lock );
+ vlc_cond_signal( &p_manager->p_priv->finder.waitcond );
}
/*****************************************************************************
@@ -305,6 +307,7 @@ static void LoadLocalStorage( addons_manager_t *p_manager )
if( p_module )
{
ARRAY_INIT( p_finder->entries );
+ p_finder->psz_uri = NULL;
p_finder->pf_find( p_finder );
module_unneed( p_finder, p_module );
@@ -319,9 +322,21 @@ static void *FinderThread( void *p_data )
{
addons_manager_t *p_manager = p_data;
int i_cancel;
+ char *psz_uri;
for( ;; )
{
+ vlc_mutex_lock( &p_manager->p_priv->finder.lock );
+ vlc_cleanup_push( vlc_mutex_unlock, &p_manager->p_priv->finder.lock );
+ while( p_manager->p_priv->finder.uris.i_size == 0 )
+ {
+ vlc_cond_wait( &p_manager->p_priv->finder.waitcond,
+ &p_manager->p_priv->finder.lock );
+ }
+ psz_uri = p_manager->p_priv->finder.uris.p_elems[0];
+ ARRAY_REMOVE( p_manager->p_priv->finder.uris, 0 );
+ vlc_cleanup_run();
+
addons_finder_t *p_finder =
vlc_custom_create( p_manager->p_priv->p_parent, sizeof( *p_finder ), "entries finder" );
@@ -331,8 +346,7 @@ static void *FinderThread( void *p_data )
module_t *p_module;
ARRAY_INIT( p_finder->entries );
vlc_mutex_lock( &p_manager->p_priv->finder.lock );
- p_finder->psz_uri = p_manager->p_priv->finder.psz_uri_hint;
- p_manager->p_priv->finder.psz_uri_hint = NULL;
+ p_finder->psz_uri = psz_uri;
vlc_mutex_unlock( &p_manager->p_priv->finder.lock );
p_module = module_need( p_finder, "addons finder", NULL, false );
@@ -343,7 +357,7 @@ static void *FinderThread( void *p_data )
MergeSources( p_manager, p_finder->entries.p_elems, p_finder->entries.i_size );
}
ARRAY_RESET( p_finder->entries );
- free( p_finder->psz_uri );
+ free( psz_uri );
vlc_object_release( p_finder );
}
@@ -354,12 +368,6 @@ static void *FinderThread( void *p_data )
vlc_restorecancel( i_cancel );
vlc_testcancel();
-
- vlc_mutex_lock( &p_manager->p_priv->finder.lock );
- vlc_cleanup_push( vlc_mutex_unlock, &p_manager->p_priv->finder.lock );
- vlc_cond_wait( &p_manager->p_priv->finder.waitcond,
- &p_manager->p_priv->finder.lock );
- vlc_cleanup_run();
}
return NULL;
More information about the vlc-commits
mailing list