MSVC compatibility for zita-convolver
authorRobin Gareus <robin@gareus.org>
Sun, 21 Oct 2018 15:02:14 +0000 (17:02 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 21 Oct 2018 15:02:14 +0000 (17:02 +0200)
libs/zita-convolver/zita-convolver.cc
libs/zita-convolver/zita-convolver/zita-convolver.h

index 3a2d053be9493780a488a94556ae3c62f116c988..91637b46d467c1557e222fdc03dcece373cb12c6 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+#if _MSC_VER
+#include <windows.h> // Needed for 'Sleep()'
+#endif
+
 #include "zita-convolver/zita-convolver.h"
 
 using namespace ArdourZita;
@@ -352,7 +356,11 @@ Convproc::cleanup (void)
        uint32_t k;
 
        while (!check_stop ()) {
+#if _MSC_VER
+               Sleep (100);
+#else
                usleep (100000);
+#endif
        }
        for (k = 0; k < _ninp; k++) {
                delete[] _inpbuff[k];
@@ -403,7 +411,9 @@ Convproc::print (FILE* F)
                _convlev[k]->print (F);
 }
 
+#ifdef ENABLE_VECTOR_MODE
 typedef float FV4 __attribute__ ((vector_size (16)));
+#endif
 
 Convlevel::Convlevel (void)
        : _stat (ST_IDLE)
index e655c636437efb38aac3a7b0bd36835f8eb66777..39ec4ed4748fcbce06e274728087850f422c3147 100644 (file)
@@ -17,9 +17,8 @@
 //
 // ----------------------------------------------------------------------------
 
-#ifndef _ZITA_CONVOLVER_H
-#define _ZITA_CONVOLVER_H
-
+#ifndef ARDOUR_ZITA_CONVOLVER_H
+#define ARDOUR_ZITA_CONVOLVER_H
 
 #include <fftw3.h>
 #include <pthread.h>
@@ -33,7 +32,11 @@ namespace ArdourZita {
 #undef ZCSEMA_IS_IMPLEMENTED
 #endif
 
-#if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined (_WIN32)
+/* Note:
+ * - __MINGW32__ is also defined for 64bit builds
+ * - mingw, x-compile uses PTW32's implementation of semaphores, we should prefer defined(PTW32_VERSION)
+ */
+#if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined (__MINGW32__)
 
 #include <semaphore.h>
 
@@ -80,7 +83,7 @@ private:
 #define ZCSEMA_IS_IMPLEMENTED
 #endif
 
-#ifdef __APPLE__
+#if defined (__APPLE__) || defined (_MSC_VER)
 
 // NOTE:  ***** I DO NOT REPEAT NOT PROVIDE SUPPORT FOR OSX *****
 //
@@ -103,8 +106,10 @@ public:
                pthread_cond_destroy (&_cond);
        }
 
+#ifndef _MSC_VER /* remove for MSVC build */
        ZCsema (const ZCsema&);            // disabled
        ZCsema& operator= (const ZCsema&); // disabled
+#endif
 
        int init (int s, int v)
        {