1 /* porttime.h -- portable interface to millisecond timer */
3 /* CHANGE LOG FOR PORTTIME
4 10-Jun-03 Mark Nelson & RBD
5 boost priority of timer thread in ptlinux.c implementation
8 /* Should there be a way to choose the source of time here? */
12 // rather than having users install a special .h file for windows,
13 // just put the required definitions inline here. portmidi.h uses
14 // these too, so the definitions are (unfortunately) duplicated there
16 typedef unsigned int uint32_t;
20 #include <stdint.h> // needed for int32_t
29 #define PMEXPORT __declspec(dllexport)
36 ptNoError = 0, /* success */
37 ptHostError = -10000, /* a system-specific error occurred */
38 ptAlreadyStarted, /* cannot start timer because it is already started */
39 ptAlreadyStopped, /* cannot stop timer because it is already stopped */
40 ptInsufficientMemory /* memory could not be allocated */
44 typedef int32_t PtTimestamp;
46 typedef void (PtCallback)( PtTimestamp timestamp, void *userData );
49 Pt_Start() starts a real-time service.
51 resolution is the timer resolution in ms. The time will advance every
54 callback is a function pointer to be called every resolution ms.
56 userData is passed to callback as a parameter.
59 Upon success, returns ptNoError. See PtError for other values.
61 PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
64 Pt_Stop() stops the timer.
67 Upon success, returns ptNoError. See PtError for other values.
69 PMEXPORT PtError Pt_Stop();
72 Pt_Started() returns true iff the timer is running.
74 PMEXPORT int Pt_Started();
77 Pt_Time() returns the current time in ms.
79 PMEXPORT PtTimestamp Pt_Time();
82 Pt_Sleep() pauses, allowing other threads to run.
84 duration is the length of the pause in ms. The true duration
85 of the pause may be rounded to the nearest or next clock tick
86 as determined by resolution in Pt_Start().
88 PMEXPORT void Pt_Sleep(int32_t duration);