[vlc-devel] [PATCH]Win32 screensaver disable change

Rémi Denis-Courmont rem at videolan.org
Sun Dec 28 11:15:13 CET 2008


Le dimanche 28 décembre 2008, Kaarlo Räihä a écrit :
> This patch changes how the VLC Win32 video output modules disable
> screensaver activation (applies to Direct3d, directx, OpenGL and
> WinGDI).
>
> Current method uses SystemParametersInfo with SPI_GETLOWPOWERTIMEOUT
> etc. which has few issues: p1. there are limited Windows accounts
> which cannot change SPI_GETLOWPOWERTIMEOUT settings. p2. if VLC
> crashes (which unfortunately isn't rare event) the original setting
> isn't returned
>
> New method abuses SendInput which sends VK__none_ keyboard input once
> per 500 frames (so it basically same as pressing keyboard key that
> does nothing). This should fix issues p1 and p2, since AFAIK every
> Windows account can use SendInput and crash just stops SendInput, so
> original state is returned.
>
> I could use SendInput after every frame, but I assumed it isn't OK.
> Limit 500 was chosen because lowest screensaver activation time is
> one minute (60 seconds) and lowest FPS video people would normally
> watch is 10 FPS, so 50x10 = 500 < 60x10 = 600.
>
> Naturally my patch is ugly in few ways:
> u1. there is one #DEFINE
> u2. INPUT creation is duplicate code in every module
> u3. Sendinput usage is duplicate code in every module

If code duplication is an issue, you could at least use a shared .h file 
with static functions. Granted, bytecode will still be duplicated, but 
at least not source.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list