Commit 1c45e0b2 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCMedia.m: Speed a bit stringToMetaType.

parent 8b583911
...@@ -296,27 +296,37 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self) ...@@ -296,27 +296,37 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
* Implementation VLCMedia (Private) * Implementation VLCMedia (Private)
*/ */
@implementation VLCMedia (Private) @implementation VLCMedia (Private)
+ (libvlc_meta_t)stringToMetaType:(NSString *)string + (libvlc_meta_t)stringToMetaType:(NSString *)string
{ {
#define VLCStringToMeta( name, string ) if ([VLCMetaInformation##name compare:string] == NSOrderedSame) return libvlc_meta_##name; static NSDictionary * stringToMetaDictionary = nil;
VLCStringToMeta(Title, string); // TODO: Thread safe-ize
VLCStringToMeta(Artist, string); if( !stringToMetaDictionary )
VLCStringToMeta(Genre, string); {
VLCStringToMeta(Copyright, string); #define VLCStringToMeta( name ) [NSNumber numberWithInt: libvlc_meta_##name], VLCMetaInformation##name
VLCStringToMeta(Album, string); stringToMetaDictionary =
VLCStringToMeta(TrackNumber, string); [[NSDictionary dictionaryWithObjectsAndKeys:
VLCStringToMeta(Description, string); VLCStringToMeta(Title),
VLCStringToMeta(Rating, string); VLCStringToMeta(Artist),
VLCStringToMeta(Date, string); VLCStringToMeta(Genre),
VLCStringToMeta(Setting, string); VLCStringToMeta(Copyright),
VLCStringToMeta(URL, string); VLCStringToMeta(Album),
VLCStringToMeta(Language, string); VLCStringToMeta(TrackNumber),
VLCStringToMeta(NowPlaying, string); VLCStringToMeta(Description),
VLCStringToMeta(Publisher, string); VLCStringToMeta(Rating),
VLCStringToMeta(ArtworkURL, string); VLCStringToMeta(Date),
VLCStringToMeta(TrackID, string); VLCStringToMeta(Setting),
VLCStringToMeta(URL),
VLCStringToMeta(Language),
VLCStringToMeta(NowPlaying),
VLCStringToMeta(Publisher),
VLCStringToMeta(ArtworkURL),
VLCStringToMeta(TrackID),
nil] retain];
#undef VLCStringToMeta #undef VLCStringToMeta
return -1; }
NSNumber * number = [stringToMetaDictionary objectForKey:string];
return number ? [number intValue] : -1;
} }
+ (NSString *)metaTypeToString:(libvlc_meta_t)type + (NSString *)metaTypeToString:(libvlc_meta_t)type
...@@ -387,9 +397,7 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self) ...@@ -387,9 +397,7 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
return; return;
} }
@synchronized(metaDictionary) { [metaDictionary setValue:newValue forKeyPath:metaType];
[metaDictionary setValue:newValue forKeyPath:metaType];
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment