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