Issues in juce_linux_ALSA format conversion


In the code below, the first loop is OK whilst the second one crashes on little endian platforms (at line 209 in juce_AudioDataConverters.h). Is there a good reason for that ?

This phenomena occurs in juce_linux_ALSA, causing crashes (line 327 in juce_linux_ALSA.cpp) when the device is non-interleaved (the AudioData::Converter is always created with AudioData::Interleaved as destination format, which I believe is the origin of the issue).
My workaround is too pass the ‘isInterleaved’ flag up to the createConverter functions (around lines 396). Could you please have a look at that ?

And while we’re here: the maximum number of channels is restricted to 32 (line 78 in juce_linux_ALSA.cpp), which is annoying. RME cards have 192 channels and they are well supported in ALSA (that’s the one I’m using at the moment). So, could you please remove the limitation in line 78 (or maybe make something like 256 instead of 32).

Thanks in advance

   const unsigned int numChannels = 2;
   const unsigned int numSamples  = 512;

   AudioSampleBuffer buffer( numChannels, numSamples );

   float* const* const data = buffer.getArrayOfWritePointers();

   for (unsigned int i = 0; i < numChannels; ++i)
       jassert( data[i] != nullptr );
       AudioDataConverters::convertFloatToInt32LE( data[i], data[i], numSamples );

   typedef AudioData::Pointer <AudioData::Float32, AudioData::LittleEndian, AudioData::NonInterleaved, AudioData::Const> SourceType;
   typedef AudioData::Pointer <AudioData::Int32, AudioData::LittleEndian, AudioData::Interleaved, AudioData::NonConst> DestType;

   AudioData::ConverterInstance < SourceType, DestType > converter ( 1, numChannels );

   for (unsigned int i = 0; i < numChannels; ++i)
       jassert( data[i] != nullptr );
       converter.convertSamples( data[i], data[i], numSamples );

OK. I’ve increased the maximum channel number to 256. Your fix for the crash looks good to me but I’d like to test it a bit more carefully. Is there anyway I can reproduce the crash in Ubuntu with some kind of virtual ALSA device?

Hi Fabian,

Thanks for the quick reply.
To reproduce the crash, you would need a device with RW_NONINTERLEAVED access flag. I dont know if there is any way to create a virtual ALSA device like that.
If you send me your code, I could test it with two hardware interfaces that I have at hand. At the moment, I dont see other options to test/reproduce.

OK can you check if it is fixed on develop now (commit 91e0385)?

Thanks Fabian. Your commit works as expected. As far as I can tell, the issue is solved.