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

David Fuhrmann git at videolan.org
Wed Oct 29 20:03:45 CET 2014


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Oct 29 20:00:51 2014 +0100| [293ed5e2ce38aa632a47206ff260a49771e9f67b] | committer: David Fuhrmann

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

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

 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 89150f6..11dba36 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 *,
@@ -397,6 +399,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)
 {
@@ -663,7 +679,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);
@@ -837,7 +853,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);
@@ -1311,7 +1327,6 @@ static bool f_appExit = false;
 
     [o_playlist updateRowSelection];
     [o_mainwindow updateWindow];
-    [o_mainwindow updateName];
     [self updateDelays];
     [self updateMainMenu];
 
@@ -1327,6 +1342,11 @@ static bool f_appExit = false;
     });
 }
 
+- (void)plItemUpdated
+{
+    [o_mainwindow updateName];
+}
+
 - (void)updateMainMenu
 {
     [o_mainmenu setupMenus];



More information about the vlc-commits mailing list