summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgaryscavone <garyscavone@users.noreply.github.com>2023-02-07 13:34:20 -0500
committerGitHub <noreply@github.com>2023-02-07 13:34:20 -0500
commit268e64a7b5e4b72de7668be6945c497693839d8f (patch)
treef04ac5d13f7684431fe96dad4aeb14d025a87f38
parent2aa4b644c0ff7031c7d0b3c278f33cb63503d4f1 (diff)
parent406e1420977218968283b218c5e159f00503205e (diff)
Merge pull request #378 from neheb/2
use pthreads on MinGW and Cygwin
-rw-r--r--RtAudio.cpp48
-rw-r--r--RtAudio.h2
-rw-r--r--configure.ac7
3 files changed, 28 insertions, 29 deletions
diff --git a/RtAudio.cpp b/RtAudio.cpp
index a51c100..9f39cfb 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -48,6 +48,12 @@
#include <climits>
#include <cmath>
#include <algorithm>
+#include <codecvt>
+#include <locale>
+
+#if defined(_WIN32)
+#include <windows.h>
+#endif
// Static variable definitions.
const unsigned int RtApi::MAX_SAMPLE_RATES = 14;
@@ -56,35 +62,27 @@ const unsigned int RtApi::SAMPLE_RATES[] = {
32000, 44100, 48000, 88200, 96000, 176400, 192000
};
-#if defined(_WIN32) || defined(__CYGWIN__)
+template<typename T> inline
+std::string convertCharPointerToStdString(const T *text);
+
+template<> inline
+std::string convertCharPointerToStdString(const char *text)
+{
+ return text;
+}
+
+template<> inline
+std::string convertCharPointerToStdString(const wchar_t *text)
+{
+ return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.to_bytes(text);
+}
+
+#if defined(_MSC_VER)
#define MUTEX_INITIALIZE(A) InitializeCriticalSection(A)
#define MUTEX_DESTROY(A) DeleteCriticalSection(A)
#define MUTEX_LOCK(A) EnterCriticalSection(A)
#define MUTEX_UNLOCK(A) LeaveCriticalSection(A)
-
- #include "tchar.h"
-
- template<typename T> inline
- std::string convertCharPointerToStdString(const T *text);
-
- template<> inline
- std::string convertCharPointerToStdString(const char *text)
- {
- return std::string(text);
- }
-
- template<> inline
- std::string convertCharPointerToStdString(const wchar_t *text)
- {
- int length = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL);
- std::string s( length-1, '\0' );
- if (length > 1)
- WideCharToMultiByte(CP_UTF8, 0, text, -1, &s[0], length-1, NULL, NULL);
- return s;
- }
-
-#elif defined(__unix__) || defined(__APPLE__)
- // pthread API
+#else
#define MUTEX_INITIALIZE(A) pthread_mutex_init(A, NULL)
#define MUTEX_DESTROY(A) pthread_mutex_destroy(A)
#define MUTEX_LOCK(A) pthread_mutex_lock(A)
diff --git a/RtAudio.h b/RtAudio.h
index 4e58e64..0c70fa9 100644
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -647,7 +647,7 @@ class RTAUDIO_DLL_PUBLIC RtAudio
};
// Operating system dependent thread functionality.
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_MSC_VER)
#ifndef NOMINMAX
#define NOMINMAX
diff --git a/configure.ac b/configure.ac
index 9b9aa95..5f61b64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -178,9 +178,9 @@ AS_IF([test "x$systems" = "x"],
[*-*-freebsd*], [systems="oss"],
[*-*-linux*], [systems="alsa pulse jack oss"],
[*-apple*], [systems="core jack"],
- [*-mingw32*], [systems="asio dsound wasapi jack"],
- [*-mingw64*], [systems="asio dsound wasapi jack"],
- [*-msys*], [systems="asio dsound wasapi jack"],
+ [*-mingw32*], [systems="asio dsound pulse wasapi jack"],
+ [*-mingw64*], [systems="asio dsound pulse wasapi jack"],
+ [*-msys*], [systems="asio dsound pulse wasapi jack"],
))
# If any were specifically requested disabled, do it.
@@ -193,6 +193,7 @@ AS_IF([test "x$with_asio" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep
AS_IF([test "x$with_dsound" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v dsound`])
AS_IF([test "x$with_wasapi" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v wasapi`])
systems=" `echo $systems|tr \\\\n ' '` "
+need_pthread=yes
# For each audio system, check if it is selected and found.
# Note: Order specified above is not necessarily respected. However,