SFML community forums

Help => Audio => Topic started by: HughPH on August 12, 2017, 02:05:00 pm

Title: (Windows) Kernel crash after audio device unplugged
Post by: HughPH on August 12, 2017, 02:05:00 pm
So I have a USB audio decoder attached to my PC. I use it when nobody else is in the room watching TV or similar. Typically I will unplug it when my noises would be disturbing others, and switch to my earphones. In pretty-much everything, this works. Except when I'm using SFML.

When I unplug the device, I immediately get this message:
"AL lib: (EE) MMDevApiProc: Failed to get padding: 0x88890004"

Some time later (seems to be a few seconds after I try to play a previously unplayed sound) my code crashes and I get this during a call to window.DispatchEvents:

Exception thrown at 0x00007FFC06F679A3 (KernelBase.dll) in GameCore.exe: 0xC0000005: Access violation reading location 0x0000000000000004.

So... how can I:
- Detect the removal of a device (or, preferably, detect the change of default device - I'd like it to work when I plug the USB amplifier in, too)
- Pause all sounds
- Change devices (reset audio, whatever is required)
- Resume all sounds

Any suggestions gratefully received!

Many thanks
Title: Re: (Windows) Kernel crash after audio device unplugged
Post by: HughPH on August 22, 2017, 01:58:15 am
Anything at all?

Should I switch to something else for audio?
Title: Re: (Windows) Kernel crash after audio device unplugged
Post by: eXpl0it3r on August 22, 2017, 01:29:34 pm
See the pretty much same discussion we just had in this thread (https://en.sfml-dev.org/forums/index.php?topic=21273.0).

tl;dr Unplugging devices while in use isn't really supported by SFML.
Title: Re: (Windows) Kernel crash after audio device unplugged
Post by: HughPH on August 22, 2017, 04:33:26 pm
Thanks eXpl0it3r I'll check out the discussion.

Unplugging devices is something I do and I imagine others will do the same, so I might look for an alternative.