[vlc-commits] macosx/playlist: fix refcounting when handling the current input item

Felix Paul Kühne git at videolan.org
Tue Feb 12 10:41:50 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Tue Feb 12 10:41:19 2019 +0100| [7220f4f19595d5545459bc50fc9080bbf7dd1095] | committer: Felix Paul Kühne

macosx/playlist: fix refcounting when handling the current input item

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

 modules/gui/macosx/menus/VLCStatusBarIcon.m                  | 3 +++
 modules/gui/macosx/playlist/VLCPlayerController.h            | 1 +
 modules/gui/macosx/playlist/VLCPlayerController.m            | 3 +++
 modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m | 2 ++
 4 files changed, 9 insertions(+)

diff --git a/modules/gui/macosx/menus/VLCStatusBarIcon.m b/modules/gui/macosx/menus/VLCStatusBarIcon.m
index 4db8ceb692..8dc5e7deb1 100644
--- a/modules/gui/macosx/menus/VLCStatusBarIcon.m
+++ b/modules/gui/macosx/menus/VLCStatusBarIcon.m
@@ -258,6 +258,7 @@
         }
         [self setStoppedStatus:NO];
 
+        input_item_Release(p_item);
     } else {
         /* Nothing playing */
         [progressField setStringValue:@"--:--"];
@@ -375,6 +376,8 @@
             album = toNSStr(tmp_cstr);
             FREENULL(tmp_cstr);
         }
+
+        input_item_Release(mediaItem);
     } else {
         /* Nothing playing */
         title = _NS("VLC media player");
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.h b/modules/gui/macosx/playlist/VLCPlayerController.h
index 89d22e8e30..b51c30233b 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.h
+++ b/modules/gui/macosx/playlist/VLCPlayerController.h
@@ -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;
 /**
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index a2cde6f521..8820cee9f1 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -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;
 }
diff --git a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
index 747b6cc9a5..c9aaf38c3c 100644
--- a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
+++ b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
@@ -315,6 +315,8 @@
                                          negative:self.timeField.timeRemaining];
     [self.timeField setStringValue:time];
     [self.timeField setNeedsDisplay:YES];
+
+    input_item_Release(p_item);
 }
 
 - (void)updateControls



More information about the vlc-commits mailing list