[vlc-commits] macosx: Add own callback path for item-change

David Fuhrmann git at videolan.org
Thu Oct 30 00:20:15 CET 2014


vlc/vlc-2.2 | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Oct 29 20:00:51 2014 +0100| [df9f6b436135b0c72b5970ad88162e7fdce12442] | committer: Felix Paul Kühne

macosx: Add own callback path for item-change

The item-change callback might be called very often, and thus an
own code path is better, with only necessary updates.

Additionally, this fixes multiple resume playback dialogs occuring
at once when starting playback in certain situations.

refs #11981

(cherry picked from commit 293ed5e2ce38aa632a47206ff260a49771e9f67b)
Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>

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

 modules/gui/macosx/intf.h |    1 +
 modules/gui/macosx/intf.m |   26 +++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 8afc5bb..98cda4e 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -152,6 +152,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
 
 - (void)PlaylistItemChanged;
+- (void)plItemUpdated;
 - (void)playbackStatusUpdated;
 - (void)sendDistributedNotificationWithUpdatedPlaybackStatus;
 - (void)playbackModeUpdated;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 74b1f4f..ff07088 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -85,6 +85,8 @@ static int InputEvent(vlc_object_t *, const char *,
                       vlc_value_t, vlc_value_t, void *);
 static int PLItemChanged(vlc_object_t *, const char *,
                          vlc_value_t, vlc_value_t, void *);
+static int PLItemUpdated(vlc_object_t *, const char *,
+                         vlc_value_t, vlc_value_t, void *);
 static int PlaylistUpdated(vlc_object_t *, const char *,
                            vlc_value_t, vlc_value_t, void *);
 static int PlaybackModeUpdated(vlc_object_t *, const char *,
@@ -392,6 +394,20 @@ static int PLItemChanged(vlc_object_t *p_this, const char *psz_var,
     return VLC_SUCCESS;
 }
 
+/**
+ * Callback for item-change variable. Is triggered after update of duration or metadata.
+ */
+static int PLItemUpdated(vlc_object_t *p_this, const char *psz_var,
+                         vlc_value_t oldval, vlc_value_t new_val, void *param)
+{
+    NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+
+    [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(plItemUpdated) withObject:nil waitUntilDone:NO];
+
+    [o_pool release];
+    return VLC_SUCCESS;
+}
+
 static int PlaylistUpdated(vlc_object_t *p_this, const char *psz_var,
                          vlc_value_t oldval, vlc_value_t new_val, void *param)
 {
@@ -658,7 +674,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     var_AddCallback(p_intf->p_libvlc, "intf-toggle-fscontrol", ShowController, self);
     var_AddCallback(p_intf->p_libvlc, "intf-show", ShowController, self);
     var_AddCallback(p_intf->p_libvlc, "intf-boss", BossCallback, self);
-    var_AddCallback(p_playlist, "item-change", PLItemChanged, self);
+    var_AddCallback(p_playlist, "item-change", PLItemUpdated, self);
     var_AddCallback(p_playlist, "activity", PLItemChanged, self);
     var_AddCallback(p_playlist, "leaf-to-parent", PlaylistUpdated, self);
     var_AddCallback(p_playlist, "playlist-item-append", PlaylistUpdated, self);
@@ -832,7 +848,7 @@ static bool f_appExit = false;
     var_DelCallback(p_intf, "dialog-login", DialogCallback, self);
     var_DelCallback(p_intf, "dialog-question", DialogCallback, self);
     var_DelCallback(p_intf, "dialog-progress-bar", DialogCallback, self);
-    var_DelCallback(p_playlist, "item-change", PLItemChanged, self);
+    var_DelCallback(p_playlist, "item-change", PLItemUpdated, self);
     var_DelCallback(p_playlist, "activity", PLItemChanged, self);
     var_DelCallback(p_playlist, "leaf-to-parent", PlaylistUpdated, self);
     var_DelCallback(p_playlist, "playlist-item-append", PlaylistUpdated, self);
@@ -1302,7 +1318,6 @@ static bool f_appExit = false;
 
     [o_playlist updateRowSelection];
     [o_mainwindow updateWindow];
-    [o_mainwindow updateName];
     [self updateDelays];
     [self updateMainMenu];
 
@@ -1318,6 +1333,11 @@ static bool f_appExit = false;
     });
 }
 
+- (void)plItemUpdated
+{
+    [o_mainwindow updateName];
+}
+
 - (void)updateMainMenu
 {
     [o_mainmenu setupMenus];



More information about the vlc-commits mailing list