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.

This commit is contained in:
gordon_gidluck 2008-10-05 15:14:25 +00:00
commit 28c21245bd

View file

@ -56,6 +56,8 @@
#include <functiondiscoverykeys.h> // PKEY_Device_FriendlyName #include <functiondiscoverykeys.h> // PKEY_Device_FriendlyName
#endif #endif
#include <process.h>
#include "pa_util.h" #include "pa_util.h"
#include "pa_allocation.h" #include "pa_allocation.h"
#include "pa_hostapi.h" #include "pa_hostapi.h"
@ -73,7 +75,12 @@
#define PORTAUDIO_SHAREMODE AUDCLNT_SHAREMODE_SHARED #define PORTAUDIO_SHAREMODE AUDCLNT_SHAREMODE_SHARED
//#define PORTAUDIO_SHAREMODE AUDCLNT_SHAREMODE_EXCLUSIVE //#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 */ /* prototypes for functions declared in this file */
@ -1517,14 +1524,8 @@ static PaError StartStream( PaStream *s )
} }
// Create a thread for this client. // Create a thread for this client.
stream->hThread = CreateThread( stream->hThread = CREATE_THREAD;
NULL, // no security attribute
0, // default stack size
ProcThread,
(LPVOID) stream, // thread parameter
0, // not suspended
&stream->dwThreadId); // returns thread ID
if (stream->hThread == NULL) if (stream->hThread == NULL)
return paUnanticipatedHostError; return paUnanticipatedHostError;