From aa82236dd093743bd2973f8b61127582aaf6e96f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sun, 18 Dec 2005 18:57:13 +0000 Subject: lots of MinGW fixes for RC6 svn path=/trunk/externals/unauthorized/; revision=4250 --- cooled~/cooled~.c | 10 ++++-- exciter/exciter.c | 6 ++-- exciter/timeval.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++ filterbank~/filterbank~.c | 5 +-- mp3amp~/mp3amp~.c | 12 ++++---- mp3live~/mp3fileout~.c | 14 ++++----- mp3live~/mp3streamin~.c | 11 ++++--- mp3live~/mp3streamout~.c | 14 ++++----- mp3write~/mp3write~.c | 16 +++++----- playlist/playlist.c | 10 +++++- probalizer/probalizer.c | 5 +-- scratcher~/scratcher~.c | 14 ++++++--- scratcher~/timeval.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++ scrolllist/scrolllist.c | 3 +- sonogram~/sonogram~-joge.c | 2 +- sonogram~/sonogram~-yves.c | 13 +++----- sonogram~/sonogram~.c | 31 +++++++++++-------- speex~/speexin~.c | 5 +-- speex~/speexout~.c | 6 ++-- 19 files changed, 253 insertions(+), 76 deletions(-) create mode 100755 exciter/timeval.h create mode 100755 scratcher~/timeval.h diff --git a/cooled~/cooled~.c b/cooled~/cooled~.c index 87b5a68..f0d966b 100644 --- a/cooled~/cooled~.c +++ b/cooled~/cooled~.c @@ -45,13 +45,17 @@ #include #include -#ifdef UNIX +#ifdef _WIN32 +#include +#define usleep(a) _sleep(a/1000) +#else #include #endif -#ifdef NT + +#include +#ifndef M_PI #define M_PI 3.14159265358979323846 #endif -#include #include "m_pd.h" #include "m_imp.h" diff --git a/exciter/exciter.c b/exciter/exciter.c index a7bd528..a8fdeda 100644 --- a/exciter/exciter.c +++ b/exciter/exciter.c @@ -44,8 +44,9 @@ #include "t_tk.h" #include "exciter.h" -#ifdef NT +#ifdef _WIN32 #include +#include "timeval.h" #else #include #endif @@ -349,7 +350,8 @@ static void exciter_properties(t_gobj *z, t_glist *owner) t_exciter *x=(t_exciter *)z; sprintf(buf, "pdtk_exciter_dialog %%s %d %d %d %.2f %d %d\n", - x->x_width, x->x_height, x->x_nbevents, x->x_timegrain, x->x_loop, x->x_save ); + (int)x->x_width, (int)x->x_height, (int)x->x_nbevents, + x->x_timegrain, x->x_loop, x->x_save ); // post("exciter_properties : %s", buf ); gfxstub_new(&x->x_obj.ob_pd, x, buf); } diff --git a/exciter/timeval.h b/exciter/timeval.h new file mode 100755 index 0000000..ff04962 --- /dev/null +++ b/exciter/timeval.h @@ -0,0 +1,76 @@ +/* + * timeval.h 1.0 01/12/19 + * + * Defines gettimeofday, timeval, etc. for Win32 + * + * By Wu Yongwei + * + */ + +#ifndef _TIMEVAL_H +#define _TIMEVAL_H + +#ifdef _WIN32 + +#define WIN32_LEAN_AND_MEAN +#include +#include + +#ifndef __GNUC__ +#define EPOCHFILETIME (116444736000000000i64) +#else +#define EPOCHFILETIME (116444736000000000LL) +#endif /* not __GNUC__ */ + +#if 0 +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; +#endif /* 0 */ + +struct timezone { + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +__inline int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + LARGE_INTEGER li; + __int64 t; + static int tzflag; + + if (tv) + { + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + t = li.QuadPart; /* In 100-nanosecond intervals */ + t -= EPOCHFILETIME; /* Offset to the Epoch time */ + t /= 10; /* In microseconds */ + tv->tv_sec = (long)(t / 1000000); + tv->tv_usec = (long)(t % 1000000); + } + + if (tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} + +#else /* _WIN32 */ + +#include + +#endif /* _WIN32 */ + +#endif /* _TIMEVAL_H */ diff --git a/filterbank~/filterbank~.c b/filterbank~/filterbank~.c index 51a2998..86bf5b9 100644 --- a/filterbank~/filterbank~.c +++ b/filterbank~/filterbank~.c @@ -33,11 +33,12 @@ #include "filterbank~.h" -#ifdef NT +#ifdef _WIN32 #include +#define random rand #else #include -#endif +#endif /* _WIN32 */ #define DEFAULT_FILTERBANK_LOWFREQ 0 #define DEFAULT_FILTERBANK_HIGHFREQ 1600 diff --git a/mp3amp~/mp3amp~.c b/mp3amp~/mp3amp~.c index c1f79be..9dfc54e 100644 --- a/mp3amp~/mp3amp~.c +++ b/mp3amp~/mp3amp~.c @@ -39,7 +39,11 @@ #include "mpg123.h" /* mpg123 decoding library from lame 3.92 */ #include "mpglib.h" /* mpglib decoding library from lame 3.92 */ #include "interface.h" /* mpglib decoding library from lame 3.92 */ -#ifdef UNIX +#ifdef _WIN32 +#include +#include +#include +#else #include #include #include @@ -51,11 +55,7 @@ #include #include #define SOCKET_ERROR -1 -#else -#include -#include -#include -#endif +#endif /* _WIN32 */ #ifdef _MSC_VER #pragma warning( disable : 4244 ) diff --git a/mp3live~/mp3fileout~.c b/mp3live~/mp3fileout~.c index e8e1c6b..bd2d431 100644 --- a/mp3live~/mp3fileout~.c +++ b/mp3live~/mp3fileout~.c @@ -36,7 +36,11 @@ #include #include -#ifdef UNIX +#ifdef _WIN32 +#include +#include +#include +#else #include #include #include @@ -48,13 +52,9 @@ #include #include #define SOCKET_ERROR -1 -#else -#include -#include -#include -#endif +#endif /* _WIN32 */ -#if defined(__APPLE__) || defined(WIN32) +#if defined(__APPLE__) || defined(_WIN32) #define MSG_NOSIGNAL 0 #endif diff --git a/mp3live~/mp3streamin~.c b/mp3live~/mp3streamin~.c index d34150b..b01a576 100644 --- a/mp3live~/mp3streamin~.c +++ b/mp3live~/mp3streamin~.c @@ -40,7 +40,10 @@ #include #include -#ifndef WIN32 +#ifdef _WIN32 +#include +#include +#else #include #include #include @@ -52,11 +55,9 @@ #include #include #define SOCKET_ERROR -1 -#else -#include -#endif +#endif /* _WIN32 */ -#if defined(__APPLE__) || defined(WIN32) +#if defined(__APPLE__) || defined(_WIN32) #define MSG_NOSIGNAL 0 #define SOL_TCP IPPROTO_TCP #endif diff --git a/mp3live~/mp3streamout~.c b/mp3live~/mp3streamout~.c index 0ed908a..33555ce 100644 --- a/mp3live~/mp3streamout~.c +++ b/mp3live~/mp3streamout~.c @@ -40,7 +40,12 @@ #include #endif #include -#ifdef UNIX +#ifdef _WIN32 +#include +#include +#include +#include +#else #include #include #include @@ -48,14 +53,9 @@ #include #include #define SOCKET_ERROR -1 -#else -#include -#include -#include -#include #endif -#if defined(__APPLE__) || defined(WIN32) +#if defined(__APPLE__) || defined(_WIN32) #define MSG_NOSIGNAL 0 #endif diff --git a/mp3write~/mp3write~.c b/mp3write~/mp3write~.c index e11eddd..b65abed 100644 --- a/mp3write~/mp3write~.c +++ b/mp3write~/mp3write~.c @@ -39,21 +39,21 @@ #include #endif #include -#ifdef UNIX +#ifdef _WIN32 +#include +#include +#include +#include +#else #include #include #include #include #include #include -#include #define SOCKET_ERROR -1 -#else -#include -#include -#include -#include -#endif +#endif /* _WIN32 */ +#include #include /* lame encoder stuff */ #include "m_pd.h" /* standard pd stuff */ diff --git a/playlist/playlist.c b/playlist/playlist.c index d8f7791..b6dde1d 100644 --- a/playlist/playlist.c +++ b/playlist/playlist.c @@ -29,6 +29,8 @@ /* Gang Of Four -- Guns Before Butter */ /* ---------------------------------------------------------------------------- */ +#ifndef _WIN32 /* this object doesn't compile on Windows because of alphasort() */ + #include #include #include @@ -42,11 +44,15 @@ #include "g_canvas.h" #include "t_tk.h" -#ifdef NT +#ifdef _WIN32 #include +#include #else #include #include +#endif + +#ifndef _MSC_VER #include #endif @@ -1017,3 +1023,5 @@ void playlist_setup(void) class_setwidget(playlist_class, &playlist_widgetbehavior); class_sethelpsymbol(playlist_class, gensym("playlist.pd")); } + +#endif /* not _WIN32 */ diff --git a/probalizer/probalizer.c b/probalizer/probalizer.c index 86ce42d..96a225b 100644 --- a/probalizer/probalizer.c +++ b/probalizer/probalizer.c @@ -42,11 +42,12 @@ #include "t_tk.h" #include "probalizer.h" -#ifdef NT +#ifdef _WIN32 #include +#define random rand #else #include -#endif +#endif /* _WIN32 */ #define DEFAULT_PROBALIZER_WIDTH 200 #define DEFAULT_PROBALIZER_HEIGHT 200 diff --git a/scratcher~/scratcher~.c b/scratcher~/scratcher~.c index 4448389..bd970a7 100644 --- a/scratcher~/scratcher~.c +++ b/scratcher~/scratcher~.c @@ -48,14 +48,18 @@ #include #include #include -#ifdef UNIX +#ifdef _WIN32 +#include +#include "timeval.h" +#else #include -#endif -#ifdef NT -#define M_PI 3.14159265358979323846 -#endif +#endif /* _WIN32 */ #include +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif /* not M_PI */ + #include "m_pd.h" #include "m_imp.h" #include "g_canvas.h" diff --git a/scratcher~/timeval.h b/scratcher~/timeval.h new file mode 100755 index 0000000..ff04962 --- /dev/null +++ b/scratcher~/timeval.h @@ -0,0 +1,76 @@ +/* + * timeval.h 1.0 01/12/19 + * + * Defines gettimeofday, timeval, etc. for Win32 + * + * By Wu Yongwei + * + */ + +#ifndef _TIMEVAL_H +#define _TIMEVAL_H + +#ifdef _WIN32 + +#define WIN32_LEAN_AND_MEAN +#include +#include + +#ifndef __GNUC__ +#define EPOCHFILETIME (116444736000000000i64) +#else +#define EPOCHFILETIME (116444736000000000LL) +#endif /* not __GNUC__ */ + +#if 0 +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; +#endif /* 0 */ + +struct timezone { + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +__inline int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + LARGE_INTEGER li; + __int64 t; + static int tzflag; + + if (tv) + { + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + t = li.QuadPart; /* In 100-nanosecond intervals */ + t -= EPOCHFILETIME; /* Offset to the Epoch time */ + t /= 10; /* In microseconds */ + tv->tv_sec = (long)(t / 1000000); + tv->tv_usec = (long)(t % 1000000); + } + + if (tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} + +#else /* _WIN32 */ + +#include + +#endif /* _WIN32 */ + +#endif /* _TIMEVAL_H */ diff --git a/scrolllist/scrolllist.c b/scrolllist/scrolllist.c index 412f062..f1ccc84 100755 --- a/scrolllist/scrolllist.c +++ b/scrolllist/scrolllist.c @@ -41,8 +41,9 @@ #include "g_canvas.h" #include "t_tk.h" -#ifdef NT +#ifdef _WIN32 #include +#include #else #include #include diff --git a/sonogram~/sonogram~-joge.c b/sonogram~/sonogram~-joge.c index 4216c4d..f420698 100644 --- a/sonogram~/sonogram~-joge.c +++ b/sonogram~/sonogram~-joge.c @@ -45,7 +45,7 @@ #include #include #endif -#ifdef NT +#ifdef _WIN32 #define M_PI 3.14159265358979323846 #include "pthread.h" #include diff --git a/sonogram~/sonogram~-yves.c b/sonogram~/sonogram~-yves.c index 59cbeed..d2ce944 100644 --- a/sonogram~/sonogram~-yves.c +++ b/sonogram~/sonogram~-yves.c @@ -42,16 +42,13 @@ #endif #include #include -#ifdef UNIX -#include -#endif -#ifdef NT +#ifdef WIN32 #define random rand +#define usleep(a) _sleep(a/1000) +#include #include -static int usleep (unsigned int us) { - Sleep((long)(us/1000.)); - return 0; -} +#else +#include #endif #include diff --git a/sonogram~/sonogram~.c b/sonogram~/sonogram~.c index fedf88c..75d17e4 100644 --- a/sonogram~/sonogram~.c +++ b/sonogram~/sonogram~.c @@ -46,13 +46,18 @@ #include #include -#ifdef UNIX +#ifdef _WIN32 +#include +#define random rand +#define usleep(a) _sleep(a/1000) +#else #include #endif -#ifdef NT +#include + +#ifndef M_PI #define M_PI 3.14159265358979323846 #endif -#include #include "m_pd.h" #include "m_imp.h" @@ -326,7 +331,7 @@ static void sonogram_update_block(t_sonogram *x, t_glist *glist, t_int bnumber) } for ( i=0; ix_zoom; i++ ) { - sprintf( x->x_guicommand, "SONIMAGE%x put {%s} -to %d 0\n", (unsigned int)x, x->x_gifdata, (bnumber*x->x_zoom)+i ); + sprintf( x->x_guicommand, "SONIMAGE%x put {%s} -to %d 0\n", (unsigned int)x, x->x_gifdata, (int) ((bnumber*x->x_zoom)+i) ); sys_gui( x->x_guicommand ); } @@ -346,7 +351,7 @@ static void sonogram_update_block(t_sonogram *x, t_glist *glist, t_int bnumber) } for ( i=0; ix_zoom; i++ ) { - sprintf( x->x_guicommand, "FAZIMAGE%x put {%s} -to %d 0\n", (unsigned int)x, x->x_gifdata, (bnumber*x->x_zoom)+i ); + sprintf( x->x_guicommand, "FAZIMAGE%x put {%s} -to %d 0\n", (unsigned int)x, x->x_gifdata, (int) ((bnumber*x->x_zoom)+i) ); sys_gui( x->x_guicommand ); } } @@ -377,15 +382,15 @@ static void sonogram_erase_block(t_sonogram *x, t_glist *glist, t_int bnumber ) static void *sonogram_do_update_part(void *tdata) { - t_sonogram *x = (t_sonogram*) tdata; - t_int si; - t_int nbpoints = 0; - t_float percentage = 0, opercentage = 0; - t_canvas *canvas=glist_getcanvas(x->x_glist); - - + t_sonogram *x = (t_sonogram*) tdata; + t_int si; + t_int nbpoints = 0; + t_float percentage = 0, opercentage = 0; + t_canvas *canvas=glist_getcanvas(x->x_glist); + + // loose synchro - usleep( THREAD_SLEEP_TIME ); + usleep( THREAD_SLEEP_TIME ); // check boundaries if ( x->x_updateend > x->x_size-1 ) x->x_updateend = x->x_size-1; diff --git a/speex~/speexin~.c b/speex~/speexin~.c index 786a9e7..eff2601 100644 --- a/speex~/speexin~.c +++ b/speex~/speexin~.c @@ -33,7 +33,8 @@ #include #include #include -#ifdef WIN32 +#ifdef _WIN32 +#include #include #else #include @@ -49,7 +50,7 @@ #define SOCKET_ERROR -1 #endif -#if defined(__APPLE__) || defined(WIN32) +#if defined(__APPLE__) || defined(_WIN32) #define MSG_NOSIGNAL 0 #define SOL_TCP IPPROTO_TCP #endif diff --git a/speex~/speexout~.c b/speex~/speexout~.c index 2d2c104..2391e6f 100644 --- a/speex~/speexout~.c +++ b/speex~/speexout~.c @@ -31,7 +31,7 @@ -#ifdef NT +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif @@ -47,7 +47,7 @@ #include #endif #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #include @@ -62,7 +62,7 @@ #define SOCKET_ERROR -1 #endif -#if defined(__APPLE__) || defined(WIN32) +#if defined(__APPLE__) || defined(_WIN32) #define MSG_NOSIGNAL 0 #endif -- cgit v1.2.1