#endif /* PAWIN_USE_WDMKS_DEVICE_INFO */
/* use CreateThread for CYGWIN, _beginthreadex for all others */
-#ifndef __CYGWIN__
+#if !defined(__CYGWIN__) && !defined(_WIN32_WCE)
#define CREATE_THREAD (HANDLE)_beginthreadex( 0, 0, ProcessingThreadProc, stream, 0, &stream->processingThreadId )
+#define PA_THREAD_FUNC static unsigned WINAPI
+#define PA_THREAD_ID unsigned
#else
#define CREATE_THREAD CreateThread( 0, 0, ProcessingThreadProc, stream, 0, &stream->processingThreadId )
+#define PA_THREAD_FUNC static DWORD WINAPI
+#define PA_THREAD_ID DWORD
#endif
-
-#if (defined(UNDER_CE))
+#if (defined(_WIN32_WCE))
#pragma comment(lib, "Coredll.lib")
#elif (defined(WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1200))) /* MSC version 6 and above */
#pragma comment(lib, "winmm.lib")
provided in newer platform sdks
*/
#ifndef DWORD_PTR
-#define DWORD_PTR DWORD
+ #if defined(_WIN64)
+ #define DWORD_PTR unsigned __int64
+ #else
+ #define DWORD_PTR unsigned long
+ #endif
#endif
/************************************************* Constants ********/
static const char constInputMapperSuffix_[] = " - Input";
static const char constOutputMapperSuffix_[] = " - Output";
+/*
+copies TCHAR string to explicit char string
+*/
+char *StrTCpyToC(char *to, const TCHAR *from)
+{
+#if !defined(_UNICODE) && !defined(UNICODE)
+ return strcpy(to, from);
+#else
+ int count = wcslen(from);
+ if (count != 0)
+ if (WideCharToMultiByte(CP_ACP, 0, from, count, to, count, NULL, NULL) == 0)
+ return NULL;
+ return to;
+#endif
+}
+
+/*
+returns length of TCHAR string
+*/
+size_t StrTLen(const TCHAR *str)
+{
+#if !defined(_UNICODE) && !defined(UNICODE)
+ return strlen(str);
+#else
+ return wcslen(str);
+#endif
+}
+
/********************************************************************/
typedef struct PaWinMmeStream PaWinMmeStream; /* forward declaration */
{
/* Append I/O suffix to WAVE_MAPPER device. */
deviceName = (char *)PaUtil_GroupAllocateMemory(
- winMmeHostApi->allocations, strlen( wic.szPname ) + 1 + sizeof(constInputMapperSuffix_) );
+ winMmeHostApi->allocations, StrTLen( wic.szPname ) + 1 + sizeof(constInputMapperSuffix_) );
if( !deviceName )
{
result = paInsufficientMemory;
goto error;
}
- strcpy( deviceName, wic.szPname );
+ StrTCpyToC( deviceName, wic.szPname );
strcat( deviceName, constInputMapperSuffix_ );
}
else
{
deviceName = (char*)PaUtil_GroupAllocateMemory(
- winMmeHostApi->allocations, strlen( wic.szPname ) + 1 );
+ winMmeHostApi->allocations, StrTLen( wic.szPname ) + 1 );
if( !deviceName )
{
result = paInsufficientMemory;
goto error;
}
- strcpy( deviceName, wic.szPname );
+ StrTCpyToC( deviceName, wic.szPname );
}
deviceInfo->name = deviceName;
{
/* Append I/O suffix to WAVE_MAPPER device. */
deviceName = (char *)PaUtil_GroupAllocateMemory(
- winMmeHostApi->allocations, strlen( woc.szPname ) + 1 + sizeof(constOutputMapperSuffix_) );
+ winMmeHostApi->allocations, StrTLen( woc.szPname ) + 1 + sizeof(constOutputMapperSuffix_) );
if( !deviceName )
{
result = paInsufficientMemory;
goto error;
}
- strcpy( deviceName, woc.szPname );
+ StrTCpyToC( deviceName, woc.szPname );
strcat( deviceName, constOutputMapperSuffix_ );
}
else
{
deviceName = (char*)PaUtil_GroupAllocateMemory(
- winMmeHostApi->allocations, strlen( woc.szPname ) + 1 );
+ winMmeHostApi->allocations, StrTLen( woc.szPname ) + 1 );
if( !deviceName )
{
result = paInsufficientMemory;
goto error;
}
- strcpy( deviceName, woc.szPname );
+ StrTCpyToC( deviceName, woc.szPname );
}
deviceInfo->name = deviceName;
/* the following calls assume that if wave*Message fails the preferred device parameter won't be modified */
preferredDeviceStatusFlags = 0;
waveInPreferredDevice = -1;
- waveInMessage( (HWAVEIN)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD)&waveInPreferredDevice, (DWORD)&preferredDeviceStatusFlags );
+ waveInMessage( (HWAVEIN)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveInPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags );
preferredDeviceStatusFlags = 0;
waveOutPreferredDevice = -1;
- waveOutMessage( (HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD)&waveOutPreferredDevice, (DWORD)&preferredDeviceStatusFlags );
+ waveOutMessage( (HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveOutPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags );
maximumPossibleDeviceCount = 0;
/* Processing thread management -------------- */
HANDLE abortEvent;
HANDLE processingThread;
- DWORD processingThreadId;
+ PA_THREAD_ID processingThreadId;
char throttleProcessingThreadOnOverload; /* 0 -> don't throtte, non-0 -> throttle */
int processingThreadPriority;
}
-static DWORD WINAPI ProcessingThreadProc( void *pArg )
+PA_THREAD_FUNC ProcessingThreadProc( void *pArg )
{
PaWinMmeStream *stream = (PaWinMmeStream *)pArg;
HANDLE events[3];