From 28c21245bd6e914089ff68520aa4de0a06f0cc12 Mon Sep 17 00:00:00 2001 From: gordon_gidluck Date: Sun, 5 Oct 2008 15:14:25 +0000 Subject: [PATCH] ticket #84. Fix for Cygwin. Added a #define called CREATE_THREAD. Cygwin will call CreateThread, whereas other dev environments will generate code to call _beginthreadex. endthreadex was handled in the same way. --- src/hostapi/wasapi/pa_win_wasapi.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/hostapi/wasapi/pa_win_wasapi.cpp b/src/hostapi/wasapi/pa_win_wasapi.cpp index f13a7f2..ea91eb2 100644 --- a/src/hostapi/wasapi/pa_win_wasapi.cpp +++ b/src/hostapi/wasapi/pa_win_wasapi.cpp @@ -56,6 +56,8 @@ #include // PKEY_Device_FriendlyName #endif +#include + #include "pa_util.h" #include "pa_allocation.h" #include "pa_hostapi.h" @@ -73,7 +75,12 @@ #define PORTAUDIO_SHAREMODE AUDCLNT_SHAREMODE_SHARED //#define PORTAUDIO_SHAREMODE AUDCLNT_SHAREMODE_EXCLUSIVE - +/* use CreateThread for CYGWIN, _beginthreadex for all others */ +#ifndef __CYGWIN__ +#define CREATE_THREAD (HANDLE) _beginthreadex(NULL, 0, (unsigned (_stdcall *)(void *))ProcThread, (LPVOID) stream, 0, (unsigned *)&stream->dwThreadId) +#else +#define CREATE_THREAD CreateThread(NULL, 0, ProcThread, (LPVOID) stream, 0, &stream->dwThreadId) +#endif /* prototypes for functions declared in this file */ @@ -1517,14 +1524,8 @@ static PaError StartStream( PaStream *s ) } // Create a thread for this client. - stream->hThread = CreateThread( - NULL, // no security attribute - 0, // default stack size - ProcThread, - (LPVOID) stream, // thread parameter - 0, // not suspended - &stream->dwThreadId); // returns thread ID - + stream->hThread = CREATE_THREAD; + if (stream->hThread == NULL) return paUnanticipatedHostError; -- 2.43.0