Commit 81a32844 authored by Felix Paul Kühne's avatar 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.
parent 113cbbcd
...@@ -1555,6 +1555,18 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1555,6 +1555,18 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (void)updatePlaybackPosition - (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]; [o_mainwindow updateTimeSlider];
} }
...@@ -1601,7 +1613,7 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1601,7 +1613,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
systemSleepAssertionID = 0; systemSleepAssertionID = 0;
} }
#ifdef __x86_64__ #ifdef __x86_64__
/* prevent the system from sleeping using the 10.5 API to be as compatible as possible */ /* 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 */ /* 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) { if ((NSAppKitVersionNumber >= 1115.2 && NSAppKitVersionNumber < 1138.45) || OSX_MOUNTAIN_LION) {
...@@ -1614,16 +1626,22 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1614,16 +1626,22 @@ unsigned int CocoaKeyToVLC( unichar i_key )
success = IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleSystemSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID); success = IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleSystemSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
} }
CFRelease(reasonForActivity); CFRelease(reasonForActivity);
} else { } else { // 10.6 and later
#endif /* use the legacy mode, which works on 10.6, 10.7.4 and 10.7.5 */
/* fall-back on the 10.5 mode, which also works on 10.6, 10.7.4 and 10.7.5 */
if ([self activeVideoPlayback]) if ([self activeVideoPlayback])
success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID); success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
else else
success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &systemSleepAssertionID); 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) 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