Commit 0b9a93ff authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: simplify system sleep prevention code to support both 10.7.4/10.7.5 and 10.5 (close #7521)

parent 51047a67
......@@ -40,10 +40,9 @@ Mac OS X:
* Fix various crashes and small issues including bookmarks, playlist, buttons,
streaming wizard, video size, hotkeys and fullscreen controller
* Fix font selection for Unicode subtitles
* Fix code signing of Delete Preferences application
* Improve system sleep behavior when playing audio-only media. The screen is
allowed to sleep while the system is kept awake for the play time.
Requires OS X 10.6 or later and a 64bit-capable Mac.
allowed to sleep while the system is kept awake during playback.
* Fix code signing of Delete Preferences application
Miscellaneous:
* Fix Notify (D-Bus) plugin deadlock.
......
......@@ -41,9 +41,7 @@
#import "misc.h"
#import "MainWindow.h"
#ifdef __x86_64__
#import <IOKit/pwr_mgt/IOPMLib.h> /* for sleep prevention */
#endif
/*****************************************************************************
* Local prototypes.
......@@ -151,10 +149,8 @@ struct intf_sys_t
NSArray *o_usedHotkeys;
#ifdef __x86_64__
/* sleep management */
IOPMAssertionID systemSleepAssertionID;
#endif
}
+ (VLCMain *)sharedInstance;
......
......@@ -1553,17 +1553,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (void)updatePlaybackPosition
{
[o_mainwindow updateTimeSlider];
#ifndef __x86_64__
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
}
- (void)updateVolume
......@@ -1599,21 +1588,17 @@ unsigned int CocoaKeyToVLC( unichar i_key )
int state = var_GetInteger( p_input, "state" );
if( state == PLAYING_S )
{
#ifdef __x86_64__
/* prevent the system from sleeping */
/* prevent the system from sleeping using the 10.5 API to be as compatible as possible */
IOReturn success;
CFStringRef reasonForActivity= CFStringCreateWithCString( kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8 );
if ( [self activeVideoPlayback] )
success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
else
success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
CFRelease( reasonForActivity );
success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
if (success == kIOReturnSuccess)
msg_Dbg( VLCIntf, "prevented sleep through IOKit (%i)", systemSleepAssertionID);
else
msg_Warn( VLCIntf, "failed to prevent system sleep through IOKit");
#endif
[[self mainMenu] setPause];
[o_mainwindow setPause];
......@@ -1625,11 +1610,9 @@ unsigned int CocoaKeyToVLC( unichar i_key )
[[self mainMenu] setPlay];
[o_mainwindow setPlay];
#ifdef __x86_64__
/* allow the system to sleep again */
msg_Dbg( VLCIntf, "releasing sleep blocker (%i)" , systemSleepAssertionID );
IOPMAssertionRelease( systemSleepAssertionID );
#endif
}
vlc_object_release( p_input );
}
......
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