[vlc-commits] macosx: simplify system sleep prevention code to support both 10.7.4/10.7. 5 and 10.5 (close #7521)

Felix Paul Kühne git at videolan.org
Fri Sep 28 13:32:41 CEST 2012


vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Sep 28 13:32:10 2012 +0200| [0b9a93ff53c8f6562b81a99d2c08f795d45f2ccb] | committer: Felix Paul Kühne

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

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=0b9a93ff53c8f6562b81a99d2c08f795d45f2ccb
---

 NEWS                      |    5 ++---
 modules/gui/macosx/intf.h |    4 ----
 modules/gui/macosx/intf.m |   23 +++--------------------
 3 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/NEWS b/NEWS
index 48ebfca..3c80455 100644
--- a/NEWS
+++ b/NEWS
@@ -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.
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 93c20ad..a4155ea 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -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;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index ff64093..74c2676 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -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 );
     }



More information about the vlc-commits mailing list