[vlc-devel] [PATCH] Use new function to declare user activity (from 10.7.3). This is the new official way to wake the display, rather than simply preventing display sleep.

Rob Jonson rob at hobbyistsoftware.com
Thu Jan 10 17:04:00 CET 2013


---
 modules/gui/macosx/intf.h |    1 +
 modules/gui/macosx/intf.m |   14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 5fa2490..d2d45cb 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -144,6 +144,7 @@ struct intf_sys_t
 
     /* sleep management */
     IOPMAssertionID systemSleepAssertionID;
+    IOPMAssertionID userActivityAssertionID;
 
     VLCVoutWindowController *o_vout_controller;
 }
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 3aa9f66..a530612 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1392,6 +1392,20 @@ static VLCMain *_o_sharedMainInstance = nil;
     if (p_input) {
         int state = var_GetInteger(p_input, "state");
         if (state == PLAYING_S) {
+            /* Declare user activity.
+             This wakes the display if it is off, and postpones display sleep according to the users system preferences
+             Available from 10.7.3
+             */
+            if ([self activeVideoPlayback] && IOPMAssertionDeclareUserActivity)
+            {
+                CFStringRef reasonForActivity = CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
+                IOPMAssertionDeclareUserActivity(reasonForActivity,
+                                                 kIOPMUserActiveLocal,
+                                                 &userActivityAssertionID);
+                CFRelease(reasonForActivity);
+            }
+
+
             /* prevent the system from sleeping */
             if (systemSleepAssertionID > 0) {
                 msg_Dbg(VLCIntf, "releasing old sleep blocker (%i)" , systemSleepAssertionID);
-- 
1.7.10.2 (Apple Git-33)




More information about the vlc-devel mailing list