deviceSelectorComponent() crashes if device numChannels = 0


Hey Jules -

I noticed this morning that when I have a device with no input channels open,
then create a deviceSelectorComponent and try to switch deviceType … it leads to a crash.

specifically, walking through juce_amalgamated.cpp in the routine:

void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, const bool treatAsChosenDevice)

it’s fine until the sendChangeMessage (this);

which triggers a:

void AudioSampleBuffer::clear() throw()
for (int i = 0; i < numChannels; ++i)
zeromem (channels[i], size * sizeof (float));

Which causes an issue since the numChannels is undefined for some reason? I tried a jassert numChannels > 0 … but it crashes on the statement and can’t seem to evaluate numChannels. Not sure.

Anyway, pretty sure that’s as far as I can quickly track it … otherwise lovin the new features in 1.5 … keep up the good work.


Can’t see what’s going on there… Where is AudioSampleBuffer::clear being called from?


The sendChangeMessage triggers it … not my code, I just figured you had a lower level changelistener somewhere that responded automatically to the AudioDeviceManager.

If not so, then maybe I am missing something here … system definitely crashes immediately after that change message is sent.


sendChangeMessage just posts a message and returns, it won’t call any methods directly. Maybe post a stack trace?