Help with Asio to DSound change crash


#1

I have a strange problem which i can’t reproduce in the juce demo :-/
been stepping through the debugger quite a while now.

When I start my application with DirectSound as startup device everything is fine.
I can switch between asio and direct sound driver without problems.

But when I start my application with an ASIO device selected, the program crashes as soon as i switch to a DSound device in the AudioDeviceSelectorComponent.

It seems like 1 of my 2 AudioCallback’s (added with audioDeviceManager.addAudioCallback(…) on startup)
gets corrupted on device change. since the programm crashes at the following line in AudioDeviceManager

callbacks.getUnchecked(i)->audioDeviceIOCallback (inputChannelData, numInputChannels, tempChans, numOutputChannels, numSamples);

as it tries to get my 2nd callback pointer wich now is set to 0x4 after the change to the DSound device.
Neither of the 2 callbacks gets deleted during device change.

If i remove the 2nd callback completely, it crashes while fetching the first callback after the device change (which works just fine if there is a 2nd callback afterwards).

currently using the tip, but happened as well with 1.53

any ideas how to solve this or how this could happen?

Comboy


#2

as a fix I found it works if I remove my audio callbacks before switching the device and add them after the AudioDeviceSelectorComponent returns from its modal state.

Is this neccessary in general or am I missing something else?

comboy


#3

Presumably it’s something you’re doing in your callback that’s crashing. Perhaps the two functions can’t cope with being called from two different threads, as might happen when the devices change over?