[vlc-commits] macosx: lock access to addon_entry_t

David Fuhrmann git at videolan.org
Mon May 19 11:41:09 CEST 2014


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun May 18 20:06:54 2014 +0200| [a270b32bb885be4b8196fe2686f0b11655e631ca] | committer: David Fuhrmann

macosx: lock access to addon_entry_t

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

 modules/gui/macosx/AddonListDataSource.h |    2 +-
 modules/gui/macosx/AddonListDataSource.m |   44 ++++++++++++++++++++++++------
 modules/gui/macosx/AddonManager.m        |   14 +++++++---
 3 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/modules/gui/macosx/AddonListDataSource.h b/modules/gui/macosx/AddonListDataSource.h
index efd3fdd..affce6f 100644
--- a/modules/gui/macosx/AddonListDataSource.h
+++ b/modules/gui/macosx/AddonListDataSource.h
@@ -32,7 +32,7 @@
 
 - (id)initWithAddon:(addon_entry_t *)p_entry;
 
-- (uint8_t *)uuid;
+- (NSData *)uuid;
 
 - (NSString *)name;
 - (NSString *)author;
diff --git a/modules/gui/macosx/AddonListDataSource.m b/modules/gui/macosx/AddonListDataSource.m
index f9c3768..aabd182 100644
--- a/modules/gui/macosx/AddonListDataSource.m
+++ b/modules/gui/macosx/AddonListDataSource.m
@@ -43,38 +43,66 @@
     [super dealloc];
 }
 
-- (uint8_t *)uuid
+- (NSData *)uuid
 {
-    return p_addon_entry->uuid;
+    vlc_mutex_lock(&p_addon_entry->lock);
+    NSData *o_uuid = [NSData dataWithBytes:p_addon_entry->uuid length:sizeof(p_addon_entry->uuid)];
+    vlc_mutex_unlock(&p_addon_entry->lock);
+
+    return o_uuid;
 }
 
 - (NSString *)name
 {
-    return toNSStr(p_addon_entry->psz_name);
+    vlc_mutex_lock(&p_addon_entry->lock);
+    NSString *o_str = toNSStr(p_addon_entry->psz_name);
+    vlc_mutex_unlock(&p_addon_entry->lock);
+
+    return o_str;
 }
 - (NSString *)author
 {
-    return toNSStr(p_addon_entry->psz_author);
+    vlc_mutex_lock(&p_addon_entry->lock);
+    NSString *o_str = toNSStr(p_addon_entry->psz_author);
+    vlc_mutex_unlock(&p_addon_entry->lock);
+
+    return o_str;
 }
 
 - (NSString *)version
 {
-    return toNSStr(p_addon_entry->psz_version);
+    vlc_mutex_lock(&p_addon_entry->lock);
+    NSString *o_str = toNSStr(p_addon_entry->psz_version);
+    vlc_mutex_unlock(&p_addon_entry->lock);
+
+    return o_str;
 }
 
 - (NSString *)description
 {
-    return toNSStr(p_addon_entry->psz_description);
+    vlc_mutex_lock(&p_addon_entry->lock);
+    NSString *o_str = toNSStr(p_addon_entry->psz_description);
+    vlc_mutex_unlock(&p_addon_entry->lock);
+
+    return o_str;
 }
 
 - (BOOL)isInstalled
 {
-    return p_addon_entry->e_state == ADDON_INSTALLED;
+    vlc_mutex_lock(&p_addon_entry->lock);
+    BOOL b_installed = p_addon_entry->e_state == ADDON_INSTALLED;
+    vlc_mutex_unlock(&p_addon_entry->lock);
+
+    return b_installed;
 }
 
 - (addon_type_t)type
 {
-    return p_addon_entry->e_type;
+    vlc_mutex_lock(&p_addon_entry->lock);
+    addon_type_t type = p_addon_entry->e_type;
+    vlc_mutex_unlock(&p_addon_entry->lock);
+
+    return type;
 }
 
 @end
diff --git a/modules/gui/macosx/AddonManager.m b/modules/gui/macosx/AddonManager.m
index cdf3481..f7fa9c8 100644
--- a/modules/gui/macosx/AddonManager.m
+++ b/modules/gui/macosx/AddonManager.m
@@ -276,14 +276,20 @@ static VLCAddonManager *_o_sharedInstance = nil;
     addons_manager_LoadCatalog(_manager);
 }
 
-- (void)_installAddonWithID:(addon_uuid_t)addonid
+- (void)_installAddonWithID:(NSData *)o_data
 {
-    addons_manager_Install(_manager, addonid);
+    addon_uuid_t uuid;
+    [o_data getBytes:uuid length:sizeof(uuid)];
+
+    addons_manager_Install(_manager, uuid);
 }
 
-- (void)_removeAddonWithID:(addon_uuid_t)addonid
+- (void)_removeAddonWithID:(NSData *)o_data
 {
-    addons_manager_Remove(_manager, addonid);
+    addon_uuid_t uuid;
+    [o_data getBytes:uuid length:sizeof(uuid)];
+
+    addons_manager_Remove(_manager, uuid);
 }
 
 - (NSString *)_getAddonType:(int)i_type



More information about the vlc-commits mailing list