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
15typedef int int32_t;
16typedef 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
24extern "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
39typedef 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;
50typedef int32_t PtTimestamp;
51
53typedef void (PtCallback)(PtTimestamp timestamp, void *userData);
54
66PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
67
72PMEXPORT PtError Pt_Stop(void);
73
78PMEXPORT int Pt_Started(void);
79
84PMEXPORT PtTimestamp Pt_Time(void);
85
92PMEXPORT void Pt_Sleep(int32_t duration);
93
96#ifdef __cplusplus
97}
98#endif
PMEXPORT int Pt_Started(void)
test if the timer is running.
PMEXPORT PtError Pt_Stop(void)
stop the timer.
PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
start a real-time clock service.
void() PtCallback(PtTimestamp timestamp, void *userData)
a function that gets a current time
Definition: porttime.h:53
PMEXPORT void Pt_Sleep(int32_t duration)
pauses the current thread, allowing other threads to run.
PMEXPORT PtTimestamp Pt_Time(void)
get the current time in ms.
PtError
PortTime error code; a common return type.
Definition: porttime.h:39
int32_t PtTimestamp
real time or time offset in milliseconds.
Definition: porttime.h:50