[vlc-commits] macosx: robustify media key trap handling

David Fuhrmann git at videolan.org
Tue Nov 11 12:25:10 CET 2014


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Tue Nov 11 12:11:02 2014 +0100| [272b0ffa072918603894ecbb22e037824f1dbcfa] | committer: David Fuhrmann

macosx: robustify media key trap handling

Only start and stop media key support when needed (ressource-intensive).

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

 modules/gui/macosx/intf.h         |    1 +
 modules/gui/macosx/intf.m         |   21 +++++++++++++--------
 modules/gui/macosx/simple_prefs.m |    4 ----
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 98cda4e..db5bacc 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -105,6 +105,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
     BOOL b_mediaKeySupport;
     BOOL b_mediakeyJustJumped;
     SPMediaKeyTap * o_mediaKeyController;
+    BOOL b_mediaKeyTrapEnabled;
 
     NSArray *o_usedHotkeys;
 
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 11dba36..2f85aef 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1842,18 +1842,23 @@ static const int kCurrentPreferencesVersion = 3;
 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
 {
     b_mediaKeySupport = var_InheritBool(VLCIntf, "macosx-mediakeys");
-    if (b_mediaKeySupport) {
-        if (!o_mediaKeyController)
-            o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
+    if (b_mediaKeySupport && !o_mediaKeyController)
+        o_mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
 
-        if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot]->i_children > 0 ||
-            p_current_input)
+    if (b_mediaKeySupport && ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot]->i_children > 0 ||
+                              p_current_input)) {
+        if (!b_mediaKeyTrapEnabled) {
+            b_mediaKeyTrapEnabled = YES;
+            msg_Dbg(p_intf, "Enable media key support");
             [o_mediaKeyController startWatchingMediaKeys];
-        else
+        }
+    } else {
+        if (b_mediaKeyTrapEnabled) {
+            b_mediaKeyTrapEnabled = NO;
+            msg_Dbg(p_intf, "Disable media key support");
             [o_mediaKeyController stopWatchingMediaKeys];
+        }
     }
-    else if (!b_mediaKeySupport && o_mediaKeyController)
-        [o_mediaKeyController stopWatchingMediaKeys];
 }
 
 @end
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index 3b89472..d51e1fd 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -1451,10 +1451,6 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
         [o_hotkeys_listbox reloadData];
         b_hotkeyChanged = YES;
     }
-
-    [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
-                                                        object: nil
-                                                      userInfo: nil];
 }
 
 - (void)showHotkeySettings



More information about the vlc-commits mailing list