Change Details
src/powersaver.cpp |
9 | 9 | |
10 | 10 | PowerSaver *PowerSaver::instance = NULL; |
11 | 11 | |
12 | | Uint32 screenTimerCallback(Uint32, void *) { |
| 12 | Uint32 screenTimerCallback(Uint32 timeout, void *d) { |
| 13 | unsigned int * old_ticks = (unsigned int *) d; |
| 14 | unsigned int new_ticks = SDL_GetTicks(); |
| 15 | |
| 16 | if (new_ticks > *old_ticks + timeout + 1000) { |
| 17 | DEBUG("Suspend occured, restarting timer\n"); |
| 18 | *old_ticks = new_ticks; |
| 19 | return timeout; |
| 20 | } |
| 21 | |
13 | 22 | DEBUG("Disable Backlight Event\n"); |
14 | 23 | PowerSaver::getInstance()->disableScreen(); |
15 | 24 | return 0; |
... | ... | |
62 | 71 | return; |
63 | 72 | } |
64 | 73 | |
65 | | screenTimer = SDL_AddTimer(screenTimeout * 1000, screenTimerCallback, NULL); |
| 74 | timeout_startms = SDL_GetTicks(); |
| 75 | screenTimer = SDL_AddTimer(screenTimeout * 1000, screenTimerCallback, &timeout_startms); |
66 | 76 | if (screenTimer == NULL) { |
67 | 77 | ERROR("Could not initialize SDLTimer: %s\n", SDL_GetError()); |
68 | 78 | } |
src/powersaver.h |
23 | 23 | static PowerSaver *instance; |
24 | 24 | bool screenState; |
25 | 25 | unsigned int screenTimeout; |
| 26 | unsigned int timeout_startms; |
26 | 27 | SDL_TimerID screenTimer; |
27 | 28 | }; |
28 | 29 | |
Download the corresponding diff file