[vlc-commits] macosx: work-around IOKit bug in OS X 10.7.4 and 10.7.5, which effectively stopped VLC from preventing system sleep (refs #7521)
Felix Paul Kühne
git at videolan.org
Fri Sep 28 13:11:36 CEST 2012
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Sep 28 13:11:05 2012 +0200| [45adae34857fcc317c88fb963f9e875d4290919b] | committer: Felix Paul Kühne
macosx: work-around IOKit bug in OS X 10.7.4 and 10.7.5, which effectively stopped VLC from preventing system sleep (refs #7521)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=45adae34857fcc317c88fb963f9e875d4290919b
---
modules/gui/macosx/intf.m | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 0602a5d..97341c9 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1304,12 +1304,21 @@ static VLCMain *_o_sharedMainInstance = nil;
if (state == PLAYING_S) {
/* prevent the system from sleeping */
IOReturn success;
- CFStringRef reasonForActivity= CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
- if ([self activeVideoPlayback])
- success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
- else
- success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
- CFRelease(reasonForActivity);
+ /* work-around a bug in 10.7.4 and 10.7.5, so check for 10.7.x < 10.7.4, 10.8 and 10.6 */
+ if ((NSAppKitVersionNumber >= 1115.2 && NSAppKitVersionNumber < 1138.45) || OSX_MOUNTAIN_LION || OSX_SNOW_LEOPARD) {
+ CFStringRef reasonForActivity= CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
+ if ([self activeVideoPlayback])
+ success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
+ else
+ success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
+ CFRelease(reasonForActivity);
+ } else {
+ /* fall-back on the 10.5 mode, which also works on 10.7.4 and 10.7.5 */
+ if ([self activeVideoPlayback])
+ success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
+ else
+ success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
+ }
if (success == kIOReturnSuccess)
msg_Dbg(VLCIntf, "prevented sleep through IOKit (%i)", systemSleepAssertionID);
More information about the vlc-commits
mailing list