audioDeviceIOCallback bug

I lent a P4 laptop to do some tests on it. It has a SIS7012 soundchip and something very weird happens on it:

Although it has only 1 Stereo Output and 1 Stereo Input, audioDeviceIOCallback receives as parameters 4 output channels and 4 inputs channels. Strange is that the AudioDeviceSelectorComponent only lets me select one stereo output or stereo input, which both are called “Left/Right” (so the selector works as it should, but the audioDeviceIOCallback does not).

I noticed that the 2 first output buffer pointers of audioDeviceIOCallback are always 0 and the 2 following are the “real pointers” to “Left/Right”.

Also, in 50% of the cases, the CPU usage goes up to 100% directly at the start of my app, even if there is no code in audioDeviceIOCallback. When I select << no audio device >> in the AudioDeviceSelectorComponent, the CPU usage goes back to 1%.

This is with Juce 1.45.

Edit: I just tried out with my ESI U46DJ (which has 3 Stereo Outputs and 2 Stereo Inputs) on the same laptop, and there’s also a strange behaviour when using non-ASIO drivers: numInputBuffers AND numOutputBuffers equals 10 (so it is the sum of the output plus the input buffers). This also explains the number 4 (2 outs + 2 ins) for the SiS7012.

Perhaps I am doing something completely wrong?

Sorry, is this ASIO that you’re using?

No, when I use an ASIO driver, everything works. But as soon as I choose a non-ASIO driver, the problem occurs.

Maybe these other channels are unused spdif connections or something?

Nope, there is no SPDIF or whatever. Just Line and Mic.

And for the ESI U46DJ, why does the callback function get 10 inputs and 10 outputs instead of 4 inputs and 6 outputs as parameters?

Seems like the function always gets the sum of outputs and inputs. Strange…

Never seen that myself. What names does it give them?

What names do you mean? Where should I check those names?

As written previously, in the AudioDeviceSelectorComponent, the inputs and outputs are listed correctly.

Oh maybe I mis-read your post. I don’t think there’s actually anything wrong here - I guess some of those channels that are passed in are null pointers? That’s actually how it works - just ignore the null ones.

So it is normal that, although my soundcard has only 4 physical inputs, audioIODeviceCallback() tells me that there are 10?

The array you get has one pointer per channel, and some of them might be null if you didn’t enable that channel when you called AudioIODevice::open(). If you want to see what all the channels are called, you can call AudioIODevice::getInputChannelNames, and that should be a big clue about what’s going on.

Ok, I understand that, if not activated some inputs may be NULL. But my soundcard has 4 Cinch Inputs (is that clear now?). So is it normal or even possible that audioIODeviceCallback tells me that there are 10 input channels?

Ok, but for the third time, please tell me what names is it reporting for these 10 channels! Are they channels from another device? Duplicates of other channels? Blank strings? Special internal channels for that device?

Sure, there might be a bug, but unless we can work out where these extra channels are coming from, there’s not much I can suggest.

Well, for the SiS7012, when I call AudioIODevice::getInputChannelNames(), it returns a StringArray containing only 2 Strings, which are: “Left” and “Right” (which is correct), but totalNumInputChannels is now 10.

inputChannelDate[2] and inputChannelData[3] are non-0, all others are 0.

Is there anything else I can look at?

But that’s fine! Ignore the other 8 pointers, which will be null. If it tells you there are 2 channels, and you open it with 2 channels, and you get your 2 pointers back, it doesn’t matter if there are some extra null pointers in the array.

It does not tell me that there are 2 channels, it tells me there are 10.

so recap:

Soundcard: SiS7012. Physical Inputs: 2 , Physical Outputs: 2

audioIODeviceCallback() tells me:

totalNumInputsChannels=10 (although my soundcard has only a stereo jack input, so 2 inputs!)


AudioIODevice::getInputChannelNames()={“Left”,“Right”}, no empty Strings

No, it doesn’t! totalNumInputChannels only tells you how many elements are in the array. A better name would probably be “numChannelsInArray” or something. Doesn’t matter whether it’s 2, 10 or a million. It might even change from one callback to the next. But if you’ve asked for 2 channels, only 2 of them will be non-zero.

getNumInputChannels() is the thing that you how many channels there are, and it says 2, which is correct!

getNumInputChannels() ? to what class does this function belong to?

Sorry, I meant getInputChannelNames()

ok. my SiS7012 only has 2 outputs, which are both active.
Why do they appear in the outputChannelData array at positions 2&3 instead of 0&1 (0&1 are null) ? The index is just wrong!?

No, that’s how it works. I admit it’s a bit confusing, but there was definitely a reason (which I forget…) for having them at certain indexes.