macosx/playlist: fix refcounting when handling the current input item
authorFelix Paul Kühne <felix@feepk.net>
Tue, 12 Feb 2019 09:41:19 +0000 (10:41 +0100)
committerFelix Paul Kühne <felix@feepk.net>
Tue, 12 Feb 2019 09:41:43 +0000 (10:41 +0100)
modules/gui/macosx/menus/VLCStatusBarIcon.m
modules/gui/macosx/playlist/VLCPlayerController.h
modules/gui/macosx/playlist/VLCPlayerController.m
modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m

index 4db8ceb..8dc5e7d 100644 (file)
         }
         [self setStoppedStatus:NO];
 
+        input_item_Release(p_item);
     } else {
         /* Nothing playing */
         [progressField setStringValue:@"--:--"];
             album = toNSStr(tmp_cstr);
             FREENULL(tmp_cstr);
         }
+
+        input_item_Release(mediaItem);
     } else {
         /* Nothing playing */
         title = _NS("VLC media player");
index 89d22e8..b51c302 100644 (file)
@@ -192,6 +192,7 @@ extern NSString *VLCPlayerMuteChanged;
 /**
  * get the current media item
  * @return the current media item, NULL if none
+ * @note it is the receiver's obligation to release the input item
  */
 @property (readonly, nullable) input_item_t * currentMedia;
 /**
index a2cde6f..8820cee 100644 (file)
@@ -420,6 +420,9 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
     input_item_t *inputItem;
     vlc_player_Lock(_p_player);
     inputItem = vlc_player_GetCurrentMedia(_p_player);
+    if (inputItem) {
+        input_item_Hold(inputItem);
+    }
     vlc_player_Unlock(_p_player);
     return inputItem;
 }
index 747b6cc..c9aaf38 100644 (file)
                                          negative:self.timeField.timeRemaining];
     [self.timeField setStringValue:time];
     [self.timeField setNeedsDisplay:YES];
+
+    input_item_Release(p_item);
 }
 
 - (void)updateControls