diff options
author | Guenter Geiger <ggeiger@users.sourceforge.net> | 2002-07-29 17:06:19 +0000 |
---|---|---|
committer | Guenter Geiger <ggeiger@users.sourceforge.net> | 2002-07-29 17:06:19 +0000 |
commit | 57045df5fe3ec557e57dc7434ac1a07b5521bffc (patch) | |
tree | 7174058b41b73c808107c7090d9a4e93ee202341 /pd/portaudio/portmidi-macosx/ptdarwin.c | |
parent | da38b3424229e59f956252c3d89895e43e84e278 (diff) |
This commit was generated by cvs2svn to compensate for changes in r58,
which included commits to RCS files with non-trunk default branches.
svn path=/trunk/; revision=59
Diffstat (limited to 'pd/portaudio/portmidi-macosx/ptdarwin.c')
-rw-r--r-- | pd/portaudio/portmidi-macosx/ptdarwin.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/pd/portaudio/portmidi-macosx/ptdarwin.c b/pd/portaudio/portmidi-macosx/ptdarwin.c new file mode 100644 index 00000000..51cf5fde --- /dev/null +++ b/pd/portaudio/portmidi-macosx/ptdarwin.c @@ -0,0 +1,58 @@ +/* + * Portable timer implementation for Darwin / MacOS X + * + * Jon Parise <jparise@cmu.edu> + * + * $Id: ptdarwin.c,v 1.1.1.1 2002-07-29 17:06:16 ggeiger 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() +{ + time_started_flag = FALSE; + return ptNoError; +} + + +int Pt_Started() +{ + return time_started_flag; +} + + +PtTimestamp Pt_Time() +{ + 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); +} + + + |