[vlc-devel] [PATCH 12/13] VLCKit: migrate VLCMedia to ARC

Florent Pillet fpillet at gmail.com
Mon Jul 7 12:41:27 CEST 2014


---
 Headers/Public/VLCMedia.h |  20 ++--
 Sources/VLCMedia.m        | 292 ++++++++++++++++++++--------------------------
 2 files changed, 136 insertions(+), 176 deletions(-)

diff --git a/Headers/Public/VLCMedia.h b/Headers/Public/VLCMedia.h
index 1145065..234c88a 100644
--- a/Headers/Public/VLCMedia.h
+++ b/Headers/Public/VLCMedia.h
@@ -124,15 +124,9 @@ typedef NSInteger VLCMediaState;
 @interface VLCMedia : NSObject
 {
     void *                p_md;              //< Internal media descriptor instance
-    NSURL *               url;               //< URL (MRL) for this media resource
-    VLCMediaList *        subitems;          //< Sub list of items
-    VLCTime *             length;            //< Cached duration of the media
-    NSMutableDictionary * metaDictionary;    //< Meta data storage
-    id                    __weak delegate;          //< Delegate object
     BOOL                  isArtFetched;      //< Value used to determine of the artwork has been parsed
     BOOL                  areOthersMetaFetched; //< Value used to determine of the other meta has been parsed
     BOOL                  isArtURLFetched;   //< Value used to determine of the other meta has been preparsed
-    VLCMediaState         state;             //< Current state of the media
     BOOL                  isParsed;
 }
 
@@ -199,14 +193,14 @@ typedef NSInteger VLCMediaState;
 /**
  * Receiver's delegate.
  */
- at property (weak) id delegate;
+ at property (nonatomic, weak) id delegate;
 
 /**
  * A VLCTime object describing the length of the media resource, only if it is
  * available.  Use lengthWaitUntilDate: to wait for a specified length of time.
  * \see lengthWaitUntilDate
  */
- at property (readonly) VLCTime * length;
+ at property (nonatomic, readonly, strong) VLCTime * length;
 
 /**
  * Returns a VLCTime object describing the length of the media resource,
@@ -221,17 +215,17 @@ typedef NSInteger VLCMediaState;
 /**
  * Determines if the media has already been preparsed.
  */
- at property (readonly) BOOL isParsed;
+ at property (nonatomic, readonly) BOOL isParsed;
 
 /**
  * The URL for the receiver's media resource.
  */
- at property (readonly) NSURL * url;
+ at property (nonatomic, readonly, strong) NSURL * url;
 
 /**
  * The receiver's sub list.
  */
- at property (readonly) VLCMediaList * subitems;
+ at property (nonatomic, readonly, strong) VLCMediaList * subitems;
 
 /**
  * get meta property for key
@@ -258,12 +252,12 @@ typedef NSInteger VLCMediaState;
 /**
  * The receiver's meta data as a NSDictionary object.
  */
- at property (readonly) NSDictionary * metaDictionary;
+ at property (nonatomic, readonly, strong) NSDictionary * metaDictionary;
 
 /**
  * The receiver's state, such as Playing, Error, NothingSpecial, Buffering.
  */
- at property (readonly) VLCMediaState state;
+ at property (nonatomic, readonly) VLCMediaState state;
 
 /**
  * returns a bool whether is the media is expected to play fluently on this
diff --git a/Sources/VLCMedia.m b/Sources/VLCMedia.m
index 49e56a1..3f1f8dc 100644
--- a/Sources/VLCMedia.m
+++ b/Sources/VLCMedia.m
@@ -56,17 +56,16 @@ NSString *const VLCMetaInformationTrackID        = @"trackID";
 NSString *const VLCMediaMetaChanged              = @"VLCMediaMetaChanged";
 
 /******************************************************************************
- * @property (readwrite)
+ * VLCMedia ()
  */
 @interface VLCMedia ()
- at property (readwrite) VLCMediaState state;
- at end
 
-/******************************************************************************
- * Interface (Private)
- */
-// TODO: Documentation
- at interface VLCMedia (Private)
+/* Make our properties internally readwrite */
+ at property (nonatomic, readwrite) VLCMediaState state;
+ at property (nonatomic, readwrite, strong) VLCTime *length;
+ at property (nonatomic, readwrite, strong) NSDictionary *metaDictionary;
+ at property (nonatomic, readwrite, strong) VLCMediaList * subitems;
+
 /* Statics */
 + (libvlc_meta_t)stringToMetaType:(NSString *)string;
 + (NSString *)metaTypeToString:(libvlc_meta_t)type;
@@ -88,6 +87,7 @@ NSString *const VLCMediaMetaChanged              = @"VLCMediaMetaChanged";
 - (void)metaChanged:(NSString *)metaType;
 - (void)subItemAdded;
 - (void)setStateAsNumber:(NSNumber *)newStateAsNumber;
+
 @end
 
 static VLCMediaState libvlc_state_to_media_state[] =
@@ -122,7 +122,6 @@ static void HandleMediaMetaChanged(const libvlc_event_t * event, void * self)
 static void HandleMediaDurationChanged(const libvlc_event_t * event, void * self)
 {
     @autoreleasepool {
-
         [[VLCEventManager sharedManager] callOnMainThreadObject:(__bridge id)(self)
                                                      withMethod:@selector(setLength:)
                                            withArgumentAsObject:[VLCTime timeWithNumber:
@@ -133,7 +132,6 @@ static void HandleMediaDurationChanged(const libvlc_event_t * event, void * self
 static void HandleMediaStateChanged(const libvlc_event_t * event, void * self)
 {
     @autoreleasepool {
-
         [[VLCEventManager sharedManager] callOnMainThreadObject:(__bridge id)(self)
                                                      withMethod:@selector(setStateAsNumber:)
                                            withArgumentAsObject:@(LibVLCStateToMediaState(event->u.media_state_changed.new_state))];
@@ -163,6 +161,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
  * Implementation
  */
 @implementation VLCMedia
+
 + (id)mediaWithURL:(NSURL *)anURL;
 {
     return [[VLCMedia alloc] initWithURL:anURL];
@@ -191,12 +190,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
 
         p_md = libvlc_media_new_location(library.instance, [[anURL absoluteString] UTF8String]);
 
-        delegate = nil;
-        metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3];
-
-        // This value is set whenever the demuxer figures out what the length is.
-        // TODO: Easy way to tell the length of the movie without having to instiate the demuxer.  Maybe cached info?
-        length = nil;
+        _metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3];
 
         [self initInternalMediaDescriptor];
     }
@@ -206,15 +200,9 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
 - (id)initAsNodeWithName:(NSString *)aName
 {
     if (self = [super init]) {
-        p_md = libvlc_media_new_as_node([VLCLibrary sharedInstance],
-                                                   [aName UTF8String]);
-
-        delegate = nil;
-        metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3];
+        p_md = libvlc_media_new_as_node([VLCLibrary sharedInstance], [aName UTF8String]);
 
-        // This value is set whenever the demuxer figures out what the length is.
-        // TODO: Easy way to tell the length of the movie without having to instiate the demuxer.  Maybe cached info?
-        length = nil;
+        _metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3];
 
         [self initInternalMediaDescriptor];
     }
@@ -229,11 +217,8 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
     libvlc_event_detach(p_em, libvlc_MediaStateChanged,    HandleMediaStateChanged,    (__bridge void *)(self));
     libvlc_event_detach(p_em, libvlc_MediaSubItemAdded,    HandleMediaSubItemAdded,    (__bridge void *)(self));
     libvlc_event_detach(p_em, libvlc_MediaParsedChanged,   HandleMediaParsedChanged,   (__bridge void *)(self));
-    [[VLCEventManager sharedManager] cancelCallToObject:self];
 
-    // Testing to see if the pointer exists is not required, if the pointer is null
-    // then the release message is not sent to it.
-    delegate = nil;
+    [[VLCEventManager sharedManager] cancelCallToObject:self];
 
     libvlc_media_release( p_md );
 
@@ -241,8 +226,8 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
 
 - (NSString *)description
 {
-    NSString * result = metaDictionary[VLCMetaInformationTitle];
-    return [NSString stringWithFormat:@"<%@ %p> %@", [self class], self, (result ? result : [url absoluteString])];
+    NSString * result = _metaDictionary[VLCMetaInformationTitle];
+    return [NSString stringWithFormat:@"<%@ %p> %@", [self class], self, (result ? result : [_url absoluteString])];
 }
 
 - (NSComparisonResult)compare:(VLCMedia *)media
@@ -254,42 +239,38 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
     return p_md == [media libVLCMediaDescriptor] ? NSOrderedSame : NSOrderedAscending;
 }
 
- at synthesize delegate;
-
 - (VLCTime *)length
 {
-    if (!length) {
+    if (!_length) {
         // Try figuring out what the length is
         long long duration = libvlc_media_get_duration( p_md );
-        if (duration > -1) {
-            length = [VLCTime timeWithNumber:@(duration)];
-            return length;
-        }
-        return [VLCTime nullTime];
+        if (duration < 0)
+            return [VLCTime nullTime];
+         _length = [VLCTime timeWithNumber:@(duration)];
     }
-    return length;
+    return _length;
 }
 
 - (VLCTime *)lengthWaitUntilDate:(NSDate *)aDate
 {
     static const long long thread_sleep = 10000;
 
-    if (!length) {
+    if (!_length) {
         // Force parsing of this item.
         [self parseIfNeeded];
 
         // wait until we are preparsed
-        while (!length && !libvlc_media_is_parsed(p_md) && [aDate timeIntervalSinceNow] > 0)
+        while (!_length && !libvlc_media_is_parsed(p_md) && [aDate timeIntervalSinceNow] > 0)
             usleep( thread_sleep );
 
         // So we're done waiting, but sometimes we trap the fact that the parsing
         // was done before the length gets assigned, so lets go ahead and assign
         // it ourselves.
-        if (!length)
+        if (!_length)
             return [self length];
     }
 
-    return length;
+    return _length;
 }
 
 - (BOOL)isParsed
@@ -312,12 +293,12 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
 - (void)addOptions:(NSDictionary*)options
 {
     if (p_md) {
-        for (NSString * key in [options allKeys]) {
-            if (options[key] != [NSNull null])
-                libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, options[key]] UTF8String]);
+        [options enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
+            if (![obj isKindOfClass:[NSNull class]])
+                libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, obj] UTF8String]);
             else
-                libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@", key] UTF8String]);
-        }
+                libvlc_media_add_option(p_md, [key UTF8String]);
+        }];
     }
 }
 
@@ -326,27 +307,26 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
     if (!p_md)
         return NULL;
 
-    NSMutableDictionary *d = [NSMutableDictionary dictionary];
     libvlc_media_stats_t p_stats;
     libvlc_media_get_stats(p_md, &p_stats);
 
-    d[@"demuxBitrate"] = @(p_stats.f_demux_bitrate);
-    d[@"inputBitrate"] = @(p_stats.f_input_bitrate);
-    d[@"sendBitrate"] = @(p_stats.f_send_bitrate);
-    d[@"decodedAudio"] = @(p_stats.i_decoded_audio);
-    d[@"decodedVideo"] = @(p_stats.i_decoded_video);
-    d[@"demuxCorrupted"] = @(p_stats.i_demux_corrupted);
-    d[@"demuxDiscontinuity"] = @(p_stats.i_demux_discontinuity);
-    d[@"demuxReadBytes"] = @(p_stats.i_demux_read_bytes);
-    d[@"displayedPictures"] = @(p_stats.i_displayed_pictures);
-    d[@"lostAbuffers"] = @(p_stats.i_lost_abuffers);
-    d[@"lostPictures"] = @(p_stats.i_lost_pictures);
-    d[@"playedAbuffers"] = @(p_stats.i_played_abuffers);
-    d[@"readBytes"] = @(p_stats.i_read_bytes);
-    d[@"sentBytes"] = @(p_stats.i_sent_bytes);
-    d[@"sentPackets"] = @(p_stats.i_sent_packets);
-
-    return d;
+    return @{
+        @"demuxBitrate" : @(p_stats.f_demux_bitrate),
+        @"inputBitrate" : @(p_stats.f_input_bitrate),
+        @"sendBitrate" : @(p_stats.f_send_bitrate),
+        @"decodedAudio" : @(p_stats.i_decoded_audio),
+        @"decodedVideo" : @(p_stats.i_decoded_video),
+        @"demuxCorrupted" : @(p_stats.i_demux_corrupted),
+        @"demuxDiscontinuity" : @(p_stats.i_demux_discontinuity),
+        @"demuxReadBytes" : @(p_stats.i_demux_read_bytes),
+        @"displayedPictures" : @(p_stats.i_displayed_pictures),
+        @"lostAbuffers" : @(p_stats.i_lost_abuffers),
+        @"lostPictures" : @(p_stats.i_lost_pictures),
+        @"playedAbuffers" : @(p_stats.i_played_abuffers),
+        @"readBytes" : @(p_stats.i_read_bytes),
+        @"sentBytes" : @(p_stats.i_sent_bytes),
+        @"sentPackets" : @(p_stats.i_sent_packets)
+    };
 }
 
 - (NSInteger)numberOfReadBytesOnInput
@@ -656,10 +636,6 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
     return YES;
 }
 
- at synthesize url;
- at synthesize subitems;
-
-
 - (NSString *)metadataForKey:(NSString *)key
 {
     if (!p_md)
@@ -690,64 +666,14 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
 - (BOOL)saveMetadata
 {
     if (p_md)
-        return libvlc_media_save_meta(p_md);
+        return libvlc_media_save_meta(p_md) != 0;
 
     return NO;
 }
 
- at synthesize metaDictionary;
- at synthesize state;
-
- at end
-
 /******************************************************************************
- * Implementation VLCMedia (LibVLCBridging)
+ * Implementation VLCMedia ()
  */
- at implementation VLCMedia (LibVLCBridging)
-
-+ (id)mediaWithLibVLCMediaDescriptor:(void *)md
-{
-    return [[VLCMedia alloc] initWithLibVLCMediaDescriptor:md];
-}
-
-- (id)initWithLibVLCMediaDescriptor:(void *)md
-{
-    if (self = [super init]) {
-        libvlc_media_retain(md);
-        p_md = md;
-
-        metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3];
-        [self initInternalMediaDescriptor];
-    }
-    return self;
-}
-
-- (void *)libVLCMediaDescriptor
-{
-    return p_md;
-}
-
-+ (id)mediaWithMedia:(VLCMedia *)media andLibVLCOptions:(NSDictionary *)options
-{
-    libvlc_media_t * p_md;
-    p_md = libvlc_media_duplicate([media libVLCMediaDescriptor]);
-
-    for (NSString * key in [options allKeys]) {
-        if (options[key] != [NSNull null])
-            libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, options[key]] UTF8String]);
-        else
-            libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@", key] UTF8String]);
-
-    }
-    return [VLCMedia mediaWithLibVLCMediaDescriptor:p_md];
-}
-
- at end
-
-/******************************************************************************
- * Implementation VLCMedia (Private)
- */
- at implementation VLCMedia (Private)
 
 + (libvlc_meta_t)stringToMetaType:(NSString *)string
 {
@@ -777,7 +703,7 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
 #undef VLCStringToMeta
     }
     NSNumber * number = stringToMetaDictionary[string];
-    return number ? [number intValue] : -1;
+    return (libvlc_meta_t) (number ? [number intValue] : -1);
 }
 
 + (NSString *)metaTypeToString:(libvlc_meta_t)type
@@ -809,9 +735,9 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
     if (!p_url)
         return;
 
-    url = [NSURL URLWithString:@(p_url)];
-    if (!url) /* Attempt to interpret as a file path then */
-        url = [NSURL fileURLWithPath:@(p_url)];
+    _url = [NSURL URLWithString:@(p_url)];
+    if (!_url) /* Attempt to interpret as a file path then */
+        _url = [NSURL fileURLWithPath:@(p_url)];
     free(p_url);
 
     libvlc_media_set_user_data(p_md, (__bridge void*)self);
@@ -825,22 +751,20 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
 
     libvlc_media_list_t * p_mlist = libvlc_media_subitems( p_md );
 
-    if (!p_mlist)
-        subitems = nil;
-    else {
-        subitems = [VLCMediaList mediaListWithLibVLCMediaList:p_mlist];
+    if (p_mlist) {
+        self.subitems = [VLCMediaList mediaListWithLibVLCMediaList:p_mlist];
         libvlc_media_list_release( p_mlist );
     }
 
-    isParsed = libvlc_media_is_parsed(p_md);
-    state = LibVLCStateToMediaState(libvlc_media_get_state( p_md ));
+    isParsed = libvlc_media_is_parsed(p_md) != 0;
+    self.state = LibVLCStateToMediaState(libvlc_media_get_state( p_md ));
 }
 
 - (void)fetchMetaInformationFromLibVLCWithType:(NSString *)metaType
 {
     char * psz_value = libvlc_media_get_meta( p_md, [VLCMedia stringToMetaType:metaType] );
     NSString * newValue = psz_value ? @(psz_value) : nil;
-    NSString * oldValue = [metaDictionary valueForKey:metaType];
+    NSString * oldValue = [_metaDictionary valueForKey:metaType];
     free(psz_value);
 
     if (newValue != oldValue && !(oldValue && newValue && [oldValue compare:newValue] == NSOrderedSame)) {
@@ -851,38 +775,35 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
                                        withObject:newValue];
         }
 
-        [metaDictionary setValue:newValue forKeyPath:metaType];
+        [_metaDictionary setValue:newValue forKeyPath:metaType];
     }
 }
 
 #if !TARGET_OS_IPHONE
 - (void)fetchMetaInformationForArtWorkWithURL:(NSString *)anURL
 {
-    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-    NSImage * art = nil;
+    @autoreleasepool {
+        NSImage * art = nil;
+
+        if (anURL) {
+            // Go ahead and load up the art work
+            NSURL * artUrl = [NSURL URLWithString:[anURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+            // Don't attempt to fetch artwork from remote. Core will do that alone
+            if ([artUrl isFileURL])
+                art  = [[NSImage alloc] initWithContentsOfURL:artUrl];
+        }
 
-    if (anURL) {
-        // Go ahead and load up the art work
-        NSURL * artUrl = [NSURL URLWithString:[anURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
-        // Don't attempt to fetch artwork from remote. Core will do that alone
-        if ([artUrl isFileURL])
-            art  = [[[NSImage alloc] initWithContentsOfURL:artUrl] autorelease];
+        // If anything was found, lets save it to the meta data dictionary
+        [self performSelectorOnMainThread:@selector(setArtwork:) withObject:art waitUntilDone:NO];
     }
-
-    // If anything was found, lets save it to the meta data dictionary
-    [self performSelectorOnMainThread:@selector(setArtwork:) withObject:art waitUntilDone:NO];
-
-    [pool release];
 }
 
 - (void)setArtwork:(NSImage *)art
 {
-    if (!art) {
-        [metaDictionary removeObjectForKey:@"artwork"];
-        return;
-    }
-
-    [metaDictionary setObject:art forKey:@"artwork"];
+    if (!art)
+        [(NSMutableDictionary *)_metaDictionary removeObjectForKey:@"artwork"];
+    else
+        [(NSMutableDictionary *)_metaDictionary setObject:art forKey:@"artwork"];
 }
 #endif
 
@@ -896,22 +817,21 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
 {
     [self fetchMetaInformationFromLibVLCWithType:metaType];
 
-    if ([delegate respondsToSelector:@selector(mediaMetaDataDidChange:)])
-        [self.delegate mediaMetaDataDidChange:self];
+    if ([_delegate respondsToSelector:@selector(mediaMetaDataDidChange:)])
+        [_delegate mediaMetaDataDidChange:self];
 }
 
 - (void)subItemAdded
 {
-    if (subitems)
+    if (_subitems)
         return; /* Nothing to do */
 
     libvlc_media_list_t * p_mlist = libvlc_media_subitems( p_md );
 
     NSAssert( p_mlist, @"The mlist shouldn't be nil, we are receiving a subItemAdded");
 
-    [self willChangeValueForKey:@"subitems"];
-    subitems = [VLCMediaList mediaListWithLibVLCMediaList:p_mlist];
-    [self didChangeValueForKey:@"subitems"];
+    self.subitems = [VLCMediaList mediaListWithLibVLCMediaList:p_mlist];
+
     libvlc_media_list_release( p_mlist );
 }
 
@@ -922,11 +842,11 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
     [self didChangeValueForKey:@"parsed"];
 
     // FIXME: Probably don't even call this if there is no delegate.
-    if (!delegate || !isParsed)
+    if (!_delegate || !isParsed)
         return;
 
-    if ([delegate respondsToSelector:@selector(mediaDidFinishParsing:)])
-        [delegate mediaDidFinishParsing:self];
+    if ([_delegate respondsToSelector:@selector(mediaDidFinishParsing:)])
+        [_delegate mediaDidFinishParsing:self];
 }
 
 - (void)setStateAsNumber:(NSNumber *)newStateAsNumber
@@ -982,6 +902,51 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
 @end
 
 /******************************************************************************
+ * Implementation VLCMedia (LibVLCBridging)
+ */
+ at implementation VLCMedia (LibVLCBridging)
+
++ (id)mediaWithLibVLCMediaDescriptor:(void *)md
+{
+    return [[VLCMedia alloc] initWithLibVLCMediaDescriptor:md];
+}
+
+- (id)initWithLibVLCMediaDescriptor:(void *)md
+{
+    if (self = [super init]) {
+        libvlc_media_retain(md);
+        p_md = md;
+
+        self.metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3];
+
+        [self initInternalMediaDescriptor];
+    }
+    return self;
+}
+
+- (void *)libVLCMediaDescriptor
+{
+    return p_md;
+}
+
++ (id)mediaWithMedia:(VLCMedia *)media andLibVLCOptions:(NSDictionary *)options
+{
+    libvlc_media_t * p_md;
+    p_md = libvlc_media_duplicate([media libVLCMediaDescriptor]);
+
+    for (NSString * key in [options allKeys]) {
+        if (options[key] != [NSNull null])
+            libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, options[key]] UTF8String]);
+        else
+            libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@", key] UTF8String]);
+
+    }
+    return [VLCMedia mediaWithLibVLCMediaDescriptor:p_md];
+}
+
+ at end
+
+/******************************************************************************
  * Implementation VLCMedia (VLCMediaPlayerBridging)
  */
 
@@ -989,10 +954,11 @@ NSString *const VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
 
 - (void)setLength:(VLCTime *)value
 {
+    VLCTime *length = _length;
     if (length && value && [length compare:value] == NSOrderedSame)
         return;
 
-    length = value ? value : nil;
+    _length = value;
 }
 
 @end
-- 
1.8.5.2 (Apple Git-48)




More information about the vlc-devel mailing list