Release Audio device driver gracefully

Hi, I am using JUCE to write an audio player application for my Octa capture sound card. But when the application crashes the Octa capture is not getting released. Is there are way to track and release the sound card? Is there are way to free any sound card if it is already occupied, and then initialize it.

 

Using Windows 7 as the platform.

If that happens, it's a bug in the soundcard driver - all decent drivers will detach themselves when a process exits, regardless of whether it crashes.

I remember having a few issues like on Windows that years ago with drivers by a couple of soundcard vendors who I won't name. Presumably you're using ASIO, which tends to be flakier than WASAPI or DSound.

And yeah, you could use JUCE_CATCH_UNHANDLED_EXCEPTIONS and JUCEApplicationBase::sendUnhandledException to catch crashes and make a last-ditch attempt to close your audio driver, but once you're into "undefined behaviour" territory, all bets are off.

But really it's the audio driver's job to handle this, not yours.

Thanks Jules for the response.

Unfortunately (or luckily) the exceptions i get now are Structured exceptions, using c++, in windows only way to catch it is by using __try __except statements which i dont want to do.

Tried JUCE_CATCH_UNHANDLED_EXCEPTIONS but it is not a good fit for this situation as even that could not catch this particular exception while works good for other types of exception.

I will try using some other sound card and update here my results.

I know eventually the code should be written to prevent any such exceptions, but for a moment i would like to be a pessimistic guy, to expect some exceptions like this to happen again, so fix it now to handle the release of sound card or never.