[vlc-commits] 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 git at videolan.org
Tue Jan 22 00:07:12 CET 2013


vlc | branch: master | Rob Jonson <rob at hobbyistsoftware.com> | Thu Jan 10 15:04:00 2013 +0000| [8f844d9a755a104698faf95f4ce327e51f3b28c9] | committer: Felix Paul Kühne

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.

Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>

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

 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 873279a..bdb3084 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -145,6 +145,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 bc4547d..3d9ddeb 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1407,6 +1407,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);



More information about the vlc-commits mailing list