PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.47k stars 304 forks source link

ALSA PortAudio doesn't support SND_PCM_FORMAT_S24_LE resp. SND_PCM_FORMAT_S24_BE formats #811

Open aholzinger opened 1 year ago

aholzinger commented 1 year ago

There is audio hardware (for example HifiBerry DIGI+ I/O) that is using SND_PCM_FORMAT_S24_LE which in spite of its name is a 32 bit padded format with 24 bits of resolution. But in contrast to SND_PCM_FORMAT_S32 which is also a 32 bit padded format with 24 bits of resolution, SND_PCM_FORMAT_S24_LE has its zero padding byte at the MSB) while SND_PCM_FORMAT_S32 is right justified (zero padding byte left in memory at the LSB, see https://stackoverflow.com/questions/40297935/alsa-using-pcm-s24le#40301874 for an explanation).

IMHO PortAudio should at least support SND_PCM_FORMAT_S24_LE when PA_LITTLE_ENDIAN is defined and SND_PCM_FORMAT_S24_BE when PA_BIG_ENDIAN is defined (and PA_LITTLE_ENDIAN is not defined).

Obviously this means that PortAudio will have to reorder the audio data, but otherwise software will need to play with ALSA internal sound formats and reorder the audio data itself.

RossBencina commented 1 year ago

It would be nice to fix this.

I seem to remember that @dmitrykos worked on this at one time (maybe?). I remember a dispute about avoiding adding additional formats to pa_converters.c. The way pa_asio.c does it is to pre-process the data before sending it to the buffer processor. But I'm not sure how relevant that is here.