]> git.sesse.net Git - vlc/commitdiff
macosx: Add own callback path for item-change
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Wed, 29 Oct 2014 19:00:51 +0000 (20:00 +0100)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Wed, 29 Oct 2014 19:03:36 +0000 (20:03 +0100)
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

modules/gui/macosx/intf.h
modules/gui/macosx/intf.m

index 8afc5bb7483995d0ead8f957f4c678e9fec86a33..98cda4e16e5fa1392ae7d859548b767258e100a3 100644 (file)
@@ -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;
index 89150f619cfd4070603a49a3631479eb4dc9d133..11dba36568e342b8905caf2bd7d555b4779e4b7a 100644 (file)
@@ -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];