pa_win_wmme.c: converted tabs to spaces (just a few sections)

This commit is contained in:
rbencina 2014-04-11 05:31:13 +00:00
commit 9222d8bfb4

View file

@ -62,7 +62,7 @@
*/ */
/** @file /** @file
@ingroup hostapi_src @ingroup hostapi_src
@brief Win32 host API implementation for the Windows MultiMedia Extensions (WMME) audio API. @brief Win32 host API implementation for the Windows MultiMedia Extensions (WMME) audio API.
*/ */
@ -207,7 +207,7 @@ static const char constOutputMapperSuffix_[] = " - Output";
static char *CopyTCharStringToUtf8CString(char *destination, size_t destLengthBytes, const TCHAR *source) static char *CopyTCharStringToUtf8CString(char *destination, size_t destLengthBytes, const TCHAR *source)
{ {
#if !defined(_UNICODE) && !defined(UNICODE) #if !defined(_UNICODE) && !defined(UNICODE)
return strcpy(destination, source); return strcpy(destination, source);
#else #else
/* The cbMultiByte parameter ["destLengthBytes" below] is: /* The cbMultiByte parameter ["destLengthBytes" below] is:
""" """
@ -218,9 +218,9 @@ static char *CopyTCharStringToUtf8CString(char *destination, size_t destLengthBy
Source: WideCharToMultiByte at MSDN: Source: WideCharToMultiByte at MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130(v=vs.85).aspx
*/ */
if (WideCharToMultiByte(CP_UTF8, 0, source, -1, destination, (int)destLengthBytes, NULL, NULL) == 0) if (WideCharToMultiByte(CP_UTF8, 0, source, -1, destination, (int)destLengthBytes, NULL, NULL) == 0)
return NULL; return NULL;
return destination; return destination;
#endif #endif
} }
@ -229,9 +229,9 @@ static char *CopyTCharStringToUtf8CString(char *destination, size_t destLengthBy
static size_t TCharStringLen(const TCHAR *str) static size_t TCharStringLen(const TCHAR *str)
{ {
#if !defined(_UNICODE) && !defined(UNICODE) #if !defined(_UNICODE) && !defined(UNICODE)
return strlen(str); return strlen(str);
#else #else
return WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL); return WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
#endif #endif
} }
@ -497,7 +497,7 @@ static UINT LocalDeviceIndexToWinMmeDeviceId( PaWinMmeHostApiRepresentation *hos
{ {
assert( device >= 0 && device < hostApi->inputDeviceCount + hostApi->outputDeviceCount ); assert( device >= 0 && device < hostApi->inputDeviceCount + hostApi->outputDeviceCount );
return hostApi->winMmeDeviceIds[ device ]; return hostApi->winMmeDeviceIds[ device ];
} }
@ -853,7 +853,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
len = TCharStringLen( woc.szPname ) + 1 + sizeof(constOutputMapperSuffix_); len = TCharStringLen( woc.szPname ) + 1 + sizeof(constOutputMapperSuffix_);
deviceName = (char*)PaUtil_GroupAllocateMemory( deviceName = (char*)PaUtil_GroupAllocateMemory(
winMmeHostApi->allocations, winMmeHostApi->allocations,
(long)len ); (long)len );
if( !deviceName ) if( !deviceName )
{ {
result = paInsufficientMemory; result = paInsufficientMemory;
@ -867,7 +867,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
len = TCharStringLen( woc.szPname ) + 1; len = TCharStringLen( woc.szPname ) + 1;
deviceName = (char*)PaUtil_GroupAllocateMemory( deviceName = (char*)PaUtil_GroupAllocateMemory(
winMmeHostApi->allocations, winMmeHostApi->allocations,
(long)len ); (long)len );
if( !deviceName ) if( !deviceName )
{ {
result = paInsufficientMemory; result = paInsufficientMemory;
@ -898,7 +898,7 @@ static PaError InitializeOutputDeviceInfo( PaWinMmeHostApiRepresentation *winMme
#ifdef PAWIN_USE_WDMKS_DEVICE_INFO #ifdef PAWIN_USE_WDMKS_DEVICE_INFO
wdmksDeviceOutputChannelCountIsKnown = QueryWaveOutKSFilterMaxChannels( wdmksDeviceOutputChannelCountIsKnown = QueryWaveOutKSFilterMaxChannels(
winMmeOutputDeviceId, &deviceInfo->maxOutputChannels ); winMmeOutputDeviceId, &deviceInfo->maxOutputChannels );
if( wdmksDeviceOutputChannelCountIsKnown && !winMmeDeviceInfo->deviceOutputChannelCountIsKnown ) if( wdmksDeviceOutputChannelCountIsKnown && !winMmeDeviceInfo->deviceOutputChannelCountIsKnown )
winMmeDeviceInfo->deviceOutputChannelCountIsKnown = 1; winMmeDeviceInfo->deviceOutputChannelCountIsKnown = 1;
#endif /* PAWIN_USE_WDMKS_DEVICE_INFO */ #endif /* PAWIN_USE_WDMKS_DEVICE_INFO */
@ -919,7 +919,7 @@ static void GetDefaultLatencies( PaTime *defaultLowLatency, PaTime *defaultHighL
{ {
OSVERSIONINFO osvi; OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof( osvi ); osvi.dwOSVersionInfoSize = sizeof( osvi );
GetVersionEx( &osvi ); GetVersionEx( &osvi );
/* Check for NT */ /* Check for NT */
if( (osvi.dwMajorVersion == 4) && (osvi.dwPlatformId == 2) ) if( (osvi.dwMajorVersion == 4) && (osvi.dwPlatformId == 2) )
@ -999,11 +999,11 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
inputDeviceCount = waveInGetNumDevs(); inputDeviceCount = waveInGetNumDevs();
if( inputDeviceCount > 0 ) if( inputDeviceCount > 0 )
maximumPossibleDeviceCount += inputDeviceCount + 1; /* assume there is a WAVE_MAPPER */ maximumPossibleDeviceCount += inputDeviceCount + 1; /* assume there is a WAVE_MAPPER */
outputDeviceCount = waveOutGetNumDevs(); outputDeviceCount = waveOutGetNumDevs();
if( outputDeviceCount > 0 ) if( outputDeviceCount > 0 )
maximumPossibleDeviceCount += outputDeviceCount + 1; /* assume there is a WAVE_MAPPER */ maximumPossibleDeviceCount += outputDeviceCount + 1; /* assume there is a WAVE_MAPPER */
if( maximumPossibleDeviceCount > 0 ){ if( maximumPossibleDeviceCount > 0 ){
@ -2173,29 +2173,29 @@ static PaError ValidateWinMmeSpecificStreamInfo(
char *throttleProcessingThreadOnOverload, char *throttleProcessingThreadOnOverload,
unsigned long *deviceCount ) unsigned long *deviceCount )
{ {
if( streamInfo ) if( streamInfo )
{ {
if( streamInfo->size != sizeof( PaWinMmeStreamInfo ) if( streamInfo->size != sizeof( PaWinMmeStreamInfo )
|| streamInfo->version != 1 ) || streamInfo->version != 1 )
{ {
return paIncompatibleHostApiSpecificStreamInfo; return paIncompatibleHostApiSpecificStreamInfo;
} }
*winMmeSpecificFlags = streamInfo->flags; *winMmeSpecificFlags = streamInfo->flags;
if( streamInfo->flags & paWinMmeDontThrottleOverloadedProcessingThread ) if( streamInfo->flags & paWinMmeDontThrottleOverloadedProcessingThread )
*throttleProcessingThreadOnOverload = 0; *throttleProcessingThreadOnOverload = 0;
if( streamInfo->flags & paWinMmeUseMultipleDevices ) if( streamInfo->flags & paWinMmeUseMultipleDevices )
{ {
if( streamParameters->device != paUseHostApiSpecificDeviceSpecification ) if( streamParameters->device != paUseHostApiSpecificDeviceSpecification )
return paInvalidDevice; return paInvalidDevice;
*deviceCount = streamInfo->deviceCount; *deviceCount = streamInfo->deviceCount;
} }
} }
return paNoError; return paNoError;
} }
static PaError RetrieveDevicesFromStreamParameters( static PaError RetrieveDevicesFromStreamParameters(
@ -2210,34 +2210,34 @@ static PaError RetrieveDevicesFromStreamParameters(
int totalChannelCount; int totalChannelCount;
PaDeviceIndex hostApiDevice; PaDeviceIndex hostApiDevice;
if( streamInfo && streamInfo->flags & paWinMmeUseMultipleDevices ) if( streamInfo && streamInfo->flags & paWinMmeUseMultipleDevices )
{ {
totalChannelCount = 0; totalChannelCount = 0;
for( i=0; i < deviceCount; ++i ) for( i=0; i < deviceCount; ++i )
{ {
/* validate that the device number is within range */ /* validate that the device number is within range */
result = PaUtil_DeviceIndexToHostApiDeviceIndex( &hostApiDevice, result = PaUtil_DeviceIndexToHostApiDeviceIndex( &hostApiDevice,
streamInfo->devices[i].device, hostApi ); streamInfo->devices[i].device, hostApi );
if( result != paNoError ) if( result != paNoError )
return result; return result;
devices[i].device = hostApiDevice; devices[i].device = hostApiDevice;
devices[i].channelCount = streamInfo->devices[i].channelCount; devices[i].channelCount = streamInfo->devices[i].channelCount;
totalChannelCount += devices[i].channelCount; totalChannelCount += devices[i].channelCount;
} }
if( totalChannelCount != streamParameters->channelCount ) if( totalChannelCount != streamParameters->channelCount )
{ {
/* channelCount must match total channels specified by multiple devices */ /* channelCount must match total channels specified by multiple devices */
return paInvalidChannelCount; /* REVIEW use of this error code */ return paInvalidChannelCount; /* REVIEW use of this error code */
} }
} }
else else
{ {
devices[0].device = streamParameters->device; devices[0].device = streamParameters->device;
devices[0].channelCount = streamParameters->channelCount; devices[0].channelCount = streamParameters->channelCount;
} }
return result; return result;
} }
@ -2251,10 +2251,10 @@ static PaError ValidateInputChannelCounts(
PaWinMmeDeviceInfo *inputDeviceInfo; PaWinMmeDeviceInfo *inputDeviceInfo;
PaError paerror; PaError paerror;
for( i=0; i < deviceCount; ++i ) for( i=0; i < deviceCount; ++i )
{ {
if( devices[i].channelCount < 1 ) if( devices[i].channelCount < 1 )
return paInvalidChannelCount; return paInvalidChannelCount;
inputDeviceInfo = inputDeviceInfo =
(PaWinMmeDeviceInfo*)hostApi->deviceInfos[ devices[i].device ]; (PaWinMmeDeviceInfo*)hostApi->deviceInfos[ devices[i].device ];
@ -2262,7 +2262,7 @@ static PaError ValidateInputChannelCounts(
paerror = IsInputChannelCountSupported( inputDeviceInfo, devices[i].channelCount ); paerror = IsInputChannelCountSupported( inputDeviceInfo, devices[i].channelCount );
if( paerror != paNoError ) if( paerror != paNoError )
return paerror; return paerror;
} }
return paNoError; return paNoError;
} }
@ -2276,10 +2276,10 @@ static PaError ValidateOutputChannelCounts(
PaWinMmeDeviceInfo *outputDeviceInfo; PaWinMmeDeviceInfo *outputDeviceInfo;
PaError paerror; PaError paerror;
for( i=0; i < deviceCount; ++i ) for( i=0; i < deviceCount; ++i )
{ {
if( devices[i].channelCount < 1 ) if( devices[i].channelCount < 1 )
return paInvalidChannelCount; return paInvalidChannelCount;
outputDeviceInfo = outputDeviceInfo =
(PaWinMmeDeviceInfo*)hostApi->deviceInfos[ devices[i].device ]; (PaWinMmeDeviceInfo*)hostApi->deviceInfos[ devices[i].device ];
@ -2287,7 +2287,7 @@ static PaError ValidateOutputChannelCounts(
paerror = IsOutputChannelCountSupported( outputDeviceInfo, devices[i].channelCount ); paerror = IsOutputChannelCountSupported( outputDeviceInfo, devices[i].channelCount );
if( paerror != paNoError ) if( paerror != paNoError )
return paerror; return paerror;
} }
return paNoError; return paNoError;
} }
@ -2336,28 +2336,28 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if( inputParameters ) if( inputParameters )
{ {
inputChannelCount = inputParameters->channelCount; inputChannelCount = inputParameters->channelCount;
inputSampleFormat = inputParameters->sampleFormat; inputSampleFormat = inputParameters->sampleFormat;
suggestedInputLatency = inputParameters->suggestedLatency; suggestedInputLatency = inputParameters->suggestedLatency;
inputDeviceCount = 1; inputDeviceCount = 1;
/* validate input hostApiSpecificStreamInfo */ /* validate input hostApiSpecificStreamInfo */
inputStreamInfo = (PaWinMmeStreamInfo*)inputParameters->hostApiSpecificStreamInfo; inputStreamInfo = (PaWinMmeStreamInfo*)inputParameters->hostApiSpecificStreamInfo;
result = ValidateWinMmeSpecificStreamInfo( inputParameters, inputStreamInfo, result = ValidateWinMmeSpecificStreamInfo( inputParameters, inputStreamInfo,
&winMmeSpecificInputFlags, &winMmeSpecificInputFlags,
&throttleProcessingThreadOnOverload, &throttleProcessingThreadOnOverload,
&inputDeviceCount ); &inputDeviceCount );
if( result != paNoError ) return result; if( result != paNoError ) return result;
inputDevices = (PaWinMmeDeviceAndChannelCount*)alloca( sizeof(PaWinMmeDeviceAndChannelCount) * inputDeviceCount ); inputDevices = (PaWinMmeDeviceAndChannelCount*)alloca( sizeof(PaWinMmeDeviceAndChannelCount) * inputDeviceCount );
if( !inputDevices ) return paInsufficientMemory; if( !inputDevices ) return paInsufficientMemory;
result = RetrieveDevicesFromStreamParameters( hostApi, inputParameters, inputStreamInfo, inputDevices, inputDeviceCount ); result = RetrieveDevicesFromStreamParameters( hostApi, inputParameters, inputStreamInfo, inputDevices, inputDeviceCount );
if( result != paNoError ) return result; if( result != paNoError ) return result;
result = ValidateInputChannelCounts( hostApi, inputDevices, inputDeviceCount ); result = ValidateInputChannelCounts( hostApi, inputDevices, inputDeviceCount );
if( result != paNoError ) return result; if( result != paNoError ) return result;
hostInputSampleFormat = hostInputSampleFormat =
PaUtil_SelectClosestAvailableFormat( paInt16 /* native formats */, inputSampleFormat ); PaUtil_SelectClosestAvailableFormat( paInt16 /* native formats */, inputSampleFormat );
@ -2373,7 +2373,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
else else
inputChannelMask = PaWin_DefaultChannelMask( inputDevices[0].channelCount ); inputChannelMask = PaWin_DefaultChannelMask( inputDevices[0].channelCount );
} }
} }
else else
{ {
inputChannelCount = 0; inputChannelCount = 0;
@ -2392,22 +2392,22 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
outputDeviceCount = 1; outputDeviceCount = 1;
/* validate output hostApiSpecificStreamInfo */ /* validate output hostApiSpecificStreamInfo */
outputStreamInfo = (PaWinMmeStreamInfo*)outputParameters->hostApiSpecificStreamInfo; outputStreamInfo = (PaWinMmeStreamInfo*)outputParameters->hostApiSpecificStreamInfo;
result = ValidateWinMmeSpecificStreamInfo( outputParameters, outputStreamInfo, result = ValidateWinMmeSpecificStreamInfo( outputParameters, outputStreamInfo,
&winMmeSpecificOutputFlags, &winMmeSpecificOutputFlags,
&throttleProcessingThreadOnOverload, &throttleProcessingThreadOnOverload,
&outputDeviceCount ); &outputDeviceCount );
if( result != paNoError ) return result; if( result != paNoError ) return result;
outputDevices = (PaWinMmeDeviceAndChannelCount*)alloca( sizeof(PaWinMmeDeviceAndChannelCount) * outputDeviceCount ); outputDevices = (PaWinMmeDeviceAndChannelCount*)alloca( sizeof(PaWinMmeDeviceAndChannelCount) * outputDeviceCount );
if( !outputDevices ) return paInsufficientMemory; if( !outputDevices ) return paInsufficientMemory;
result = RetrieveDevicesFromStreamParameters( hostApi, outputParameters, outputStreamInfo, outputDevices, outputDeviceCount ); result = RetrieveDevicesFromStreamParameters( hostApi, outputParameters, outputStreamInfo, outputDevices, outputDeviceCount );
if( result != paNoError ) return result; if( result != paNoError ) return result;
result = ValidateOutputChannelCounts( hostApi, outputDevices, outputDeviceCount ); result = ValidateOutputChannelCounts( hostApi, outputDevices, outputDeviceCount );
if( result != paNoError ) return result; if( result != paNoError ) return result;
hostOutputSampleFormat = hostOutputSampleFormat =
PaUtil_SelectClosestAvailableFormat( paInt16 /* native formats */, outputSampleFormat ); PaUtil_SelectClosestAvailableFormat( paInt16 /* native formats */, outputSampleFormat );
@ -3235,9 +3235,9 @@ static PaError StartStream( PaStream *s )
MMRESULT mmresult; MMRESULT mmresult;
unsigned int i, j; unsigned int i, j;
int callbackResult; int callbackResult;
unsigned int channel; unsigned int channel;
unsigned long framesProcessed; unsigned long framesProcessed;
PaStreamCallbackTimeInfo timeInfo = {0,0,0}; /** @todo implement this for stream priming */ PaStreamCallbackTimeInfo timeInfo = {0,0,0}; /** @todo implement this for stream priming */
PaUtil_ResetBufferProcessor( &stream->bufferProcessor ); PaUtil_ResetBufferProcessor( &stream->bufferProcessor );