PortMidi
Cross-platform MIDI IO library
porttime.h
Go to the documentation of this file.
1 
3 /* CHANGE LOG FOR PORTTIME
4  10-Jun-03 Mark Nelson & RBD
5  boost priority of timer thread in ptlinux.c implementation
6  */
7 
8 /* Should there be a way to choose the source of time here? */
9 
10 #ifdef WIN32
11 #ifndef INT32_DEFINED
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
15 typedef int int32_t;
16 typedef unsigned int uint32_t;
17 #define INT32_DEFINED
18 #endif
19 #else
20 #include <stdint.h> // needed for int32_t
21 #endif
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #ifndef PMEXPORT
28 #ifdef _WINDLL
29 #define PMEXPORT __declspec(dllexport)
30 #else
31 #define PMEXPORT
32 #endif
33 #endif
34 
39 typedef enum {
40  ptNoError = 0, /* success */
41  ptHostError = -10000, /* a system-specific error occurred */
42  ptAlreadyStarted, /* cannot start timer because it is already started */
43  ptAlreadyStopped, /* cannot stop timer because it is already stopped */
44  ptInsufficientMemory /* memory could not be allocated */
45 } PtError;
50 typedef int32_t PtTimestamp;
51 
53 typedef void (PtCallback)(PtTimestamp timestamp, void *userData);
54 
66 PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
67 
72 PMEXPORT PtError Pt_Stop(void);
73 
78 PMEXPORT int Pt_Started(void);
79 
84 PMEXPORT PtTimestamp Pt_Time(void);
85 
92 PMEXPORT void Pt_Sleep(int32_t duration);
93 
96 #ifdef __cplusplus
97 }
98 #endif
PtError
PortTime error code; a common return type.
Definition: porttime.h:39
PMEXPORT PtError Pt_Stop(void)
stop the timer.
PMEXPORT PtTimestamp Pt_Time(void)
get the current time in ms.
int32_t PtTimestamp
real time or time offset in milliseconds.
Definition: porttime.h:50
PMEXPORT void Pt_Sleep(int32_t duration)
pauses the current thread, allowing other threads to run.
void( PtCallback)(PtTimestamp timestamp, void *userData)
a function that gets a current time
Definition: porttime.h:53
PMEXPORT int Pt_Started(void)
test if the timer is running.
PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
start a real-time clock service.