Page 1 of 1

OSS bug (possibly in portaudio) when ALSA exists too + patch

Posted: Thu Mar 19, 2009 8:32 pm
by SLi
Hi,

I think I've discovered and fixed a bug in portaudio (while hunting for another bug) that affects audacity 1.3.7, however I'm not sure if my fix is correct.

When I look at Help -> Audio Device Info, I have ALSA devices as devices 0..6, and then a OSS /dev/dsp. However the OSS device's list of supported rates is empty. This also causes record and play to fail with "Error while opening sound device. Please check the output device settings and the project sample rate."

I believe the bug is in pa_unix_oss.c, function IsFormatSupported(), in lines 665 and 671.

The problem is that inputParameters->device or outputParameters->device as passed by the caller in pa_front.c is already in the host api device index space (i.e. 0 = first OSS device, not first device portaudio knows of), but the code calls PaUtil_DeviceIndexToHostApiDeviceIndex() for it. This causes the call to fail or return a wrong index if OSS is not the first host API known by portaudio.

Here's a minimal patch to fix the problem. It fixes it for me, but I don't understand the code well enough to be sure it's correct. It possibly would be prudent to also check that *Parameters->device is in the correct range.

Code: Select all

+++ audacity-1.3.7/lib-src/portaudio-v19/src/hostapi/oss/pa_unix_oss.c	2009-03-19 20:31:29.000000000 +0200
@@ -662,13 +662,13 @@
 
     if( inputChannelCount > 0 )
     {
-        result = PaUtil_DeviceIndexToHostApiDeviceIndex(&device, inputParameters->device, hostApi);
+        result = inputParameters->device; /* PaUtil_DeviceIndexToHostApiDeviceIndex(&device, inputParameters->device, hostApi); */
         if (result != paNoError)
             return result;
     }
     else
     {
-        result = PaUtil_DeviceIndexToHostApiDeviceIndex(&device, outputParameters->device, hostApi);
+        result = outputParameters->device; /* PaUtil_DeviceIndexToHostApiDeviceIndex(&device, outputParameters->device, hostApi); */
         if (result != paNoError)
             return result;
     }


Re: OSS bug (possibly in portaudio) when ALSA exists too + p

Posted: Thu Mar 19, 2009 11:28 pm
by steve
I don't know enough about the Audacity code to help with your question, but if you look on the Audacity wiki there is some information about submitting patches. This will put you in touch with the developers who are the people that are able to answer your questions on this - I'm sure they will be pleased to hear from you. http://audacityteam.org/wiki/index.php? ... ingPatches