Update of /cvsroot/pure-data/externals/mrpeach/osc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23060
Modified Files: unpackOSC.c packOSC.c Log Message: Should compile on MSW now...
Index: packOSC.c =================================================================== RCS file: /cvsroot/pure-data/externals/mrpeach/osc/packOSC.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** packOSC.c 11 Jul 2007 17:34:38 -0000 1.7 --- packOSC.c 15 Jul 2007 18:00:20 -0000 1.8 *************** *** 38,47 **** #include <string.h> #include <stdlib.h> - #include <sys/time.h>
#ifdef MSW #include <winsock2.h> #else #include <ctype.h> #endif
--- 38,48 ---- #include <string.h> #include <stdlib.h>
#ifdef MSW #include <winsock2.h> + #include <sys/timeb.h> #else #include <ctype.h> + #include <sys/time.h> #endif
*************** *** 1269,1275 **** { /* offset is in microseconds */ OSCTimeTag tt; struct timeval tv; struct timezone tz; - static unsigned int onemillion = 1000000;
gettimeofday(&tv, &tz); --- 1270,1289 ---- { /* offset is in microseconds */ OSCTimeTag tt; + static unsigned int onemillion = 1000000; + static unsigned int onethousand = 1000; + #ifdef MSW + struct _timeb tb; + + _ftime(&tb); + + /* First get the seconds right */ + tt.seconds = (unsigned)SECONDS_FROM_1900_to_1970 + + (unsigned)tb.time+ + (unsigned)offset/onemillion; + /* Now get the fractional part. */ + tt.fraction = (unsigned)tb.millitm*onethousand + (unsigned)(offset%onemillion); /* in usec */ + #else struct timeval tv; struct timezone tz;
gettimeofday(&tv, &tz); *************** *** 1283,1286 **** --- 1297,1301 ---- /* Now get the fractional part. */ tt.fraction = (unsigned) tv.tv_usec + (unsigned)(offset%onemillion); /* in usec */ + #endif if (tt.fraction > onemillion) {
Index: unpackOSC.c =================================================================== RCS file: /cvsroot/pure-data/externals/mrpeach/osc/unpackOSC.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** unpackOSC.c 12 Jul 2007 15:25:36 -0000 1.6 --- unpackOSC.c 15 Jul 2007 18:00:20 -0000 1.7 *************** *** 78,88 **** #include <string.h> #include <stdlib.h> - #include <sys/time.h> #ifdef _WIN32 #include <winsock2.h> #else #include <sys/types.h> #include <netinet/in.h> #include <ctype.h> #endif /* _WIN32 */
--- 78,89 ---- #include <string.h> #include <stdlib.h> #ifdef _WIN32 #include <winsock2.h> + #include <sys/timeb.h> #else #include <sys/types.h> #include <netinet/in.h> #include <ctype.h> + #include <sys/time.h> #endif /* _WIN32 */
*************** *** 605,629 **** static t_float unpackOSC_DeltaTime(OSCTimeTag tt) { - OSCTimeTag ttnow; - struct timeval tv; - struct timezone tz; static double onemillion = 1000000.0f; ! double ttusec, nowusec, delta;
if (tt.fraction == 1 && tt.seconds == 0) return 0.0; /* immediate */ ! gettimeofday(&tv, &tz); /* find now */ ! /* First get the seconds right */ ! ttnow.seconds = (unsigned) SECONDS_FROM_1900_to_1970 + ! (unsigned) tv.tv_sec - ! (unsigned) 60 * tz.tz_minuteswest + ! (unsigned) (tz.tz_dsttime ? 3600 : 0); ! /* find usec in tt */ ! ttusec = tt.seconds*onemillion + ONE_MILLION_OVER_TWO_TO_THE_32*tt.fraction; ! nowusec = ttnow.seconds*onemillion + tv.tv_usec; ! /* subtract now from tt to get delta time */ ! /* if (ttusec < nowusec) return 0.0; */ ! /*negative delays are all right */ ! delta = ttusec - nowusec; ! return (float)(delta*0.001f); } /* end of unpackOSC.c */ --- 606,647 ---- static t_float unpackOSC_DeltaTime(OSCTimeTag tt) { static double onemillion = 1000000.0f; ! static double onethousand = 1000.0f;
if (tt.fraction == 1 && tt.seconds == 0) return 0.0; /* immediate */ ! else ! { ! OSCTimeTag ttnow; ! double ttusec, nowusec, delta; ! #ifdef MSW ! struct _timeb tb; ! ! _ftime(&tb); /* find now */ ! /* First get the seconds right */ ! ttnow.seconds = (unsigned) SECONDS_FROM_1900_to_1970 + ! (unsigned) tb.time; ! /* find usec in tt */ ! ttusec = tt.seconds*onemillion + ONE_MILLION_OVER_TWO_TO_THE_32*tt.fraction; ! nowusec = ttnow.seconds*onemillion + tb.millitm*onethousand; ! #else ! struct timeval tv; ! struct timezone tz; ! ! gettimeofday(&tv, &tz); /* find now */ ! /* First get the seconds right */ ! ttnow.seconds = (unsigned) SECONDS_FROM_1900_to_1970 + ! (unsigned) tv.tv_sec - ! (unsigned) 60 * tz.tz_minuteswest + ! (unsigned) (tz.tz_dsttime ? 3600 : 0); ! /* find usec in tt */ ! ttusec = tt.seconds*onemillion + ONE_MILLION_OVER_TWO_TO_THE_32*tt.fraction; ! nowusec = ttnow.seconds*onemillion + tv.tv_usec; ! #endif /* ifdef MSW */ ! /* subtract now from tt to get delta time */ ! /* if (ttusec < nowusec) return 0.0; */ ! /*negative delays are all right */ ! delta = ttusec - nowusec; ! return (float)(delta*0.001f); ! } } /* end of unpackOSC.c */