[vlc-devel] commit: macosx/framework: Don't automatically fetch meta, only when asked. (Pierre d'Herbemont )

git version control git at videolan.org
Fri Dec 11 16:20:32 CET 2009


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Fri Dec 11 16:17:33 2009 +0100| [bfc6b198c0352fd87636563af135dcd645b929bd] | committer: Pierre d'Herbemont 

macosx/framework: Don't automatically fetch meta, only when asked.

This saves some precious memory if we don't browse them.

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

 .../macosx/framework/Headers/Public/VLCMedia.h     |    3 ++-
 projects/macosx/framework/Sources/VLCMedia.m       |   18 ++++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/projects/macosx/framework/Headers/Public/VLCMedia.h b/projects/macosx/framework/Headers/Public/VLCMedia.h
index 6293ffc..0302758 100644
--- a/projects/macosx/framework/Headers/Public/VLCMedia.h
+++ b/projects/macosx/framework/Headers/Public/VLCMedia.h
@@ -113,7 +113,8 @@ typedef enum VLCMediaState
     VLCTime *             length;            //< Cached duration of the media
     NSMutableDictionary * metaDictionary;    //< Meta data storage
     id                    delegate;          //< Delegate object
-    BOOL                  artFetched;        //< Value used to determine of the artwork has been preparsed
+    BOOL                  isArtFetched;      //< Value used to determine of the artwork has been preparsed
+    BOOL                  areOthersMetaFetched; //< Value used to determine of the other meta has been preparsed
     VLCMediaState         state;             //< Current state of the media
 }
 
diff --git a/projects/macosx/framework/Sources/VLCMedia.m b/projects/macosx/framework/Sources/VLCMedia.m
index f22fb6f..11a0f33 100644
--- a/projects/macosx/framework/Sources/VLCMedia.m
+++ b/projects/macosx/framework/Sources/VLCMedia.m
@@ -428,8 +428,6 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
     libvlc_exception_t ex;
     libvlc_exception_init( &ex );
 
-    artFetched = NO;
-
     char * p_url = libvlc_media_get_mrl( p_md );
 
     url = [[NSURL URLWithString:[NSString stringWithUTF8String:p_url]] retain];
@@ -456,10 +454,6 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
     }
 
     state = LibVLCStateToMediaState(libvlc_media_get_state( p_md ));
-
-    /* Force VLCMetaInformationTitle, that will trigger preparsing
-     * And all the other meta will be added through the libvlc event system */
-    [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationTitle];
 }
 
 - (void)fetchMetaInformationFromLibVLCWithType:(NSString *)metaType
@@ -542,12 +536,20 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
 
 - (id)valueForKeyPath:(NSString *)keyPath
 {
-    if( !artFetched && [keyPath isEqualToString:@"metaDictionary.artwork"])
+    if( !isArtFetched && [keyPath isEqualToString:@"metaDictionary.artwork"])
     {
-        artFetched = YES;
+        isArtFetched = YES;
         /* Force the retrieval of the artwork now that someone asked for it */
         [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationArtworkURL];
     }
+    else if( !areOthersMetaFetched && [keyPath hasPrefix:@"metaDictionary."])
+    {
+        areOthersMetaFetched = YES;
+        /* Force VLCMetaInformationTitle, that will trigger preparsing
+         * And all the other meta will be added through the libvlc event system */
+        [self fetchMetaInformationFromLibVLCWithType: VLCMetaInformationTitle];
+    }
+
     return [super valueForKeyPath:keyPath];
 }
 @end




More information about the vlc-devel mailing list