[vlc-commits] Win32: try to fix the power management issues.
Jean-Baptiste Kempf
git at videolan.org
Thu Aug 16 12:18:18 CEST 2012
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Aug 16 00:41:19 2012 +0200| [342a38f0b973fad378acc279c113a54405f5260e] | committer: Jean-Baptiste Kempf
Win32: try to fix the power management issues.
Should close #923 #1241 #4158 #4275 #5380 #5719
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=342a38f0b973fad378acc279c113a54405f5260e
---
modules/video_output/msw/common.c | 50 +++++++++++++++++--------------------
modules/video_output/msw/common.h | 4 +--
modules/video_output/msw/events.c | 2 +-
3 files changed, 25 insertions(+), 31 deletions(-)
diff --git a/modules/video_output/msw/common.c b/modules/video_output/msw/common.c
index e9ebfc9..fbc8f44 100644
--- a/modules/video_output/msw/common.c
+++ b/modules/video_output/msw/common.c
@@ -694,25 +694,29 @@ static void DisableScreensaver(vout_display_t *vd)
vout_display_sys_t *sys = vd->sys;
/* disable screensaver by temporarily changing system settings */
- sys->i_spi_lowpowertimeout = 0;
- sys->i_spi_powerofftimeout = 0;
- sys->i_spi_screensavetimeout = 0;
+ sys->i_spi_screensaveactive = 0;
if (var_GetBool(vd, "disable-screensaver")) {
msg_Dbg(vd, "disabling screen saver");
- SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT, 0,
- &sys->i_spi_lowpowertimeout, 0);
- if (0 != sys->i_spi_lowpowertimeout) {
- SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
- }
- SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
- &sys->i_spi_powerofftimeout, 0);
- if (0 != sys->i_spi_powerofftimeout) {
- SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
+ SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0,
+ &sys->i_spi_screensaveactive, 0);
+
+ if (LOWORD(GetVersion()) == 0x0005) {
+ /* If this is NT 5.0 (i.e., Win2K), we need to hack around
+ * KB318781 (see http://support.microsoft.com/kb/318781) */
+
+ HKEY hKeyCP = NULL;
+
+ if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER,
+ TEXT("Control Panel\\Desktop"),
+ 0, KEY_QUERY_VALUE, &hKeyCP) &&
+ ERROR_SUCCESS != RegQueryValueEx(hKeyCP, TEXT("SCRNSAVE.EXE"),
+ NULL, NULL, NULL, NULL)) {
+ sys->i_spi_screensaveactive = FALSE;
+ }
}
- SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
- &sys->i_spi_screensavetimeout, 0);
- if (0 != sys->i_spi_screensavetimeout) {
- SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
+
+ if (FALSE != sys->i_spi_screensaveactive) {
+ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, NULL, 0);
}
}
}
@@ -722,17 +726,9 @@ static void RestoreScreensaver(vout_display_t *vd)
vout_display_sys_t *sys = vd->sys;
/* restore screensaver system settings */
- if (0 != sys->i_spi_lowpowertimeout) {
- SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
- sys->i_spi_lowpowertimeout, NULL, 0);
- }
- if (0 != sys->i_spi_powerofftimeout) {
- SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
- sys->i_spi_powerofftimeout, NULL, 0);
- }
- if (0 != sys->i_spi_screensavetimeout) {
- SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
- sys->i_spi_screensavetimeout, NULL, 0);
+ if (0 != sys->i_spi_screensaveactive) {
+ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,
+ sys->i_spi_screensaveactive, NULL, 0);
}
}
#endif
diff --git a/modules/video_output/msw/common.h b/modules/video_output/msw/common.h
index 704311d..cfa3323 100644
--- a/modules/video_output/msw/common.h
+++ b/modules/video_output/msw/common.h
@@ -96,9 +96,7 @@ struct vout_display_sys_t
#ifndef UNDER_CE
/* screensaver system settings to be restored when vout is closed */
- UINT i_spi_lowpowertimeout;
- UINT i_spi_powerofftimeout;
- UINT i_spi_screensavetimeout;
+ UINT i_spi_screensaveactive;
#endif
diff --git a/modules/video_output/msw/events.c b/modules/video_output/msw/events.c
index 8952f85f..cfcc706 100644
--- a/modules/video_output/msw/events.c
+++ b/modules/video_output/msw/events.c
@@ -252,7 +252,7 @@ static void *EventThread( void *p_this )
#ifndef UNDER_CE
/* Prevent monitor from powering off */
- SetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_CONTINUOUS );
+ SetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS );
#endif
/* Main loop */
More information about the vlc-commits
mailing list