Commit 45adae34 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: work-around IOKit bug in OS X 10.7.4 and 10.7.5, which effectively...

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)
parent 33ecade2
...@@ -1304,12 +1304,21 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1304,12 +1304,21 @@ static VLCMain *_o_sharedMainInstance = nil;
if (state == PLAYING_S) { if (state == PLAYING_S) {
/* prevent the system from sleeping */ /* prevent the system from sleeping */
IOReturn success; IOReturn success;
CFStringRef reasonForActivity= CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8); /* 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 ([self activeVideoPlayback]) if ((NSAppKitVersionNumber >= 1115.2 && NSAppKitVersionNumber < 1138.45) || OSX_MOUNTAIN_LION || OSX_SNOW_LEOPARD) {
success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID); CFStringRef reasonForActivity= CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
else if ([self activeVideoPlayback])
success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID); success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
CFRelease(reasonForActivity); 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) if (success == kIOReturnSuccess)
msg_Dbg(VLCIntf, "prevented sleep through IOKit (%i)", systemSleepAssertionID); msg_Dbg(VLCIntf, "prevented sleep through IOKit (%i)", systemSleepAssertionID);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment