* Clean up whitespace in src/hostapi/{asihpi, jack, oss, skeleton} in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
* Additional formatting cleanups.
/* If HPI error occurred */ \
if( UNLIKELY( hpiError ) ) \
{ \
- char szError[256]; \
- HPI_GetErrorText( hpiError, szError ); \
- PA_DEBUG(( "HPI error %d occurred: %s\n", hpiError, szError )); \
- /* This message will always be displayed, even if debug info is disabled */ \
+ char szError[256]; \
+ HPI_GetErrorText( hpiError, szError ); \
+ PA_DEBUG(( "HPI error %d occurred: %s\n", hpiError, szError )); \
+ /* This message will always be displayed, even if debug info is disabled */ \
PA_DEBUG(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" )); \
if( (paError) == paUnanticipatedHostError ) \
- { \
- PA_DEBUG(( "Host error description: %s\n", szError )); \
- /* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \
- if( pthread_equal( pthread_self(), paUnixMainThread ) ) \
+ { \
+ PA_DEBUG(( "Host error description: %s\n", szError )); \
+ /* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \
+ if( pthread_equal( pthread_self(), paUnixMainThread ) ) \
{ \
- PaUtil_SetLastHostErrorInfo( paInDevelopment, hpiError, szError ); \
+ PaUtil_SetLastHostErrorInfo( paInDevelopment, hpiError, szError ); \
} \
- } \
- /* If paNoError is specified, continue as usual */ \
+ } \
+ /* If paNoError is specified, continue as usual */ \
/* (useful if you only want to print out the debug messages above) */ \
- if( (paError) < 0 ) \
- { \
- result = (paError); \
- goto error; \
- } \
+ if( (paError) < 0 ) \
+ { \
+ result = (paError); \
+ goto error; \
+ } \
} \
} while( 0 );
PA_DEBUG(( "HPI error %d occurred: %s\n", hpiError, szError )); \
/* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \
if( pthread_equal( pthread_self(), paUnixMainThread ) ) \
- { \
- PaUtil_SetLastHostErrorInfo( paInDevelopment, (hpiErrorCode), szError ); \
- } \
+ { \
+ PaUtil_SetLastHostErrorInfo( paInDevelopment, (hpiErrorCode), szError ); \
+ } \
} while( 0 );
/* Defaults */
continue;
}
hpiError = HPI_AdapterGetInfo( NULL, idx, &outStreams, &inStreams,
- &version, &serial, &type );
+ &version, &serial, &type );
/* Skip to next device on failure */
if( hpiError )
{
* interface and paNoError */
PA_DEBUG(( "Could not open HPI interface\n" ));
- *hostApi = NULL;
+ *hostApi = NULL;
return paNoError;
}
else
/* If BBM not supported, foreground transfers will be used, but not a show-stopper */
/* Anything else is an error */
else if (( hpiError != HPI_ERROR_INVALID_OPERATION ) &&
- ( hpiError != HPI_ERROR_INVALID_FUNC ))
+ ( hpiError != HPI_ERROR_INVALID_FUNC ))
{
PA_ASIHPI_REPORT_ERROR_( hpiError );
result = paUnanticipatedHostError;
static int
BlockingCallback( const void *inputBuffer,
void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
+ void *userData )
{
struct PaJackStream *stream = (PaJackStream *)userData;
long numBytes = stream->bytesPerFrame * framesPerBuffer;
#define ABS(x) ( (x) > 0 ? (x) : -(x) )
if( ABS(sampleRate - jack_get_sample_rate(((PaJackHostApiRepresentation *) hostApi)->jack_client )) > 1 )
- return paInvalidSampleRate;
+ return paInvalidSampleRate;
#undef ABS
return paFormatIsSupported;
#define ABS(x) ( (x) > 0 ? (x) : -(x) )
if( ABS(sampleRate - jackSr) > 1 )
- return paInvalidSampleRate;
+ return paInvalidSampleRate;
#undef ABS
UNLESS( stream = (PaJackStream*)PaUtil_AllocateMemory( sizeof(PaJackStream) ), paInsufficientMemory );
{
int r = jack_connect( stream->jack_client, jack_port_name( stream->remote_output_ports[i] ),
jack_port_name( stream->local_input_ports[i] ) );
- UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
+ UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
}
}
{
int r = jack_connect( stream->jack_client, jack_port_name( stream->local_output_ports[i] ),
jack_port_name( stream->remote_input_ports[i] ) );
- UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
+ UNLESS( 0 == r || EEXIST == r, paUnanticipatedHostError );
}
}
for( i = -1; i < 100; i++ )
{
- char deviceName[32];
- PaDeviceInfo *deviceInfo;
- int testResult;
-
- if( i == -1 )
- snprintf(deviceName, sizeof (deviceName), "%s", DEVICE_NAME_BASE);
- else
- snprintf(deviceName, sizeof (deviceName), "%s%d", DEVICE_NAME_BASE, i);
-
- /* PA_DEBUG(("%s: trying device %s\n", __FUNCTION__, deviceName )); */
- if( (testResult = QueryDevice( deviceName, ossApi, &deviceInfo )) != paNoError )
- {
- if( testResult != paDeviceUnavailable )
- PA_ENSURE( testResult );
-
- continue;
- }
-
- ++numDevices;
- if( !deviceInfos || numDevices > maxDeviceInfos )
- {
- maxDeviceInfos *= 2;
- PA_UNLESS( deviceInfos = (PaDeviceInfo **) realloc( deviceInfos, maxDeviceInfos * sizeof (PaDeviceInfo *) ),
- paInsufficientMemory );
- }
- {
- int devIdx = numDevices - 1;
- deviceInfos[devIdx] = deviceInfo;
-
- if( commonApi->info.defaultInputDevice == paNoDevice && deviceInfo->maxInputChannels > 0 )
- commonApi->info.defaultInputDevice = devIdx;
- if( commonApi->info.defaultOutputDevice == paNoDevice && deviceInfo->maxOutputChannels > 0 )
- commonApi->info.defaultOutputDevice = devIdx;
- }
+ char deviceName[32];
+ PaDeviceInfo *deviceInfo;
+ int testResult;
+
+ if( i == -1 )
+ snprintf(deviceName, sizeof (deviceName), "%s", DEVICE_NAME_BASE);
+ else
+ snprintf(deviceName, sizeof (deviceName), "%s%d", DEVICE_NAME_BASE, i);
+
+ /* PA_DEBUG(("%s: trying device %s\n", __FUNCTION__, deviceName )); */
+ if( (testResult = QueryDevice( deviceName, ossApi, &deviceInfo )) != paNoError )
+ {
+ if( testResult != paDeviceUnavailable )
+ PA_ENSURE( testResult );
+
+ continue;
+ }
+
+ ++numDevices;
+ if( !deviceInfos || numDevices > maxDeviceInfos )
+ {
+ maxDeviceInfos *= 2;
+ PA_UNLESS( deviceInfos = (PaDeviceInfo **) realloc( deviceInfos, maxDeviceInfos * sizeof (PaDeviceInfo *) ),
+ paInsufficientMemory );
+ }
+ {
+ int devIdx = numDevices - 1;
+ deviceInfos[devIdx] = deviceInfo;
+
+ if( commonApi->info.defaultInputDevice == paNoDevice && deviceInfo->maxInputChannels > 0 )
+ commonApi->info.defaultInputDevice = devIdx;
+ if( commonApi->info.defaultOutputDevice == paNoDevice && deviceInfo->maxOutputChannels > 0 )
+ commonApi->info.defaultOutputDevice = devIdx;
+ }
}
/* Make an array of PaDeviceInfo pointers out of the linked list */
/* if full duplex, make sure that they're the same device */
if (inputChannelCount > 0 && outputChannelCount > 0 &&
- inputParameters->device != outputParameters->device)
+ inputParameters->device != outputParameters->device)
return paInvalidDevice;
/* if full duplex, also make sure that they're the same number of channels */
if (inputChannelCount > 0 && outputChannelCount > 0 &&
- inputChannelCount != outputChannelCount)
- return paInvalidChannelCount;
+ inputChannelCount != outputChannelCount)
+ return paInvalidChannelCount;
/* open the device so we can do more tests */
flags = O_NONBLOCK;
if (inputChannelCount > 0 && outputChannelCount > 0)
- flags |= O_RDWR;
+ flags |= O_RDWR;
else if (inputChannelCount > 0)
- flags |= O_RDONLY;
+ flags |= O_RDONLY;
else
- flags |= O_WRONLY;
+ flags |= O_WRONLY;
ENSURE_( tempDevHandle = open( deviceInfo->name, flags ), paDeviceUnavailable );
/* everything succeeded! */
- error:
+error:
if( tempDevHandle >= 0 )
close( tempDevHandle );
return paInvalidDevice;
}
- maxChans = (mode == StreamMode_In ? deviceInfo->maxInputChannels :
- deviceInfo->maxOutputChannels);
+ maxChans = (mode == StreamMode_In ? deviceInfo->maxInputChannels : deviceInfo->maxOutputChannels);
if( parameters->channelCount > maxChans )
{
return paInvalidChannelCount;
assert( stream );
- pthread_cleanup_push( &OnExit, stream ); /* Execute OnExit when exiting */
+ pthread_cleanup_push( &OnExit, stream ); /* Execute OnExit when exiting */
/* The first time the stream is started we use SNDCTL_DSP_TRIGGER to accurately start capture and
* playback in sync, when the stream is restarted after being stopped we simply start by reading/
{
framesRequested = PA_MIN( frames, stream->capture->hostFrames );
- bytesRequested = framesRequested * PaOssStreamComponent_FrameSize( stream->capture );
- ENSURE_( (bytesRead = read( stream->capture->fd, stream->capture->buffer, bytesRequested )),
- paUnanticipatedHostError );
- if ( bytesRequested != bytesRead )
- {
- PA_DEBUG(( "Requested %d bytes, read %d\n", bytesRequested, bytesRead ));
- return paUnanticipatedHostError;
- }
-
- PaUtil_SetInputFrameCount( &stream->bufferProcessor, stream->capture->hostFrames );
- PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor, 0, stream->capture->buffer, stream->capture->hostChannelCount );
+ bytesRequested = framesRequested * PaOssStreamComponent_FrameSize( stream->capture );
+ ENSURE_( (bytesRead = read( stream->capture->fd, stream->capture->buffer, bytesRequested )),
+ paUnanticipatedHostError );
+ if ( bytesRequested != bytesRead )
+ {
+ PA_DEBUG(( "Requested %d bytes, read %d\n", bytesRequested, bytesRead ));
+ return paUnanticipatedHostError;
+ }
+
+ PaUtil_SetInputFrameCount( &stream->bufferProcessor, stream->capture->hostFrames );
+ PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor, 0, stream->capture->buffer, stream->capture->hostChannelCount );
PaUtil_CopyInput( &stream->bufferProcessor, &userBuffer, framesRequested );
- frames -= framesRequested;
+ frames -= framesRequested;
}
error:
while( frames )
{
- PaUtil_SetOutputFrameCount( &stream->bufferProcessor, stream->playback->hostFrames );
- PaUtil_SetInterleavedOutputChannels( &stream->bufferProcessor, 0, stream->playback->buffer, stream->playback->hostChannelCount );
+ PaUtil_SetOutputFrameCount( &stream->bufferProcessor, stream->playback->hostFrames );
+ PaUtil_SetInterleavedOutputChannels( &stream->bufferProcessor, 0, stream->playback->buffer, stream->playback->hostChannelCount );
- framesConverted = PaUtil_CopyOutput( &stream->bufferProcessor, &userBuffer, frames );
- frames -= framesConverted;
+ framesConverted = PaUtil_CopyOutput( &stream->bufferProcessor, &userBuffer, frames );
+ frames -= framesConverted;
- bytesRequested = framesConverted * PaOssStreamComponent_FrameSize( stream->playback );
- ENSURE_( (bytesWritten = write( stream->playback->fd, stream->playback->buffer, bytesRequested )),
- paUnanticipatedHostError );
+ bytesRequested = framesConverted * PaOssStreamComponent_FrameSize( stream->playback );
+ ENSURE_( (bytesWritten = write( stream->playback->fd, stream->playback->buffer, bytesRequested )),
+ paUnanticipatedHostError );
- if ( bytesRequested != bytesWritten )
- {
- PA_DEBUG(( "Requested %d bytes, wrote %d\n", bytesRequested, bytesWritten ));
- return paUnanticipatedHostError;
- }
+ if ( bytesRequested != bytesWritten )
+ {
+ PA_DEBUG(( "Requested %d bytes, wrote %d\n", bytesRequested, bytesWritten ));
+ return paUnanticipatedHostError;
+ }
}
error:
* recplay.c
* Phil Burk
* Minimal record and playback test.
- *
+ *
*/
#include <stdio.h>
#include <unistd.h>
*/
/*
- * 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:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
(*hostApi)->info.defaultInputDevice = paNoDevice; /* IMPLEMENT ME */
(*hostApi)->info.defaultOutputDevice = paNoDevice; /* IMPLEMENT ME */
- (*hostApi)->info.deviceCount = 0;
+ (*hostApi)->info.deviceCount = 0;
deviceCount = 0; /* IMPLEMENT ME */
-
+
if( deviceCount > 0 )
{
(*hostApi)->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory(
deviceInfo->maxInputChannels = 0; /* IMPLEMENT ME */
deviceInfo->maxOutputChannels = 0; /* IMPLEMENT ME */
-
+
deviceInfo->defaultLowInputLatency = 0.; /* IMPLEMENT ME */
deviceInfo->defaultLowOutputLatency = 0.; /* IMPLEMENT ME */
deviceInfo->defaultHighInputLatency = 0.; /* IMPLEMENT ME */
- deviceInfo->defaultHighOutputLatency = 0.; /* IMPLEMENT ME */
+ deviceInfo->defaultHighOutputLatency = 0.; /* IMPLEMENT ME */
deviceInfo->defaultSampleRate = 0.; /* IMPLEMENT ME */
-
+
(*hostApi)->deviceInfos[i] = deviceInfo;
++(*hostApi)->info.deviceCount;
}
PaUtil_FreeAllAllocations( skeletonHostApi->allocations );
PaUtil_DestroyAllocationGroup( skeletonHostApi->allocations );
}
-
+
PaUtil_FreeMemory( skeletonHostApi );
}
return result;
{
int inputChannelCount, outputChannelCount;
PaSampleFormat inputSampleFormat, outputSampleFormat;
-
+
if( inputParameters )
{
inputChannelCount = inputParameters->channelCount;
this implementation doesn't support any custom sample formats */
if( inputSampleFormat & paCustomFormat )
return paSampleFormatNotSupported;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
this implementation doesn't support any custom sample formats */
if( outputSampleFormat & paCustomFormat )
return paSampleFormatNotSupported;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
{
outputChannelCount = 0;
}
-
+
/*
IMPLEMENT ME:
{
outputChannelCount = outputParameters->channelCount;
outputSampleFormat = outputParameters->sampleFormat;
-
+
/* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */
/* we assume a fixed host buffer size in this example, but the buffer processor
- can also support bounded and unknown host buffer sizes by passing
+ can also support bounded and unknown host buffer sizes by passing
paUtilBoundedHostBufferSize or paUtilUnknownHostBufferSize instead of
paUtilFixedHostBufferSize below. */
-
+
result = PaUtil_InitializeBufferProcessor( &stream->bufferProcessor,
inputChannelCount, inputSampleFormat, hostInputSampleFormat,
outputChannelCount, outputSampleFormat, hostOutputSampleFormat,
(PaTime)PaUtil_GetBufferProcessorOutputLatencyFrames(&stream->bufferProcessor) / sampleRate; /* outputLatency is specified in _seconds_ */
stream->streamRepresentation.streamInfo.sampleRate = sampleRate;
-
+
/*
IMPLEMENT ME:
- additional stream setup + opening
/*
ExampleHostProcessingLoop() illustrates the kind of processing which may
occur in a host implementation.
-
+
*/
static void ExampleHostProcessingLoop( void *inputBuffer, void *outputBuffer, void *userData )
{
PaStreamCallbackTimeInfo timeInfo = {0,0,0}; /* IMPLEMENT ME */
int callbackResult;
unsigned long framesProcessed;
-
+
PaUtil_BeginCpuLoadMeasurement( &stream->cpuLoadMeasurer );
-
+
/*
IMPLEMENT ME:
- generate timing information
or a mixture, you will want to call PaUtil_SetInterleaved*Channels(),
PaUtil_SetNonInterleaved*Channel() or PaUtil_Set*Channel() here.
*/
-
+
PaUtil_SetInputFrameCount( &stream->bufferProcessor, 0 /* default to host buffer size */ );
PaUtil_SetInterleavedInputChannels( &stream->bufferProcessor,
0, /* first channel of inputBuffer is channel 0 */
callbackResult = paContinue;
framesProcessed = PaUtil_EndBufferProcessing( &stream->bufferProcessor, &callbackResult );
-
+
/*
If you need to byte swap or shift outputBuffer to convert it to
host format, do it here.
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior */
return result;
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior */
return 0;
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior */
return 0;
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return 0;
(void) buffer;
(void) frames;
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return paNoError;
(void) buffer;
(void) frames;
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return paNoError;
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return 0;
/* suppress unused variable warnings */
(void) stream;
-
+
/* IMPLEMENT ME, see portaudio.h for required behavior*/
return 0;