gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

porttime.h (2308B)


      1 /* porttime.h -- portable interface to millisecond timer */
      2 
      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 
     35 typedef enum {
     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 */
     41 } PtError;
     42 
     43 
     44 typedef int32_t PtTimestamp;
     45 
     46 typedef void (PtCallback)( PtTimestamp timestamp, void *userData );
     47 
     48 /*
     49     Pt_Start() starts a real-time service.
     50 
     51     resolution is the timer resolution in ms. The time will advance every
     52     resolution ms.
     53 
     54     callback is a function pointer to be called every resolution ms.
     55 
     56     userData is passed to callback as a parameter.
     57 
     58     return value:
     59     Upon success, returns ptNoError. See PtError for other values.
     60 */
     61 PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
     62 
     63 /*
     64     Pt_Stop() stops the timer.
     65 
     66     return value:
     67     Upon success, returns ptNoError. See PtError for other values.
     68 */
     69 PMEXPORT PtError Pt_Stop();
     70 
     71 /*
     72     Pt_Started() returns true iff the timer is running.
     73 */
     74 PMEXPORT int Pt_Started();
     75 
     76 /* 
     77     Pt_Time() returns the current time in ms.
     78 */
     79 PMEXPORT PtTimestamp Pt_Time();
     80 
     81 /*
     82     Pt_Sleep() pauses, allowing other threads to run.
     83 
     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().
     87 */
     88 PMEXPORT void Pt_Sleep(int32_t duration);
     89 
     90 #ifdef __cplusplus
     91 }
     92 #endif