0
|
1 #include <assert.h>
|
|
2 #ifndef WIN32_LEAN_AND_MEAN
|
|
3 # define WIN32_LEAN_AND_MEAN
|
|
4 #endif
|
|
5 #include <windows.h>
|
|
6 #include "timer.h"
|
1
|
7
|
0
|
8 void timer_init(struct timer_t* timer, HWND winampClientWindow, TIMERPROC timer_proc) {
|
|
9 timer->winampClientWindow = winampClientWindow;
|
|
10 timer->timer_proc = timer_proc;
|
|
11 timer->initialized = 1;
|
|
12 }
|
|
13
|
|
14 void timer_set(struct timer_t* timer, HWND winampClientWindow) {
|
|
15 assert(timer->initialized);
|
|
16
|
|
17 if (timer->is_timer_alive)
|
|
18 return;
|
|
19
|
|
20 timer->is_timer_alive = 1;
|
|
21 SetTimer(winampClientWindow, 1, timer->interval, timer->timer_proc);
|
|
22 }
|
|
23
|
|
24 void timer_stop(struct timer_t* timer, HWND winampClientWindow) {
|
|
25 assert(timer->initialized);
|
|
26
|
|
27 if (!timer->is_timer_alive)
|
|
28 return;
|
|
29
|
|
30
|
|
31 timer->is_timer_alive = 0;
|
|
32 KillTimer(winampClientWindow, 1);
|
|
33 } |