Clean up whitespace in src/hostapi/wdmks in preparation for .editorconfig. Indent by 4 spaces. Strip trailing whitespace. (#476)

This commit is contained in:
Ross Bencina 2021-02-04 12:17:16 +11:00 committed by GitHub
commit bfb9b7f7e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,13 +27,13 @@
*/ */
/* /*
* The text above constitutes the entire PortAudio license; however, * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests: * the PortAudio community also makes the following non-binding requests:
* *
* Any person wishing to distribute modifications to the Software is * Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that * requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also * they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the * requested that these non-binding requests be included along with the
* license above. * license above.
*/ */
@ -164,13 +164,13 @@ Default is to use the pin category.
#define _NTRTL_ /* Turn off default definition of DEFINE_GUIDEX */ #define _NTRTL_ /* Turn off default definition of DEFINE_GUIDEX */
#undef DEFINE_GUID #undef DEFINE_GUID
#if defined(__clang__) || (defined(_MSVC_TRADITIONAL) && !_MSVC_TRADITIONAL) /* clang-cl and new msvc preprocessor: avoid too many arguments error */ #if defined(__clang__) || (defined(_MSVC_TRADITIONAL) && !_MSVC_TRADITIONAL) /* clang-cl and new msvc preprocessor: avoid too many arguments error */
#define DEFINE_GUID(n, ...) EXTERN_C const GUID n = {__VA_ARGS__} #define DEFINE_GUID(n, ...) EXTERN_C const GUID n = {__VA_ARGS__}
#define DEFINE_GUID_THUNK(n, ...) DEFINE_GUID(n, __VA_ARGS__) #define DEFINE_GUID_THUNK(n, ...) DEFINE_GUID(n, __VA_ARGS__)
#define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n) #define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n)
#else #else
#define DEFINE_GUID(n, data) EXTERN_C const GUID n = {data} #define DEFINE_GUID(n, data) EXTERN_C const GUID n = {data}
#define DEFINE_GUID_THUNK(n, data) DEFINE_GUID(n, data) #define DEFINE_GUID_THUNK(n, data) DEFINE_GUID(n, data)
#define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n) #define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n)
#endif /* __clang__, !_MSVC_TRADITIONAL */ #endif /* __clang__, !_MSVC_TRADITIONAL */
#endif #endif
@ -229,7 +229,7 @@ typedef struct
static PaWinWDMKSAvRtEntryPoints paWinWDMKSAvRtEntryPoints = {0}; static PaWinWDMKSAvRtEntryPoints paWinWDMKSAvRtEntryPoints = {0};
/* An unspecified channel count (-1) is not treated correctly, so we replace it with /* An unspecified channel count (-1) is not treated correctly, so we replace it with
* an arbitrarily large number */ * an arbitrarily large number */
#define MAXIMUM_NUMBER_OF_CHANNELS 256 #define MAXIMUM_NUMBER_OF_CHANNELS 256
/* Forward definition to break circular type reference between pin and filter */ /* Forward definition to break circular type reference between pin and filter */
@ -371,7 +371,7 @@ typedef struct __PaWinWdmIOInfo
HANDLE *events; /* noOfPackets handles (WaveCyclic) 1 (WaveRT) */ HANDLE *events; /* noOfPackets handles (WaveCyclic) 1 (WaveRT) */
DATAPACKET *packets; /* noOfPackets packets (WaveCyclic) 2 (WaveRT) */ DATAPACKET *packets; /* noOfPackets packets (WaveCyclic) 2 (WaveRT) */
/* WaveRT polled mode */ /* WaveRT polled mode */
unsigned lastPosition; unsigned lastPosition;
unsigned pollCntr; unsigned pollCntr;
} PaWinWdmIOInfo; } PaWinWdmIOInfo;
@ -414,7 +414,7 @@ struct __PaWinWdmStream
}; };
/* Gather all processing variables in a struct */ /* Gather all processing variables in a struct */
struct __PaProcessThreadInfo struct __PaProcessThreadInfo
{ {
PaWinWdmStream *stream; PaWinWdmStream *stream;
PaStreamCallbackTimeInfo ti; PaStreamCallbackTimeInfo ti;
@ -434,7 +434,7 @@ struct __PaProcessThreadInfo
/* Used for transferring device infos during scanning / rescanning */ /* Used for transferring device infos during scanning / rescanning */
typedef struct __PaWinWDMScanDeviceInfosResults typedef struct __PaWinWDMScanDeviceInfosResults
{ {
PaDeviceInfo **deviceInfos; PaDeviceInfo **deviceInfos;
PaDeviceIndex defaultInputDevice; PaDeviceIndex defaultInputDevice;
PaDeviceIndex defaultOutputDevice; PaDeviceIndex defaultOutputDevice;
@ -735,9 +735,9 @@ static PaError WdmSyncIoctl(
if (!bRes) if (!bRes)
{ {
unsigned long error = GetLastError(); unsigned long error = GetLastError();
if ( !(((error == ERROR_INSUFFICIENT_BUFFER ) || ( error == ERROR_MORE_DATA )) && if ( !(((error == ERROR_INSUFFICIENT_BUFFER ) || ( error == ERROR_MORE_DATA )) &&
( ioctlNumber == IOCTL_KS_PROPERTY ) && ( ioctlNumber == IOCTL_KS_PROPERTY ) &&
( outBufferCount == 0 ) ) ) ( outBufferCount == 0 ) ) )
{ {
KSPROPERTY* ksProperty = (KSPROPERTY*)inBuffer; KSPROPERTY* ksProperty = (KSPROPERTY*)inBuffer;
@ -1092,15 +1092,15 @@ static const KSTOPOLOGY_CONNECTION* FindStartConnectionTo(ULONG startPin, PaWinW
static ULONG GetConnectedPin(ULONG startPin, BOOL forward, PaWinWdmFilter* filter, int muxPosition, ULONG *muxInputPinId, ULONG *muxNodeId) static ULONG GetConnectedPin(ULONG startPin, BOOL forward, PaWinWdmFilter* filter, int muxPosition, ULONG *muxInputPinId, ULONG *muxNodeId)
{ {
int limit=1000; int limit=1000;
const KSTOPOLOGY_CONNECTION *conn = NULL; const KSTOPOLOGY_CONNECTION *conn = NULL;
TFnGetConnection fnGetConnection = forward ? GetConnectionTo : GetConnectionFrom ; TFnGetConnection fnGetConnection = forward ? GetConnectionTo : GetConnectionFrom ;
PA_LOGE_; PA_LOGE_;
while (1) while (1)
{ {
limit--; limit--;
if (limit == 0) { if (limit == 0) {
PA_DEBUG(("GetConnectedPin: LOOP LIMIT REACHED\n")); PA_DEBUG(("GetConnectedPin: LOOP LIMIT REACHED\n"));
break; break;
} }
if (conn == NULL) if (conn == NULL)
@ -1164,7 +1164,7 @@ static void DumpConnectionsAndNodes(PaWinWdmFilter* filter)
for (i=0; i < filter->connections->Count; ++i) for (i=0; i < filter->connections->Count; ++i)
{ {
const KSTOPOLOGY_CONNECTION* pConn = connections + i; const KSTOPOLOGY_CONNECTION* pConn = connections + i;
PA_DEBUG((" Connection: %u - FromNode=%u,FromPin=%u -> ToNode=%u,ToPin=%u\n", PA_DEBUG((" Connection: %u - FromNode=%u,FromPin=%u -> ToNode=%u,ToPin=%u\n",
i, i,
pConn->FromNode, pConn->FromNodePin, pConn->FromNode, pConn->FromNodePin,
pConn->ToNode, pConn->ToNodePin pConn->ToNode, pConn->ToNodePin
@ -1187,7 +1187,7 @@ static void DumpConnectionsAndNodes(PaWinWdmFilter* filter)
} }
typedef struct __PaUsbTerminalGUIDToName typedef struct __PaUsbTerminalGUIDToName
{ {
USHORT usbGUID; USHORT usbGUID;
wchar_t name[64]; wchar_t name[64];
@ -1797,7 +1797,7 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
PA_DEBUG(("PinNew: Pin name '%s'\n", pin->friendlyName)); PA_DEBUG(("PinNew: Pin name '%s'\n", pin->friendlyName));
#else #else
PA_DEBUG(("PinNew: Pin name '%S'\n", pin->friendlyName)); PA_DEBUG(("PinNew: Pin name '%S'\n", pin->friendlyName));
#endif #endif
/* Set endpoint pin ID (this is the topology INPUT pin, since portmixer will always traverse the /* Set endpoint pin ID (this is the topology INPUT pin, since portmixer will always traverse the
filter in audio streaming direction, see http://msdn.microsoft.com/en-us/library/windows/hardware/ff536331(v=vs.85).aspx filter in audio streaming direction, see http://msdn.microsoft.com/en-us/library/windows/hardware/ff536331(v=vs.85).aspx
@ -1927,7 +1927,7 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
FALSE, FALSE,
pin->parentFilter->topologyFilter, pin->parentFilter->topologyFilter,
muxPos, muxPos,
&pin->inputs[i]->muxPinId, &pin->inputs[i]->muxPinId,
&pin->inputs[i]->muxNodeId); &pin->inputs[i]->muxNodeId);
if (endpointPinId != KSFILTER_NODE) if (endpointPinId != KSFILTER_NODE)
@ -2232,7 +2232,7 @@ static PaError PinIsFormatSupported(PaWinWdmPin* pin, const WAVEFORMATEX* format
dataRange = (KSDATARANGE_AUDIO*)pin->dataRanges; dataRange = (KSDATARANGE_AUDIO*)pin->dataRanges;
for(count = 0; for(count = 0;
count<pin->dataRangesItem->Count; count<pin->dataRangesItem->Count;
count++, count++,
dataRange = (KSDATARANGE_AUDIO*)( ((char*)dataRange) + dataRange->DataRange.FormatSize)) /* Need to update dataRange here, due to 'continue' !! */ dataRange = (KSDATARANGE_AUDIO*)( ((char*)dataRange) + dataRange->DataRange.FormatSize)) /* Need to update dataRange here, due to 'continue' !! */
{ {
/* Check major format*/ /* Check major format*/
@ -2263,7 +2263,7 @@ static PaError PinIsFormatSupported(PaWinWdmPin* pin, const WAVEFORMATEX* format
PA_DEBUG(("\tBits:%d-%d\n",dataRange->MinimumBitsPerSample,dataRange->MaximumBitsPerSample)); PA_DEBUG(("\tBits:%d-%d\n",dataRange->MinimumBitsPerSample,dataRange->MaximumBitsPerSample));
PA_DEBUG(("\tSampleRate:%d-%d\n",dataRange->MinimumSampleFrequency,dataRange->MaximumSampleFrequency)); PA_DEBUG(("\tSampleRate:%d-%d\n",dataRange->MinimumSampleFrequency,dataRange->MaximumSampleFrequency));
if( dataRange->MaximumChannels != (ULONG)-1 && if( dataRange->MaximumChannels != (ULONG)-1 &&
dataRange->MaximumChannels < format->nChannels ) dataRange->MaximumChannels < format->nChannels )
{ {
result = paInvalidChannelCount; result = paInvalidChannelCount;
@ -2320,7 +2320,7 @@ static PaError PinQueryNotificationSupport(PaWinWdmPin* pPin, BOOL* pbResult)
sizeof(BOOL), sizeof(BOOL),
NULL); NULL);
if (result != paNoError) if (result != paNoError)
{ {
PA_DEBUG(("Failed PinQueryNotificationSupport\n")); PA_DEBUG(("Failed PinQueryNotificationSupport\n"));
} }
@ -2351,13 +2351,13 @@ static PaError PinGetBufferWithNotification(PaWinWdmPin* pPin, void** pBuffer, D
sizeof(KSRTAUDIO_BUFFER), sizeof(KSRTAUDIO_BUFFER),
NULL); NULL);
if (result == paNoError) if (result == paNoError)
{ {
*pBuffer = propOut.BufferAddress; *pBuffer = propOut.BufferAddress;
*pRequestedBufSize = propOut.ActualBufferSize; *pRequestedBufSize = propOut.ActualBufferSize;
*pbCallMemBarrier = propOut.CallMemoryBarrier; *pbCallMemBarrier = propOut.CallMemoryBarrier;
} }
else else
{ {
PA_DEBUG(("Failed to get buffer with notification\n")); PA_DEBUG(("Failed to get buffer with notification\n"));
} }
@ -2393,7 +2393,7 @@ static PaError PinGetBufferWithoutNotification(PaWinWdmPin* pPin, void** pBuffer
*pRequestedBufSize = propOut.ActualBufferSize; *pRequestedBufSize = propOut.ActualBufferSize;
*pbCallMemBarrier = propOut.CallMemoryBarrier; *pbCallMemBarrier = propOut.CallMemoryBarrier;
} }
else else
{ {
PA_DEBUG(("Failed to get buffer without notification\n")); PA_DEBUG(("Failed to get buffer without notification\n"));
} }
@ -2423,8 +2423,8 @@ static PaError PinGetBuffer(PaWinWdmPin* pPin, void** pBuffer, DWORD* pRequested
{ {
limit--; limit--;
if (limit == 0) { if (limit == 0) {
PA_DEBUG(("PinGetBuffer: LOOP LIMIT REACHED\n")); PA_DEBUG(("PinGetBuffer: LOOP LIMIT REACHED\n"));
break; break;
} }
if (pPin->pinKsSubType != SubType_kPolled) if (pPin->pinKsSubType != SubType_kPolled)
@ -2474,7 +2474,7 @@ static PaError PinGetBuffer(PaWinWdmPin* pPin, void** pBuffer, DWORD* pRequested
return result; return result;
} }
static PaError PinRegisterPositionRegister(PaWinWdmPin* pPin) static PaError PinRegisterPositionRegister(PaWinWdmPin* pPin)
{ {
PaError result = paNoError; PaError result = paNoError;
KSRTAUDIO_HWREGISTER_PROPERTY propIn; KSRTAUDIO_HWREGISTER_PROPERTY propIn;
@ -2494,7 +2494,7 @@ static PaError PinRegisterPositionRegister(PaWinWdmPin* pPin)
sizeof(KSRTAUDIO_HWREGISTER), sizeof(KSRTAUDIO_HWREGISTER),
NULL); NULL);
if (result == paNoError) if (result == paNoError)
{ {
pPin->positionRegister = (ULONG*)propOut.Register; pPin->positionRegister = (ULONG*)propOut.Register;
} }
@ -2508,7 +2508,7 @@ static PaError PinRegisterPositionRegister(PaWinWdmPin* pPin)
return result; return result;
} }
static PaError PinRegisterNotificationHandle(PaWinWdmPin* pPin, HANDLE handle) static PaError PinRegisterNotificationHandle(PaWinWdmPin* pPin, HANDLE handle)
{ {
PaError result = paNoError; PaError result = paNoError;
KSRTAUDIO_NOTIFICATION_EVENT_PROPERTY prop; KSRTAUDIO_NOTIFICATION_EVENT_PROPERTY prop;
@ -2537,7 +2537,7 @@ static PaError PinRegisterNotificationHandle(PaWinWdmPin* pPin, HANDLE handle)
return result; return result;
} }
static PaError PinUnregisterNotificationHandle(PaWinWdmPin* pPin, HANDLE handle) static PaError PinUnregisterNotificationHandle(PaWinWdmPin* pPin, HANDLE handle)
{ {
PaError result = paNoError; PaError result = paNoError;
KSRTAUDIO_NOTIFICATION_EVENT_PROPERTY prop; KSRTAUDIO_NOTIFICATION_EVENT_PROPERTY prop;
@ -2681,7 +2681,7 @@ static PaError PinGetAudioPositionViaIOCTLWrite(PaWinWdmPin* pPin, ULONG* pPosit
/***********************************************************************************************/ /***********************************************************************************************/
/** /**
* Create a new filter object. * Create a new filter object.
*/ */
static PaWinWdmFilter* FilterNew( PaWDMKSType type, DWORD devNode, const wchar_t* filterName, const wchar_t* friendlyName, PaError* error ) static PaWinWdmFilter* FilterNew( PaWDMKSType type, DWORD devNode, const wchar_t* filterName, const wchar_t* friendlyName, PaError* error )
{ {
@ -2828,7 +2828,7 @@ PaError FilterInitializePins( PaWinWdmFilter* filter )
return paNoError; return paNoError;
if (filter->pins != NULL) if (filter->pins != NULL)
return paNoError; return paNoError;
/* Allocate pointer array to hold the pins */ /* Allocate pointer array to hold the pins */
filter->pins = (PaWinWdmPin**)PaUtil_AllocateMemory( sizeof(PaWinWdmPin*) * filter->pinCount ); filter->pins = (PaWinWdmPin**)PaUtil_AllocateMemory( sizeof(PaWinWdmPin*) * filter->pinCount );
@ -3054,10 +3054,10 @@ static void TrimString(wchar_t* str, size_t length)
/** /**
* Build the list of available filters * Build the list of available filters
* Use the SetupDi API to enumerate all devices in the KSCATEGORY_AUDIO which * Use the SetupDi API to enumerate all devices in the KSCATEGORY_AUDIO which
* have a KSCATEGORY_RENDER or KSCATEGORY_CAPTURE alias. For each of these * have a KSCATEGORY_RENDER or KSCATEGORY_CAPTURE alias. For each of these
* devices initialise a PaWinWdmFilter structure by calling our NewFilter() * devices initialise a PaWinWdmFilter structure by calling our NewFilter()
* function. We enumerate devices twice, once to count how many there are, * function. We enumerate devices twice, once to count how many there are,
* and once to initialize the PaWinWdmFilter structures. * and once to initialize the PaWinWdmFilter structures.
* *
* Vista and later: Also check KSCATEGORY_REALTIME for WaveRT devices. * Vista and later: Also check KSCATEGORY_REALTIME for WaveRT devices.
@ -3235,7 +3235,7 @@ PaWinWdmFilter** BuildFilterList( int* pFilterCount, int* pNoOfPaDevices, PaErro
very literate. */ very literate. */
if (!SetupDiGetDeviceRegistryPropertyW(handle, if (!SetupDiGetDeviceRegistryPropertyW(handle,
&devInfoData, &devInfoData,
SPDRP_LOCATION_INFORMATION, SPDRP_LOCATION_INFORMATION,
&type, &type,
(BYTE*)friendlyName, (BYTE*)friendlyName,
sizeof(friendlyName), sizeof(friendlyName),
@ -3269,7 +3269,7 @@ PaWinWdmFilter** BuildFilterList( int* pFilterCount, int* pNoOfPaDevices, PaErro
TrimString(friendlyName, sizeFriendlyName); TrimString(friendlyName, sizeFriendlyName);
newFilter = FilterNew(streamingType, newFilter = FilterNew(streamingType,
devInfoData.DevInst, devInfoData.DevInst,
devInterfaceDetails->DevicePath, devInterfaceDetails->DevicePath,
friendlyName, friendlyName,
@ -3350,7 +3350,7 @@ static ULONG GetNameHash(const wchar_t* str, const BOOL input)
static PaError CreateHashEntry(PaNameHashObject* obj, const wchar_t* name, const BOOL input) static PaError CreateHashEntry(PaNameHashObject* obj, const wchar_t* name, const BOOL input)
{ {
ULONG hash = GetNameHash(name, input); ULONG hash = GetNameHash(name, input);
PaNameHashIndex * pLast = NULL; PaNameHashIndex * pLast = NULL;
PaNameHashIndex * p = obj->list; PaNameHashIndex * p = obj->list;
while (p != 0) while (p != 0)
@ -3432,7 +3432,7 @@ static void DeinitNameHashObject(PaNameHashObject* obj)
static unsigned GetNameIndex(PaNameHashObject* obj, const wchar_t* name, const BOOL input) static unsigned GetNameIndex(PaNameHashObject* obj, const wchar_t* name, const BOOL input)
{ {
ULONG hash = GetNameHash(name, input); ULONG hash = GetNameHash(name, input);
PaNameHashIndex* p = obj->list; PaNameHashIndex* p = obj->list;
while (p != NULL) while (p != NULL)
{ {
@ -3653,7 +3653,7 @@ static PaError ScanDeviceInfos( struct PaUtilHostApiRepresentation *hostApi, PaH
case Type_kWaveCyclic: case Type_kWaveCyclic:
if (IsEarlierThanVista()) if (IsEarlierThanVista())
{ {
/* XP doesn't tolerate low latency, unless the Process Priority Class is set to REALTIME_PRIORITY_CLASS /* XP doesn't tolerate low latency, unless the Process Priority Class is set to REALTIME_PRIORITY_CLASS
through SetPriorityClass, then 10 ms is quite feasible. However, one should then bear in mind that ALL of through SetPriorityClass, then 10 ms is quite feasible. However, one should then bear in mind that ALL of
the process is running in REALTIME_PRIORITY_CLASS, which might not be appropriate for an application with the process is running in REALTIME_PRIORITY_CLASS, which might not be appropriate for an application with
a GUI . In this case it is advisable to separate the audio engine in another process and use IPC to communicate a GUI . In this case it is advisable to separate the audio engine in another process and use IPC to communicate
@ -4016,7 +4016,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
/* Check that the input format is supported */ /* Check that the input format is supported */
channelMask = PaWin_DefaultChannelMask(inputChannelCount); channelMask = PaWin_DefaultChannelMask(inputChannelCount);
PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx,
inputChannelCount, inputChannelCount,
testFormat, testFormat,
PaWin_SampleFormatToLinearWaveFormatTag(testFormat), PaWin_SampleFormatToLinearWaveFormatTag(testFormat),
sampleRate, sampleRate,
@ -4031,7 +4031,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
{ {
/* Try a WAVE_FORMAT_PCM instead */ /* Try a WAVE_FORMAT_PCM instead */
PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx,
inputChannelCount, inputChannelCount,
testFormat, testFormat,
PaWin_SampleFormatToLinearWaveFormatTag(testFormat), PaWin_SampleFormatToLinearWaveFormatTag(testFormat),
sampleRate); sampleRate);
@ -4127,7 +4127,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
/* Check that the output format is supported */ /* Check that the output format is supported */
channelMask = PaWin_DefaultChannelMask(outputChannelCount); channelMask = PaWin_DefaultChannelMask(outputChannelCount);
PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx,
outputChannelCount, outputChannelCount,
testFormat, testFormat,
PaWin_SampleFormatToLinearWaveFormatTag(testFormat), PaWin_SampleFormatToLinearWaveFormatTag(testFormat),
sampleRate, sampleRate,
@ -4143,7 +4143,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
{ {
/* Try a WAVE_FORMAT_PCM instead */ /* Try a WAVE_FORMAT_PCM instead */
PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx,
outputChannelCount, outputChannelCount,
testFormat, testFormat,
PaWin_SampleFormatToLinearWaveFormatTag(testFormat), PaWin_SampleFormatToLinearWaveFormatTag(testFormat),
sampleRate); sampleRate);
@ -4197,7 +4197,7 @@ static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
return result; return result;
} }
static void ResetStreamEvents(PaWinWdmStream* stream) static void ResetStreamEvents(PaWinWdmStream* stream)
{ {
unsigned i; unsigned i;
ResetEvent(stream->eventAbort); ResetEvent(stream->eventAbort);
@ -4221,7 +4221,7 @@ static void ResetStreamEvents(PaWinWdmStream* stream)
} }
} }
static void CloseStreamEvents(PaWinWdmStream* stream) static void CloseStreamEvents(PaWinWdmStream* stream)
{ {
unsigned i; unsigned i;
PaWinWdmIOInfo* ios[2] = { &stream->capture, &stream->render }; PaWinWdmIOInfo* ios[2] = { &stream->capture, &stream->render };
@ -4506,7 +4506,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
while (1) while (1)
{ {
PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx,
channelsToProbe, channelsToProbe,
hostInputSampleFormat, hostInputSampleFormat,
PaWin_SampleFormatToLinearWaveFormatTag(hostInputSampleFormat), PaWin_SampleFormatToLinearWaveFormatTag(hostInputSampleFormat),
sampleRate, sampleRate,
@ -4523,7 +4523,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
{ {
/* Try a WAVE_FORMAT_PCM instead */ /* Try a WAVE_FORMAT_PCM instead */
PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx,
channelsToProbe, channelsToProbe,
hostInputSampleFormat, hostInputSampleFormat,
PaWin_SampleFormatToLinearWaveFormatTag(hostInputSampleFormat), PaWin_SampleFormatToLinearWaveFormatTag(hostInputSampleFormat),
sampleRate); sampleRate);
@ -4658,7 +4658,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
while (1) while (1)
{ {
PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatExtensible((PaWinWaveFormat*)&wfx,
channelsToProbe, channelsToProbe,
hostOutputSampleFormat, hostOutputSampleFormat,
PaWin_SampleFormatToLinearWaveFormatTag(hostOutputSampleFormat), PaWin_SampleFormatToLinearWaveFormatTag(hostOutputSampleFormat),
sampleRate, sampleRate,
@ -4674,7 +4674,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if( result != paNoError && result != paDeviceUnavailable ) if( result != paNoError && result != paDeviceUnavailable )
{ {
PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx, PaWin_InitializeWaveFormatEx((PaWinWaveFormat*)&wfx,
channelsToProbe, channelsToProbe,
hostOutputSampleFormat, hostOutputSampleFormat,
PaWin_SampleFormatToLinearWaveFormatTag(hostOutputSampleFormat), PaWin_SampleFormatToLinearWaveFormatTag(hostOutputSampleFormat),
sampleRate); sampleRate);
@ -4797,7 +4797,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->userInputChannels, inputSampleFormat, hostInputSampleFormat, stream->userInputChannels, inputSampleFormat, hostInputSampleFormat,
stream->userOutputChannels, outputSampleFormat, hostOutputSampleFormat, stream->userOutputChannels, outputSampleFormat, hostOutputSampleFormat,
sampleRate, streamFlags, framesPerUserBuffer, sampleRate, streamFlags, framesPerUserBuffer,
max(stream->capture.framesPerBuffer, stream->render.framesPerBuffer), max(stream->capture.framesPerBuffer, stream->render.framesPerBuffer),
paUtilBoundedHostBufferSize, paUtilBoundedHostBufferSize,
streamCallback, userData ); streamCallback, userData );
if( result != paNoError ) if( result != paNoError )
@ -4844,7 +4844,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
ULONG hwFifoLatency = 0; ULONG hwFifoLatency = 0;
ULONG dummy; ULONG dummy;
result = PinGetBuffer(stream->capture.pPin, (void**)&stream->capture.hostBuffer, &dwRequestedSize, &bCallMemoryBarrier); result = PinGetBuffer(stream->capture.pPin, (void**)&stream->capture.hostBuffer, &dwRequestedSize, &bCallMemoryBarrier);
if (!result) if (!result)
{ {
PA_DEBUG(("Input buffer start = %p, size = %u\n", stream->capture.hostBuffer, dwRequestedSize)); PA_DEBUG(("Input buffer start = %p, size = %u\n", stream->capture.hostBuffer, dwRequestedSize));
if (dwRequestedSize != dwTotalSize) if (dwRequestedSize != dwTotalSize)
@ -4868,7 +4868,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->capture.pPin->fnMemBarrier = bCallMemoryBarrier ? MemoryBarrierRead : MemoryBarrierDummy; stream->capture.pPin->fnMemBarrier = bCallMemoryBarrier ? MemoryBarrierRead : MemoryBarrierDummy;
} }
else else
{ {
PA_DEBUG(("Failed to get input buffer (WaveRT)\n")); PA_DEBUG(("Failed to get input buffer (WaveRT)\n"));
PaWinWDM_SetLastErrorInfo(paUnanticipatedHostError, "Failed to get input buffer (WaveRT)"); PaWinWDM_SetLastErrorInfo(paUnanticipatedHostError, "Failed to get input buffer (WaveRT)");
@ -4900,7 +4900,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
goto error; goto error;
} }
} }
else else
{ {
stream->capture.hostBuffer = 0; stream->capture.hostBuffer = 0;
} }
@ -4939,7 +4939,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
ULONG hwFifoLatency = 0; ULONG hwFifoLatency = 0;
ULONG dummy; ULONG dummy;
result = PinGetBuffer(stream->render.pPin, (void**)&stream->render.hostBuffer, &dwRequestedSize, &bCallMemoryBarrier); result = PinGetBuffer(stream->render.pPin, (void**)&stream->render.hostBuffer, &dwRequestedSize, &bCallMemoryBarrier);
if (!result) if (!result)
{ {
PA_DEBUG(("Output buffer start = %p, size = %u, membarrier = %u\n", stream->render.hostBuffer, dwRequestedSize, bCallMemoryBarrier)); PA_DEBUG(("Output buffer start = %p, size = %u, membarrier = %u\n", stream->render.hostBuffer, dwRequestedSize, bCallMemoryBarrier));
if (dwRequestedSize != dwTotalSize) if (dwRequestedSize != dwTotalSize)
@ -4963,7 +4963,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
stream->render.pPin->fnMemBarrier = bCallMemoryBarrier ? MemoryBarrierWrite : MemoryBarrierDummy; stream->render.pPin->fnMemBarrier = bCallMemoryBarrier ? MemoryBarrierWrite : MemoryBarrierDummy;
} }
else else
{ {
PA_DEBUG(("Failed to get output buffer (with notification)\n")); PA_DEBUG(("Failed to get output buffer (with notification)\n"));
PaWinWDM_SetLastErrorInfo(paUnanticipatedHostError, "Failed to get output buffer (with notification)"); PaWinWDM_SetLastErrorInfo(paUnanticipatedHostError, "Failed to get output buffer (with notification)");
@ -4995,7 +4995,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
goto error; goto error;
} }
} }
else else
{ {
stream->render.hostBuffer = 0; stream->render.hostBuffer = 0;
} }
@ -5121,7 +5121,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
PaWinWDM_SetLastErrorInfo(paUnanticipatedHostError, "Failed to read capture position register (IOCTL)"); PaWinWDM_SetLastErrorInfo(paUnanticipatedHostError, "Failed to read capture position register (IOCTL)");
result = paUnanticipatedHostError; result = paUnanticipatedHostError;
goto error; goto error;
} }
} }
else else
{ {
@ -5516,19 +5516,19 @@ static void DuplicateFirstChannelInt32(void* buffer, int channels, int samples)
} }
/* /*
Increase the priority of the calling thread to RT Increase the priority of the calling thread to RT
*/ */
static HANDLE BumpThreadPriority() static HANDLE BumpThreadPriority()
{ {
HANDLE hThread = GetCurrentThread(); HANDLE hThread = GetCurrentThread();
DWORD dwTask = 0; DWORD dwTask = 0;
HANDLE hAVRT = NULL; HANDLE hAVRT = NULL;
/* If we have access to AVRT.DLL (Vista and later), use it */ /* If we have access to AVRT.DLL (Vista and later), use it */
if (paWinWDMKSAvRtEntryPoints.AvSetMmThreadCharacteristics != NULL) if (paWinWDMKSAvRtEntryPoints.AvSetMmThreadCharacteristics != NULL)
{ {
hAVRT = paWinWDMKSAvRtEntryPoints.AvSetMmThreadCharacteristics("Pro Audio", &dwTask); hAVRT = paWinWDMKSAvRtEntryPoints.AvSetMmThreadCharacteristics("Pro Audio", &dwTask);
if (hAVRT != NULL && hAVRT != INVALID_HANDLE_VALUE) if (hAVRT != NULL && hAVRT != INVALID_HANDLE_VALUE)
{ {
BOOL bret = paWinWDMKSAvRtEntryPoints.AvSetMmThreadPriority(hAVRT, PA_AVRT_PRIORITY_CRITICAL); BOOL bret = paWinWDMKSAvRtEntryPoints.AvSetMmThreadPriority(hAVRT, PA_AVRT_PRIORITY_CRITICAL);
if (!bret) if (!bret)
@ -5565,7 +5565,7 @@ static void DropThreadPriority(HANDLE hAVRT)
{ {
HANDLE hThread = GetCurrentThread(); HANDLE hThread = GetCurrentThread();
if (hAVRT != NULL) if (hAVRT != NULL)
{ {
paWinWDMKSAvRtEntryPoints.AvSetMmThreadPriority(hAVRT, PA_AVRT_PRIORITY_NORMAL); paWinWDMKSAvRtEntryPoints.AvSetMmThreadPriority(hAVRT, PA_AVRT_PRIORITY_NORMAL);
paWinWDMKSAvRtEntryPoints.AvRevertMmThreadCharacteristics(hAVRT); paWinWDMKSAvRtEntryPoints.AvRevertMmThreadCharacteristics(hAVRT);
@ -5635,7 +5635,7 @@ static PaError PreparePinsForStart(PaProcessThreadInfo* pInfo)
pInfo->priming += pInfo->stream->render.noOfPackets; pInfo->priming += pInfo->stream->render.noOfPackets;
++pInfo->pending; ++pInfo->pending;
SetEvent(pInfo->stream->render.events[0]); SetEvent(pInfo->stream->render.events[0]);
if (pInfo->stream->render.pPin->parentFilter->devInfo.streamingType == Type_kWaveCyclic) if (pInfo->stream->render.pPin->parentFilter->devInfo.streamingType == Type_kWaveCyclic)
{ {
unsigned i; unsigned i;
for(i=1; i < pInfo->stream->render.noOfPackets; ++i) for(i=1; i < pInfo->stream->render.noOfPackets; ++i)
@ -5805,7 +5805,7 @@ static PaError PaDoProcessing(PaProcessThreadInfo* pInfo)
framesProcessed = 0; framesProcessed = 0;
} }
} }
else else
{ {
framesProcessed = PaUtil_EndBufferProcessing(&pInfo->stream->bufferProcessor, &pInfo->cbResult); framesProcessed = PaUtil_EndBufferProcessing(&pInfo->stream->bufferProcessor, &pInfo->cbResult);
} }
@ -5951,7 +5951,7 @@ PA_THREAD_FUNC ProcessingThread(void* pParam)
assert(noOfHandles <= (info.stream->capture.noOfPackets + info.stream->render.noOfPackets + 1)); assert(noOfHandles <= (info.stream->capture.noOfPackets + info.stream->render.noOfPackets + 1));
/* Prepare render and capture pins */ /* Prepare render and capture pins */
if ((result = PreparePinsForStart(&info)) != paNoError) if ((result = PreparePinsForStart(&info)) != paNoError)
{ {
PA_DEBUG(("Failed to prepare device(s)!\n")); PA_DEBUG(("Failed to prepare device(s)!\n"));
goto error; goto error;
@ -6032,7 +6032,7 @@ PA_THREAD_FUNC ProcessingThread(void* pParam)
unsigned eventSignalled = wait - WAIT_OBJECT_0; unsigned eventSignalled = wait - WAIT_OBJECT_0;
DWORD dwCurrentTime = 0; DWORD dwCurrentTime = 0;
if (wait == WAIT_FAILED) if (wait == WAIT_FAILED)
{ {
PA_DEBUG(("Wait failed = %ld! \n",wait)); PA_DEBUG(("Wait failed = %ld! \n",wait));
break; break;
@ -6065,7 +6065,7 @@ PA_THREAD_FUNC ProcessingThread(void* pParam)
/* Get event time */ /* Get event time */
dwCurrentTime = GetCurrentTimeInMillisecs(); dwCurrentTime = GetCurrentTimeInMillisecs();
/* Since we can mix capture/render devices between WaveCyclic, WaveRT polled and WaveRT notification (3x3 combinations), /* Since we can mix capture/render devices between WaveCyclic, WaveRT polled and WaveRT notification (3x3 combinations),
we can't rely on the timeout of WFMO to check for device timeouts, we need to keep tally. */ we can't rely on the timeout of WFMO to check for device timeouts, we need to keep tally. */
if (info.stream->capture.pPin && (dwCurrentTime - timeStamp[0]) >= info.timeout) if (info.stream->capture.pPin && (dwCurrentTime - timeStamp[0]) >= info.timeout)
{ {
@ -6524,7 +6524,7 @@ static PaError PaPinCaptureEventHandler_WaveCyclic(PaProcessThreadInfo* pInfo, u
{ {
PA_HP_TRACE((pInfo->stream->hLog, ">>> Capture bogus event (no data): idx=%u", eventIndex)); PA_HP_TRACE((pInfo->stream->hLog, ">>> Capture bogus event (no data): idx=%u", eventIndex));
/* Bogus event, reset! This is to handle the behavior of this USB mic: http://shop.xtz.se/measurement-system/microphone-to-dirac-live-room-correction-suite /* Bogus event, reset! This is to handle the behavior of this USB mic: http://shop.xtz.se/measurement-system/microphone-to-dirac-live-room-correction-suite
on startup of streaming, where it erroneously sets the event without the corresponding buffer being filled (DataUsed == 0) */ on startup of streaming, where it erroneously sets the event without the corresponding buffer being filled (DataUsed == 0) */
ResetEvent(packet->Signal.hEvent); ResetEvent(packet->Signal.hEvent);