[Openal] Handling device changes on Vista

Daniel PEACOCK dpeacock at creativelabs.com
Tue Apr 14 02:55:13 PDT 2009





Hi Niklas,

> What is the recommended way of handling sound device changes (new
> devices being created, old devices being removed) when using OpenAL?

I don't think we have a recommending way of handling this.

> This issue is especially important on Windows Vista where new devices
> can appear when a uses plugs in his headphones. (I.e. a game may start
> with headphones unplugged and find no devices, then when the headphones
> are plugged in a new device appears.)

True.

> As far as I can tell, there is no mechanism for detecting "device
> creation" or "device loss" within OpenAL. Should I try to detect these
> events using Windows functionality? Or regularily poll the system by
> enumerating the devices? And then re-initialize the sound system with a
> new device if detected.

That's correct, there are no mechanisms in OpenAL for detecting these
events.  I think an extension that handles this has been proposed.

I'm not aware of a way to get a notification from Windows that an audio
device has been added, removed, or become the new default playback device.
That doesn't mean it doesn't exist - I just haven't encountered it before.
Assuming it doesn't, then you would need to poll Windows to find out what
audio devices are available.   If you detect that something has changed -
and you consider that something that should be acted upon - then I think
you may have to shutdown the OpenAL system, and unload openal32.dll, then
re-load openal32.dll and request the new lists of devices.  This is because
the OpenAL32.dll router only enumerates devices once.  NOTE : I've not
tested this scenario ... there may be other issues.

Dan



More information about the Openal mailing list