diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2008-02-08 13:00:32 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2008-02-08 13:00:32 +0000 |
commit | 4d84d14ac1aa13958eaa2971b03f7f929a519105 (patch) | |
tree | 6579d3f2cea5410a10c4baac8d0f372fb0dff372 /desiredata/portmidi_osx/ptdarwin.c | |
parent | b334d38aefbd8e0e159d7af6c20d63c5d2b64859 (diff) |
reorganized
svn path=/trunk/; revision=9400
Diffstat (limited to 'desiredata/portmidi_osx/ptdarwin.c')
-rw-r--r-- | desiredata/portmidi_osx/ptdarwin.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/desiredata/portmidi_osx/ptdarwin.c b/desiredata/portmidi_osx/ptdarwin.c new file mode 100644 index 00000000..de71d03b --- /dev/null +++ b/desiredata/portmidi_osx/ptdarwin.c @@ -0,0 +1,58 @@ +/* + * Portable timer implementation for Darwin / MacOS X + * + * Jon Parise <jparise@cmu.edu> + * + * $Id: ptdarwin.c,v 1.9.2.2 2005-07-12 15:53:50 timblech Exp $ + */ + +#include <stdio.h> +#include <sys/time.h> +#include "porttime.h" + +#define TRUE 1 +#define FALSE 0 + +static int time_started_flag = FALSE; +static struct timeval time_offset; + +PtError Pt_Start(int resolution, PtCallback *callback, void *userData) +{ + struct timezone tz; + + if (callback) printf("error in porttime: callbacks not implemented\n"); + time_started_flag = TRUE; + gettimeofday(&time_offset, &tz); + + return ptNoError; +} + + +PtError Pt_Stop(void) // xjs added void +{ + time_started_flag = FALSE; + return ptNoError; +} + + +int Pt_Started(void) // xjs added void +{ + return time_started_flag; +} + + +PtTimestamp Pt_Time(void *time_info) // xjs added void *time_info +{ + long seconds, milliseconds; + struct timeval now; + struct timezone tz; + + gettimeofday(&now, &tz); + seconds = now.tv_sec - time_offset.tv_sec; + milliseconds = (now.tv_usec - time_offset.tv_usec) / 1000; + + return (seconds * 1000 + milliseconds); +} + + + |