remove trailing whitespace from end of lines

This commit is contained in:
Ross Bencina 2016-08-26 19:33:31 +10:00
commit fce3367c23

View file

@ -27,26 +27,26 @@
*/ */
/* /*
* 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.
*/ */
/** @file /** @file
@ingroup common_src @ingroup common_src
@brief Implements PortAudio API functions defined in portaudio.h, checks @brief Implements PortAudio API functions defined in portaudio.h, checks
some errors, delegates platform-specific behavior to host API implementations. some errors, delegates platform-specific behavior to host API implementations.
Implements the functions defined in the PortAudio API (portaudio.h), Implements the functions defined in the PortAudio API (portaudio.h),
validates some parameters and checks for state inconsistencies before validates some parameters and checks for state inconsistencies before
forwarding API requests to specific Host API implementations (via the forwarding API requests to specific Host API implementations (via the
interface declared in pa_hostapi.h), and Streams (via the interface interface declared in pa_hostapi.h), and Streams (via the interface
declared in pa_stream.h). declared in pa_stream.h).
This file manages initialization and termination of Host API This file manages initialization and termination of Host API
@ -101,7 +101,7 @@
/** /**
* This is a combination of paVersionMajor, paVersionMinor and paVersionSubMinor. * This is a combination of paVersionMajor, paVersionMinor and paVersionSubMinor.
* It will always increase so that version numbers can be compared as integers to * It will always increase so that version numbers can be compared as integers to
* see which is later. * see which is later.
*/ */
#define paVersion paMakeVersionNumber(paVersionMajor, paVersionMinor, paVersionSubMinor) #define paVersion paMakeVersionNumber(paVersionMajor, paVersionMinor, paVersionSubMinor)
@ -209,7 +209,7 @@ static PaError InitializeHostApis( void )
if( !hostApis_ ) if( !hostApis_ )
{ {
result = paInsufficientMemory; result = paInsufficientMemory;
goto error; goto error;
} }
hostApisCount_ = 0; hostApisCount_ = 0;
@ -235,11 +235,11 @@ static PaError InitializeHostApis( void )
assert( hostApi->info.defaultInputDevice < hostApi->info.deviceCount ); assert( hostApi->info.defaultInputDevice < hostApi->info.deviceCount );
assert( hostApi->info.defaultOutputDevice < hostApi->info.deviceCount ); assert( hostApi->info.defaultOutputDevice < hostApi->info.deviceCount );
/* the first successfully initialized host API with a default input *or* /* the first successfully initialized host API with a default input *or*
output device is used as the default host API. output device is used as the default host API.
*/ */
if( (defaultHostApiIndex_ == -1) && if( (defaultHostApiIndex_ == -1) &&
( hostApi->info.defaultInputDevice != paNoDevice ( hostApi->info.defaultInputDevice != paNoDevice
|| hostApi->info.defaultOutputDevice != paNoDevice ) ) || hostApi->info.defaultOutputDevice != paNoDevice ) )
{ {
defaultHostApiIndex_ = hostApisCount_; defaultHostApiIndex_ = hostApisCount_;
@ -277,7 +277,7 @@ error:
<device> belongs and returns it. if <hostSpecificDeviceIndex> is <device> belongs and returns it. if <hostSpecificDeviceIndex> is
non-null, the host specific device index is returned in it. non-null, the host specific device index is returned in it.
returns -1 if <device> is out of range. returns -1 if <device> is out of range.
*/ */
static int FindHostApi( PaDeviceIndex device, int *hostSpecificDeviceIndex ) static int FindHostApi( PaDeviceIndex device, int *hostSpecificDeviceIndex )
{ {
@ -367,7 +367,7 @@ PaError Pa_Initialize( void )
{ {
PA_VALIDATE_TYPE_SIZES; PA_VALIDATE_TYPE_SIZES;
PA_VALIDATE_ENDIANNESS; PA_VALIDATE_ENDIANNESS;
PaUtil_InitializeClock(); PaUtil_InitializeClock();
PaUtil_ResetTraceMessages(); PaUtil_ResetTraceMessages();
@ -454,11 +454,11 @@ const char *Pa_GetErrorText( PaError errorCode )
case paCanNotWriteToAnInputOnlyStream: result = "Can't write to an input only stream"; break; case paCanNotWriteToAnInputOnlyStream: result = "Can't write to an input only stream"; break;
case paIncompatibleStreamHostApi: result = "Incompatible stream host API"; break; case paIncompatibleStreamHostApi: result = "Incompatible stream host API"; break;
case paBadBufferPtr: result = "Bad buffer pointer"; break; case paBadBufferPtr: result = "Bad buffer pointer"; break;
default: default:
if( errorCode > 0 ) if( errorCode > 0 )
result = "Invalid error code (value greater than zero)"; result = "Invalid error code (value greater than zero)";
else else
result = "Invalid error code"; result = "Invalid error code";
break; break;
} }
return result; return result;
@ -469,7 +469,7 @@ PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type )
{ {
PaHostApiIndex result; PaHostApiIndex result;
int i; int i;
PA_LOGAPI_ENTER_PARAMS( "Pa_HostApiTypeIdToHostApiIndex" ); PA_LOGAPI_ENTER_PARAMS( "Pa_HostApiTypeIdToHostApiIndex" );
PA_LOGAPI(("\tPaHostApiTypeId type: %d\n", type )); PA_LOGAPI(("\tPaHostApiTypeId type: %d\n", type ));
@ -480,14 +480,14 @@ PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type )
else else
{ {
result = paHostApiNotFound; result = paHostApiNotFound;
for( i=0; i < hostApisCount_; ++i ) for( i=0; i < hostApisCount_; ++i )
{ {
if( hostApis_[i]->info.type == type ) if( hostApis_[i]->info.type == type )
{ {
result = i; result = i;
break; break;
} }
} }
} }
@ -502,7 +502,7 @@ PaError PaUtil_GetHostApiRepresentation( struct PaUtilHostApiRepresentation **ho
{ {
PaError result; PaError result;
int i; int i;
if( !PA_IS_INITIALISED_ ) if( !PA_IS_INITIALISED_ )
{ {
result = paNotInitialized; result = paNotInitialized;
@ -510,7 +510,7 @@ PaError PaUtil_GetHostApiRepresentation( struct PaUtilHostApiRepresentation **ho
else else
{ {
result = paHostApiNotFound; result = paHostApiNotFound;
for( i=0; i < hostApisCount_; ++i ) for( i=0; i < hostApisCount_; ++i )
{ {
if( hostApis_[i]->info.type == type ) if( hostApis_[i]->info.type == type )
@ -531,7 +531,7 @@ PaError PaUtil_DeviceIndexToHostApiDeviceIndex(
{ {
PaError result; PaError result;
PaDeviceIndex x; PaDeviceIndex x;
x = device - hostApi->privatePaFrontInfo.baseDeviceIndex; x = device - hostApi->privatePaFrontInfo.baseDeviceIndex;
if( x < 0 || x >= hostApi->info.deviceCount ) if( x < 0 || x >= hostApi->info.deviceCount )
@ -616,7 +616,7 @@ const PaHostApiInfo* Pa_GetHostApiInfo( PaHostApiIndex hostApi )
else if( hostApi < 0 || hostApi >= hostApisCount_ ) else if( hostApi < 0 || hostApi >= hostApisCount_ )
{ {
info = NULL; info = NULL;
PA_LOGAPI(("Pa_GetHostApiInfo returned:\n" )); PA_LOGAPI(("Pa_GetHostApiInfo returned:\n" ));
PA_LOGAPI(("\tPaHostApiInfo*: NULL [ hostApi out of range ]\n" )); PA_LOGAPI(("\tPaHostApiInfo*: NULL [ hostApi out of range ]\n" ));
@ -725,7 +725,7 @@ PaDeviceIndex Pa_GetDefaultOutputDevice( void )
{ {
PaHostApiIndex hostApi; PaHostApiIndex hostApi;
PaDeviceIndex result; PaDeviceIndex result;
PA_LOGAPI_ENTER( "Pa_GetDefaultOutputDevice" ); PA_LOGAPI_ENTER( "Pa_GetDefaultOutputDevice" );
hostApi = Pa_GetDefaultHostApi(); hostApi = Pa_GetDefaultHostApi();
@ -809,7 +809,7 @@ static int SampleFormatIsValid( PaSampleFormat format )
ValidateOpenStreamParameters() checks that parameters to Pa_OpenStream() ValidateOpenStreamParameters() checks that parameters to Pa_OpenStream()
conform to the expected values as described below. This function is conform to the expected values as described below. This function is
also designed to be used with the proposed Pa_IsFormatSupported() function. also designed to be used with the proposed Pa_IsFormatSupported() function.
There are basically two types of validation that could be performed: There are basically two types of validation that could be performed:
Generic conformance validation, and device capability mismatch Generic conformance validation, and device capability mismatch
validation. This function performs only generic conformance validation. validation. This function performs only generic conformance validation.
@ -818,21 +818,21 @@ static int SampleFormatIsValid( PaSampleFormat format )
combinations of parameters - for example, even if the sampleRate combinations of parameters - for example, even if the sampleRate
seems ok, it might not be for a duplex stream - we have no way of seems ok, it might not be for a duplex stream - we have no way of
checking this in an API-neutral way, so we don't try. checking this in an API-neutral way, so we don't try.
On success the function returns PaNoError and fills in hostApi, On success the function returns PaNoError and fills in hostApi,
hostApiInputDeviceID, and hostApiOutputDeviceID fields. On failure hostApiInputDeviceID, and hostApiOutputDeviceID fields. On failure
the function returns an error code indicating the first encountered the function returns an error code indicating the first encountered
parameter error. parameter error.
If ValidateOpenStreamParameters() returns paNoError, the following If ValidateOpenStreamParameters() returns paNoError, the following
assertions are guaranteed to be true. assertions are guaranteed to be true.
- at least one of inputParameters & outputParmeters is valid (not NULL) - at least one of inputParameters & outputParmeters is valid (not NULL)
- if inputParameters & outputParameters are both valid, that - if inputParameters & outputParameters are both valid, that
inputParameters->device & outputParameters->device both use the same host api inputParameters->device & outputParameters->device both use the same host api
PaDeviceIndex inputParameters->device PaDeviceIndex inputParameters->device
- is within range (0 to Pa_GetDeviceCount-1) Or: - is within range (0 to Pa_GetDeviceCount-1) Or:
- is paUseHostApiSpecificDeviceSpecification and - is paUseHostApiSpecificDeviceSpecification and
@ -842,30 +842,30 @@ static int SampleFormatIsValid( PaSampleFormat format )
int inputParameters->channelCount int inputParameters->channelCount
- if inputParameters->device is not paUseHostApiSpecificDeviceSpecification, channelCount is > 0 - if inputParameters->device is not paUseHostApiSpecificDeviceSpecification, channelCount is > 0
- upper bound is NOT validated against device capabilities - upper bound is NOT validated against device capabilities
PaSampleFormat inputParameters->sampleFormat PaSampleFormat inputParameters->sampleFormat
- is one of the sample formats defined in portaudio.h - is one of the sample formats defined in portaudio.h
void *inputParameters->hostApiSpecificStreamInfo void *inputParameters->hostApiSpecificStreamInfo
- if supplied its hostApi field matches the input device's host Api - if supplied its hostApi field matches the input device's host Api
PaDeviceIndex outputParmeters->device PaDeviceIndex outputParmeters->device
- is within range (0 to Pa_GetDeviceCount-1) - is within range (0 to Pa_GetDeviceCount-1)
int outputParmeters->channelCount int outputParmeters->channelCount
- if inputDevice is valid, channelCount is > 0 - if inputDevice is valid, channelCount is > 0
- upper bound is NOT validated against device capabilities - upper bound is NOT validated against device capabilities
PaSampleFormat outputParmeters->sampleFormat PaSampleFormat outputParmeters->sampleFormat
- is one of the sample formats defined in portaudio.h - is one of the sample formats defined in portaudio.h
void *outputParmeters->hostApiSpecificStreamInfo void *outputParmeters->hostApiSpecificStreamInfo
- if supplied its hostApi field matches the output device's host Api - if supplied its hostApi field matches the output device's host Api
double sampleRate double sampleRate
- is not an 'absurd' rate (less than 1000. or greater than 384000.) - is not an 'absurd' rate (less than 1000. or greater than 384000.)
- sampleRate is NOT validated against device capabilities - sampleRate is NOT validated against device capabilities
PaStreamFlags streamFlags PaStreamFlags streamFlags
- unused platform neutral flags are zero - unused platform neutral flags are zero
- paNeverDropInput is only used for full-duplex callback streams with - paNeverDropInput is only used for full-duplex callback streams with
@ -992,7 +992,7 @@ static PaError ValidateOpenStreamParameters(
!= (*hostApi)->info.type ) != (*hostApi)->info.type )
return paIncompatibleHostApiSpecificStreamInfo; return paIncompatibleHostApiSpecificStreamInfo;
} }
} }
if( (inputParameters != NULL) && (outputParameters != NULL) ) if( (inputParameters != NULL) && (outputParameters != NULL) )
{ {
@ -1001,8 +1001,8 @@ static PaError ValidateOpenStreamParameters(
return paBadIODeviceCombination; return paBadIODeviceCombination;
} }
} }
/* Check for absurd sample rates. */ /* Check for absurd sample rates. */
if( (sampleRate < 1000.0) || (sampleRate > 384000.0) ) if( (sampleRate < 1000.0) || (sampleRate > 384000.0) )
return paInvalidSampleRate; return paInvalidSampleRate;
@ -1024,7 +1024,7 @@ static PaError ValidateOpenStreamParameters(
if( framesPerBuffer != paFramesPerBufferUnspecified ) if( framesPerBuffer != paFramesPerBufferUnspecified )
return paInvalidFlag; return paInvalidFlag;
} }
return paNoError; return paNoError;
} }
@ -1064,7 +1064,7 @@ PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
PA_LOGAPI(("\tPaTime outputParameters->suggestedLatency: %f\n", outputParameters->suggestedLatency )); PA_LOGAPI(("\tPaTime outputParameters->suggestedLatency: %f\n", outputParameters->suggestedLatency ));
PA_LOGAPI(("\tvoid *outputParameters->hostApiSpecificStreamInfo: 0x%p\n", outputParameters->hostApiSpecificStreamInfo )); PA_LOGAPI(("\tvoid *outputParameters->hostApiSpecificStreamInfo: 0x%p\n", outputParameters->hostApiSpecificStreamInfo ));
} }
PA_LOGAPI(("\tdouble sampleRate: %g\n", sampleRate )); PA_LOGAPI(("\tdouble sampleRate: %g\n", sampleRate ));
#endif #endif
@ -1087,7 +1087,7 @@ PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
PA_LOGAPI_EXIT_PAERROR( "Pa_IsFormatSupported", result ); PA_LOGAPI_EXIT_PAERROR( "Pa_IsFormatSupported", result );
return result; return result;
} }
if( inputParameters ) if( inputParameters )
{ {
@ -1174,7 +1174,7 @@ PaError Pa_OpenStream( PaStream** stream,
PA_LOGAPI(("\tPaTime outputParameters->suggestedLatency: %f\n", outputParameters->suggestedLatency )); PA_LOGAPI(("\tPaTime outputParameters->suggestedLatency: %f\n", outputParameters->suggestedLatency ));
PA_LOGAPI(("\tvoid *outputParameters->hostApiSpecificStreamInfo: 0x%p\n", outputParameters->hostApiSpecificStreamInfo )); PA_LOGAPI(("\tvoid *outputParameters->hostApiSpecificStreamInfo: 0x%p\n", outputParameters->hostApiSpecificStreamInfo ));
} }
PA_LOGAPI(("\tdouble sampleRate: %g\n", sampleRate )); PA_LOGAPI(("\tdouble sampleRate: %g\n", sampleRate ));
PA_LOGAPI(("\tunsigned long framesPerBuffer: %d\n", framesPerBuffer )); PA_LOGAPI(("\tunsigned long framesPerBuffer: %d\n", framesPerBuffer ));
PA_LOGAPI(("\tPaStreamFlags streamFlags: 0x%x\n", streamFlags )); PA_LOGAPI(("\tPaStreamFlags streamFlags: 0x%x\n", streamFlags ));
@ -1221,7 +1221,7 @@ PaError Pa_OpenStream( PaStream** stream,
PA_LOGAPI(("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )); PA_LOGAPI(("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) ));
return result; return result;
} }
if( inputParameters ) if( inputParameters )
{ {
@ -1295,8 +1295,8 @@ PaError Pa_OpenDefaultStream( PaStream** stream,
{ {
hostApiInputParameters.device = Pa_GetDefaultInputDevice(); hostApiInputParameters.device = Pa_GetDefaultInputDevice();
if( hostApiInputParameters.device == paNoDevice ) if( hostApiInputParameters.device == paNoDevice )
return paDeviceUnavailable; return paDeviceUnavailable;
hostApiInputParameters.channelCount = inputChannelCount; hostApiInputParameters.channelCount = inputChannelCount;
hostApiInputParameters.sampleFormat = sampleFormat; hostApiInputParameters.sampleFormat = sampleFormat;
/* defaultHighInputLatency is used below instead of /* defaultHighInputLatency is used below instead of
@ -1304,7 +1304,7 @@ PaError Pa_OpenDefaultStream( PaStream** stream,
stream to work reliably than it is for it to work with the lowest stream to work reliably than it is for it to work with the lowest
latency. latency.
*/ */
hostApiInputParameters.suggestedLatency = hostApiInputParameters.suggestedLatency =
Pa_GetDeviceInfo( hostApiInputParameters.device )->defaultHighInputLatency; Pa_GetDeviceInfo( hostApiInputParameters.device )->defaultHighInputLatency;
hostApiInputParameters.hostApiSpecificStreamInfo = NULL; hostApiInputParameters.hostApiSpecificStreamInfo = NULL;
hostApiInputParametersPtr = &hostApiInputParameters; hostApiInputParametersPtr = &hostApiInputParameters;
@ -1318,7 +1318,7 @@ PaError Pa_OpenDefaultStream( PaStream** stream,
{ {
hostApiOutputParameters.device = Pa_GetDefaultOutputDevice(); hostApiOutputParameters.device = Pa_GetDefaultOutputDevice();
if( hostApiOutputParameters.device == paNoDevice ) if( hostApiOutputParameters.device == paNoDevice )
return paDeviceUnavailable; return paDeviceUnavailable;
hostApiOutputParameters.channelCount = outputChannelCount; hostApiOutputParameters.channelCount = outputChannelCount;
hostApiOutputParameters.sampleFormat = sampleFormat; hostApiOutputParameters.sampleFormat = sampleFormat;
@ -1702,7 +1702,7 @@ PaError Pa_WriteStream( PaStream* stream,
else if( result == 1 ) else if( result == 1 )
{ {
result = paStreamIsStopped; result = paStreamIsStopped;
} }
} }
} }