Split custom ReactOS-only non-standard extensions from NTDDSND.H
[reactos.git] / reactos / lib / drivers / sound / shared / time.c
1 /*
2 ReactOS Sound System
3 Timing helper
4
5 Author:
6 Andrew Greenwood (silverblade@reactos.org)
7
8 History:
9 31 May 2008 - Created
10
11 Notes:
12 Have checked timing in DebugView. A 10,000ms delay covered a period
13 of 124.305 sec to 134.308 sec. Not 100% accurate but likely down to
14 the delays in submitting the debug strings?
15 */
16
17 /*
18 Nanoseconds are fun! You must try some!
19 1 ns = .000000001 seconds = .0000001 ms
20 100 ns = .0000001 seconds = .00001 ms
21 10000 ns = .00001 seconds = .001 ms
22 1000000 ns = .001 seconds = 1 ms
23 */
24
25 #include <ntddk.h>
26
27 VOID
28 SleepMs(ULONG Milliseconds)
29 {
30 LARGE_INTEGER Period;
31
32 Period.QuadPart = -Milliseconds;
33 Period.QuadPart *= 10000;
34
35 KeDelayExecutionThread(KernelMode, FALSE, &Period);
36 }
37
38 ULONG
39 QuerySystemTimeMs()
40 {
41 LARGE_INTEGER Time;
42
43 KeQuerySystemTime(&Time);
44
45 Time.QuadPart /= 10000;
46
47 return (ULONG) Time.QuadPart;
48 }
49