[Portaudio] Alsa: support for sub-device & 24-bit BE format only

Ross Bencina rossb-lists at audiomulch.com
Wed Mar 21 22:30:02 EDT 2012

On 22/03/2012 2:34 AM, Alan Horstmann wrote:
> If Portaudio is doing conversions, might it be
> better to put all the code in a common area, or merge it into the existing
> convertor parts?

Some general comments:

PortAudio's converter routines currently only address the conversions 
that are targetted by the public PA API. This leaves some obscure (and 
some not so obscure) conversions unaddressed: namely some packed formats 
and byte-swapped formats. To my knowledge, the only host API so far that 
has needed support for non-PA public formats is ASIO -- in that case 
there are some additional pre-conversion steps in pa_asio.c to get the 
data into a PA supported format (maybe bitshifting to get the right 
alignment, or byte swapping to get the right endianness). I don't know 
anything about PA/ALSA in this regard but perhaps this is what Dmitry is 

In general I think the PA code should prefer to use the native API (ie 
ALSA lib) to obtain formats that the PA converters can deal with. So it 
may be that the code in question could be handled by ALSA. But maybe not.

Like all common code -- there's no point having common code that isn't 
needed by more than one API. There's a general pattern we are following 
which is to do things in specific host APIs and then factor out to 
common code if duplication becomes apparent. The rule of thumb I 
generally follow is "you can write something twice, but if it's written 
three times it should be factored out."

If it emerges that multiple host APIs need common conversion functions 
that pa_converters.c doesn't define then we can look at adding some 
there, or creating some auxilliary converters (eg for byte swapping). On 
the other hand, perhaps linux provides some native routines for 
byteswapping that should be preferred to a portable code solution.


More information about the Portaudio mailing list