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"
|
|
7 void timer_init(struct timer_t* timer, HWND winampClientWindow, TIMERPROC timer_proc) {
|
|
8 timer->winampClientWindow = winampClientWindow;
|
|
9 timer->timer_proc = timer_proc;
|
|
10 timer->initialized = 1;
|
|
11 }
|
|
12
|
|
13 void timer_set(struct timer_t* timer, HWND winampClientWindow) {
|
|
14 assert(timer->initialized);
|
|
15
|
|
16 if (timer->is_timer_alive)
|
|
17 return;
|
|
18
|
|
19 timer->is_timer_alive = 1;
|
|
20 SetTimer(winampClientWindow, 1, timer->interval, timer->timer_proc);
|
|
21 }
|
|
22
|
|
23 void timer_stop(struct timer_t* timer, HWND winampClientWindow) {
|
|
24 assert(timer->initialized);
|
|
25
|
|
26 if (!timer->is_timer_alive)
|
|
27 return;
|
|
28
|
|
29
|
|
30 timer->is_timer_alive = 0;
|
|
31 KillTimer(winampClientWindow, 1);
|
|
32 } |