Fix for portaudio ALSA-OSS duplex problem

(Required for Audacity)

UPDATE ON PROGRESS WITH THIS - PLEASE READ!

In September 2006 I posted here and elsewhere patches to fix 'portaudio with Alsa-OSS' duplex mode so record and playback number of channels can be different, and this involved a patch to ALSA and to portaudio.

Recently I made a fresh attempt to get the ALSA part accepted into mainstream code.  A 'thorough' discussion followed, and an alternative approach was proposed which did not need ALSA changing at all, instead changing the way the application accessed the OSS.  At first I was not convinced and questioned which was really the 'right' way, but now I am happy with the resulting recommendation for accessing OSS devices.  A documentation patch has been accepted into ALSA to confirm the correct method, and the paragraph is given below.  Note this applies equally to other OSS implementations, and is the 'compatible' solution.

If portaudio is changed to reflect this, then there is no problem with the duplex access.  As it turns out, it can actually be done with a single extra line, although that obscures the underlying change.  Patch pa_unix.c-OSS-fix.diff is available below.

My recommendation is that this alternative patch is used in preference to the original two which are no longer available here; note also it avoids having to re-compile ALSA

To download patch to portaudio (used in Audacity): Click Here

Extract from revised OSS-Emulation.txt

" Duplex Streams

==============

Note that when attempting to use a single device file for playback and capture, the OSS API provides no way to set the format, sample rate or number of channels different in each direction. Thus

	io_handle = open("device", O_RDWR)
will only function correctly if the values are the same in each direction.

To use different values in the two directions, use both

	input_handle = open("device", O_RDONLY)
	output_handle = open("device", O_WRONLY)
and set values for the corresponding handle. "