Browse Source

VLCMediaPlayer: avoid retain cycle by weakifying delegate

Gleb Pinigin 11 years ago
parent
commit
71db8d5ab7
2 changed files with 1 additions and 17 deletions
  1. 1 4
      Headers/Public/VLCMediaPlayer.h
  2. 0 13
      Sources/VLCMediaPlayer.m

+ 1 - 4
Headers/Public/VLCMediaPlayer.h

@@ -93,6 +93,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
 @interface VLCMediaPlayer : NSObject
 
 @property (readonly) VLCLibrary *libraryInstance;
+@property (weak) id<VLCMediaPlayerDelegate> delegate;
 
 #if !TARGET_OS_IPHONE
 /* Initializers */
@@ -101,10 +102,6 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
 #endif
 - (id)initWithOptions:(NSArray *)options;
 
-/* Properties */
-- (void)setDelegate:(id)value;
-- (id)delegate;
-
 /* Video View Options */
 // TODO: Should be it's own object?
 

+ 0 - 13
Sources/VLCMediaPlayer.m

@@ -150,7 +150,6 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
 @interface VLCMediaPlayer ()
 {
     VLCLibrary *_privateLibrary;
-    id _delegate;                        //< Object delegate
     void * _playerInstance;              //  Internal
     VLCMedia * _media;                   //< Current media being played
     VLCTime * _cachedTime;               //< Cached time of the media being played
@@ -245,16 +244,6 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
         libvlc_release(_privateLibrary.instance);
 }
 
-- (void)setDelegate:(id)value
-{
-    _delegate = value;
-}
-
-- (id)delegate
-{
-    return _delegate;
-}
-
 #if !TARGET_OS_IPHONE
 - (void)setVideoView:(VLCVideoView *)aVideoView
 {
@@ -1070,8 +1059,6 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
 - (id)initWithDrawable:(id)aDrawable options:(NSArray *)options
 {
     if (self = [super init]) {
-        _delegate = nil;
-        _media = nil;
         _cachedTime = [VLCTime nullTime];
         _cachedRemainingTime = [VLCTime nullTime];
         _position = 0.0f;