Added patest_write_sine_nonint to Makefile.

Check for paNonInterleaved on Mac and return paSampleFormatNotSupported.
Fix pa_minlat.c. Linux was complaining about not checking fgets return value.
This commit is contained in:
philburk 2011-02-28 23:56:48 +00:00
commit 7aad01a1d3
5 changed files with 49 additions and 25 deletions

View file

@ -95,6 +95,7 @@ TESTS = \
bin/patest_underflow \ bin/patest_underflow \
bin/patest_wire \ bin/patest_wire \
bin/patest_write_sine \ bin/patest_write_sine \
bin/patest_write_sine_nonint \
bin/pa_devs \ bin/pa_devs \
bin/pa_fuzz \ bin/pa_fuzz \
bin/pa_minlat bin/pa_minlat

View file

@ -292,7 +292,7 @@ static int RecordAndPlayBlockingIO( PaStream *inStream,
long framesPerBuffer = test->framesPerBuffer; long framesPerBuffer = test->framesPerBuffer;
if( framesPerBuffer <= 0 ) if( framesPerBuffer <= 0 )
{ {
framesPerBuffer = 64; // bigger values might run past end of recording framesPerBuffer = maxPerBuffer; // bigger values might run past end of recording
} }
// Read in audio. // Read in audio.
@ -553,7 +553,7 @@ static void PaQa_TeardownLoopbackContext( LoopbackContext *loopbackContextPtr )
/*******************************************************************/ /*******************************************************************/
static void PaQa_PrintShortErrorReport( PaQaAnalysisResult *analysisResultPtr, int channel ) static void PaQa_PrintShortErrorReport( PaQaAnalysisResult *analysisResultPtr, int channel )
{ {
printf("#%d ", channel); printf("channel %d ", channel);
if( analysisResultPtr->popPosition > 0 ) if( analysisResultPtr->popPosition > 0 )
{ {
printf("POP %0.3f at %d, ", (double)analysisResultPtr->popAmplitude, (int)analysisResultPtr->popPosition ); printf("POP %0.3f at %d, ", (double)analysisResultPtr->popAmplitude, (int)analysisResultPtr->popPosition );
@ -1008,7 +1008,7 @@ int main( int argc, char **argv )
} }
} }
result = PaQa_TestAnalyzer(); //result = PaQa_TestAnalyzer();
if( (result == 0) && (justMath == 0) ) if( (result == 0) && (justMath == 0) )
{ {

View file

@ -1340,13 +1340,19 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
(float) sampleRate, (float) sampleRate,
framesPerBuffer )); framesPerBuffer ));
VDBUG( ("Opening Stream.\n") ); VDBUG( ("Opening Stream.\n") );
/*These first few bits of code are from paSkeleton with few modifications.*/ /*These first few bits of code are from paSkeleton with few modifications.*/
if( inputParameters ) if( inputParameters )
{ {
inputChannelCount = inputParameters->channelCount; inputChannelCount = inputParameters->channelCount;
inputSampleFormat = inputParameters->sampleFormat; inputSampleFormat = inputParameters->sampleFormat;
/* @todo Blocking read/write on Mac is not yet supported. */
if( inputSampleFormat & paNonInterleaved )
{
return paSampleFormatNotSupported;
}
/* unless alternate device specification is supported, reject the use of /* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */ paUseHostApiSpecificDeviceSpecification */
@ -1371,6 +1377,12 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
outputChannelCount = outputParameters->channelCount; outputChannelCount = outputParameters->channelCount;
outputSampleFormat = outputParameters->sampleFormat; outputSampleFormat = outputParameters->sampleFormat;
/* @todo Blocking read/write on Mac is not yet supported. */
if( outputSampleFormat & paNonInterleaved )
{
return paSampleFormatNotSupported;
}
/* unless alternate device specification is supported, reject the use of /* unless alternate device specification is supported, reject the use of
paUseHostApiSpecificDeviceSpecification */ paUseHostApiSpecificDeviceSpecification */

View file

@ -71,12 +71,12 @@
#endif #endif
/* /*
* This fnuction determines the size of a particular sample format. * This function determines the size of a particular sample format.
* if the format is not recognized, this returns zero. * if the format is not recognized, this returns zero.
*/ */
static size_t computeSampleSizeFromFormat( PaSampleFormat format ) static size_t computeSampleSizeFromFormat( PaSampleFormat format )
{ {
switch( format ) { switch( format & (~paNonInterleaved) ) {
case paFloat32: return 4; case paFloat32: return 4;
case paInt32: return 4; case paInt32: return 4;
case paInt24: return 3; case paInt24: return 3;
@ -91,7 +91,7 @@ static size_t computeSampleSizeFromFormat( PaSampleFormat format )
*/ */
static size_t computeSampleSizeFromFormatPow2( PaSampleFormat format ) static size_t computeSampleSizeFromFormatPow2( PaSampleFormat format )
{ {
switch( format ) { switch( format & (~paNonInterleaved) ) {
case paFloat32: return 4; case paFloat32: return 4;
case paInt32: return 4; case paInt32: return 4;
case paInt24: return 4; case paInt24: return 4;

View file

@ -107,6 +107,7 @@ int main( int argc, char **argv )
int framesPerBuffer; int framesPerBuffer;
double sampleRate = 44100.0; double sampleRate = 44100.0;
char str[256]; char str[256];
char *line;
printf("pa_minlat - Determine minimum latency for your computer.\n"); printf("pa_minlat - Determine minimum latency for your computer.\n");
printf(" usage: pa_minlat {userBufferSize}\n"); printf(" usage: pa_minlat {userBufferSize}\n");
@ -157,24 +158,34 @@ int main( int argc, char **argv )
/* Ask user for a new nlatency. */ /* Ask user for a new nlatency. */
printf("\nMove windows around to see if the sound glitches.\n"); printf("\nMove windows around to see if the sound glitches.\n");
printf("Latency now %d, enter new number of frames, or 'q' to quit: ", outLatency ); printf("Latency now %d, enter new number of frames, or 'q' to quit: ", outLatency );
fgets( str, 256, stdin ); line = fgets( str, 256, stdin );
{ if( line == NULL )
/* Get rid of newline */ {
size_t l = strlen( str ) - 1; go = 0;
if( str[ l ] == '\n') }
str[ l ] = '\0'; else
} {
if( str[0] == 'q' ) go = 0; {
else /* Get rid of newline */
{ size_t l = strlen( str ) - 1;
outLatency = atol( str ); if( str[ l ] == '\n')
if( outLatency < minLatency ) str[ l ] = '\0';
{ }
printf( "Latency below minimum of %d! Set to minimum!!!\n", minLatency );
outLatency = minLatency;
} if( str[0] == 'q' ) go = 0;
} else
/* Stop sound until ENTER hit. */ {
outLatency = atol( str );
if( outLatency < minLatency )
{
printf( "Latency below minimum of %d! Set to minimum!!!\n", minLatency );
outLatency = minLatency;
}
}
}
/* Stop sound until ENTER hit. */
err = Pa_StopStream( stream ); err = Pa_StopStream( stream );
if( err != paNoError ) goto error; if( err != paNoError ) goto error;
err = Pa_CloseStream( stream ); err = Pa_CloseStream( stream );