[fpc-pascal] Strange error with Pa_IsFormatSupported from portaudio when used with Pascal headers AND Mac OS X.

Schindler Karl-Michael karl-michael.schindler at web.de
Sun Mar 7 19:18:58 CET 2010


Hi

If I use Pa_IsFormatSupported from portaudio with a different sample rate than the default, I get a division by zero error or other arithmetic error.

However, it needs very special conditions. It does not occur with the same Pascal program on linux. Also the very similar test program pa_devs written in C reports success for other sample rates.

Testprogram:

program TestPortAudioDevice;
{$MODE Delphi}
uses
 ctypes,
 PortAudio;
var
 PaError:         TPaError;
 inputParameters: PPaStreamParameters;
 sampleRate:      cdouble;
begin
 PaError := Pa_Initialize;
 New(inputParameters);
 inputParameters^.device                    := 0;
 inputParameters^.channelCount              := 2;  // checked before that device 0 has 2 channels.
 inputParameters^.sampleFormat              := paInt16;
 inputParameters^.suggestedLatency          := 0;
 inputParameters^.hostApiSpecificStreamInfo := nil;

 sampleRate := 44100;
 PaError    := Pa_IsFormatSupported(inputParameters, nil, sampleRate);  // this works fine. 44100 is the default sample rate

 sampleRate := 48000;
 PaError    := Pa_IsFormatSupported(inputParameters, nil, sampleRate);  // this crashes. See below. 

 Dispose(inputParameters);
 PaError := Pa_Terminate; 
end.

Runtime error 200 at $9261C7CB
 $9261C7CB
 $9261C532
 $9261C1C9
 $9261BD9A
 $9261BC7D
 $9261BBD5
 $926163F4
 $92615A40
 $92614A98
 $92614983

gdb backtrace shows that it is deep down in Apple libs (probably the reason, why it does not happen in linux).

(gdb) next
74	  PaError    := Pa_IsFormatSupported(inputParameters, nil, sampleRate);
(gdb) next

Program received signal EXC_ARITHMETIC, Arithmetic exception.
0x9261c7cb in SincKernel::CalculateFilterCoefficients ()
(gdb) backtrace
#0  0x9261c7cb in SincKernel::CalculateFilterCoefficients ()
#1  0x9261c532 in SincKernelFactory::ReferenceSincKernel ()
#2  0x9261c1c9 in Resampler2::Resampler2 ()
#3  0x9261bd9a in Resampler2Wrapper::Resampler2Wrapper ()
#4  0x9261bc7d in SampleRateConverter::SetConverterQuality ()
#5  0x9261bbd5 in SampleRateConverter::SampleRateConverter ()
#6  0x926163f4 in PCMConverterFactory::BuildConverterChain ()
#7  0x92615a40 in ConverterRegistry::CreateConverter ()
#8  0x92614a98 in _AudioConverterNewInternal ()
#9  0x92614983 in AudioConverterNew ()
#10 0x000b4bf2 in OpenAndSetupOneAudioUnit ()
#11 0x000b55a4 in OpenStream ()
#12 0x000b590a in IsFormatSupported ()
#13 0x000aec42 in Pa_IsFormatSupported ()
#14 0x00011669 in PASCALMAIN () at Test2.pas:74
#15 0x0002e845 in SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR ()
#16 0x000111e9 in _start ()
#17 0x00011118 in start ()





More information about the fpc-pascal mailing list