[vlc-commits] macosx: fix display sleep issue on 10.5 (refs #7623)

Felix Paul Kühne git at videolan.org
Thu Dec 6 02:00:25 CET 2012


vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Dec  6 11:59:45 2012 +1100| [81a328447337174bb0aac581f9f560205db741d9] | committer: Felix Paul Kühne

macosx: fix display sleep issue on 10.5 (refs #7623)

According to user reports, the modern IOKit approach doesn't work on 10.5 eventhough the docs state that it should.

Note that the screen (and it turn the device) will fall asleep after the defined time in system preferences when playing audio-only media on 32bit devices running 10.5. This is the way it used to be in the past anyway. For x86_64 devices or 32bit devices running 10.6, there is no change.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=81a328447337174bb0aac581f9f560205db741d9
---

 modules/gui/macosx/intf.m |   30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index e1d6bbd..601e89b 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1555,6 +1555,18 @@ unsigned int CocoaKeyToVLC( unichar i_key )
 
 - (void)updatePlaybackPosition
 {
+#ifndef __x86_64__
+    /* 10.5 compatibility mode, for sane stuff, check playbackStatusUpdated */
+    if (NSAppKitVersionNumber < 1038) {
+        input_thread_t * p_input;
+        p_input = pl_CurrentInput(p_intf);
+        if (p_input) {
+            if (var_GetInteger(p_input, "state") == PLAYING_S && [self activeVideoPlayback])
+                UpdateSystemActivity(UsrActivity);
+            vlc_object_release(p_input);
+        }
+    }
+#endif
     [o_mainwindow updateTimeSlider];
 }
 
@@ -1601,7 +1613,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
                     systemSleepAssertionID = 0;
             }
 
-            #ifdef __x86_64__
+#ifdef __x86_64__
             /* prevent the system from sleeping using the 10.5 API to be as compatible as possible */
             /* work-around a bug in 10.7.4 and 10.7.5, so check for 10.7.x < 10.7.4 and 10.8 */
             if ((NSAppKitVersionNumber >= 1115.2 && NSAppKitVersionNumber < 1138.45) || OSX_MOUNTAIN_LION) {
@@ -1614,16 +1626,22 @@ unsigned int CocoaKeyToVLC( unichar i_key )
                     success = IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleSystemSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
                     }
                 CFRelease(reasonForActivity);
-            } else {
-            #endif
-                /* fall-back on the 10.5 mode, which also works on 10.6, 10.7.4 and 10.7.5 */
+            } else { // 10.6 and later
+                /* use the legacy mode, which works on 10.6, 10.7.4 and 10.7.5 */
                 if ([self activeVideoPlayback])
                     success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
                 else
                     success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
-            #ifdef __x86_64__
             }
-            #endif
+#else
+            if (NSAppKitVersionNumber >= 1038) { // 10.6 and later
+                /* use the legacy mode, which works on 10.6, 10.7.4 and 10.7.5 */
+                if ([self activeVideoPlayback])
+                    success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
+                else
+                    success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
+            } // else is handled in updatePlaybackPosition
+#endif
 
             if (success == kIOReturnSuccess)
                 msg_Dbg( VLCIntf, "prevented sleep through IOKit (%i)", systemSleepAssertionID);



More information about the vlc-commits mailing list