[vlc-commits] macosx: simplify more updaters

David Fuhrmann git at videolan.org
Sat Jun 27 23:04:59 CEST 2015


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jun 27 22:59:53 2015 +0200| [876dc9a6121155ed96a9a4e3640fd20fa81152ca] | committer: David Fuhrmann

macosx: simplify more updaters

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

 modules/gui/macosx/intf.h |    2 --
 modules/gui/macosx/intf.m |   52 +++++++++++++++++++--------------------------
 2 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 04114d2..c343a12 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -145,8 +145,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
 
 - (void)plItemUpdated;
 - (void)playbackModeUpdated;
-- (void)updateVolume;
-- (void)showMainWindow;
 - (void)showFullscreenController;
 
 - (void)updateTogglePlaylistState;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 3801c79..6518dc8 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -359,22 +359,21 @@ static int PlaybackModeUpdated(vlc_object_t *p_this, const char *psz_var,
 static int VolumeUpdated(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(updateVolume) withObject:nil waitUntilDone:NO];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[[VLCMain sharedInstance] mainWindow] updateVolumeSlider];
+    });
 
-    [o_pool release];
     return VLC_SUCCESS;
 }
 
 static int BossCallback(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];
-
-    [[VLCCoreInteraction sharedInstance] performSelectorOnMainThread:@selector(pause) withObject:nil waitUntilDone:NO];
-    [[VLCApplication sharedApplication] hide:nil];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[VLCCoreInteraction sharedInstance] pause];
+        [[VLCApplication sharedApplication] hide:nil];
+    });
 
-    [o_pool release];
     return VLC_SUCCESS;
 }
 
@@ -386,15 +385,21 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 static int ShowController(vlc_object_t *p_this, const char *psz_variable,
                      vlc_value_t old_val, vlc_value_t new_val, void *param)
 {
-    intf_thread_t * p_intf = VLCIntf;
-    if (p_intf) {
-        playlist_t * p_playlist = pl_Get(p_intf);
-        BOOL b_fullscreen = var_GetBool(p_playlist, "fullscreen");
-        if (b_fullscreen)
-            [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(showFullscreenController) withObject:nil waitUntilDone:NO];
-        else if (!strcmp(psz_variable, "intf-show"))
-            [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(showMainWindow) withObject:nil waitUntilDone:NO];
-    }
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+
+        intf_thread_t * p_intf = VLCIntf;
+        if (p_intf) {
+            playlist_t * p_playlist = pl_Get(p_intf);
+            BOOL b_fullscreen = var_GetBool(p_playlist, "fullscreen");
+            if (b_fullscreen)
+                [[VLCMain sharedInstance] showFullscreenController];
+
+            else if (!strcmp(psz_variable, "intf-show"))
+                [[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:nil];
+        }
+
+    });
 
     return VLC_SUCCESS;
 }
@@ -1225,11 +1230,6 @@ static VLCMain *_o_sharedMainInstance = nil;
         [o_info updateMetadata];
 }
 
-- (void)showMainWindow
-{
-    [o_mainwindow performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:nil waitUntilDone:NO];
-}
-
 - (void)showFullscreenController
 {
     // defer selector here (possibly another time) to ensure that keyWindow is set properly
@@ -1237,11 +1237,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_mainwindow performSelectorOnMainThread:@selector(showFullscreenController) withObject:nil waitUntilDone:NO];
 }
 
-- (void)updateVolume
-{
-    [o_mainwindow updateVolumeSlider];
-}
-
 - (void)playbackModeUpdated
 {
     playlist_t * p_playlist = pl_Get(VLCIntf);
@@ -1263,9 +1258,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_mainmenu setShuffle];
 }
 
-#pragma mark -
-#pragma mark Window updater
-
 - (void)setActiveVideoPlayback:(BOOL)b_value
 {
     assert([NSThread isMainThread]);



More information about the vlc-commits mailing list