[Openal-devel] ALC_ENUMERATE_ALL_EXT and pluggable sound devices
Daniel PEACOCK
dpeacock at creativelabs.com
Thu Sep 17 02:20:06 PDT 2009
Hi,
> Day by day, pluggable devices become even more popular. They are cheap
> and very attractive for mobile users. Some of pluggable USB sound
> devices have good quality. For this reason, it is not suitable anymore
> to be obliged to restart an application (or a game) after connecting a
> device to be able to use it... And I think that ALC_ENUMERATE_ALL_EXT
> extension should reflect devices changes of the system.
>
> A second problem was that I could't list the current connected USB
> device by using ALC_ALL_DEVICES_SPECIFIER. Inspecting some OpenAL code
> in SVN (specifically the Windows Router code), I discovered that the
> variables g_pDeviceList, g_pCaptureDeviceList and g_pAllDevicesList are
> initialized only once, in the occurrence of calling opening functions
> like alcOpenDevice (see the function BuildDeviceList).
I agree that this is a problem that needs to be solved. The reason why
these variables are initialized once is purely as an optimization to
prevent repeated loading and unloading of DLLs. However, I think you are
probably right - it would be better to always get an up-to-date list of
available devices when calling the enumerate calls (ALC_DEVICE_SPECIFIER
and ALC_ALL_DEVICES_SPECIFIER).
The tricky part is, perhaps, how an application knows that it should
refresh the available devices. e.g. An application should definitely not
keep calling an enumerate function just to see if anything is different -
that would be really slow.
Ideally if the Router detected a change of audio devices, then it could set
a flag that enables a refresh of the device lists on the *next* call to an
enumerate function. (We could even add a new function that the application
can call to determine if the device list has potentially changed).
Unfortunately I don't know of any reliable way on Windows XP and below of
getting a notification that new audio hardware has appeared (or
disappeared). There are methods of doing that - but I believe they only
work if the application has the focus. On Vista (and presumably Win7)
there are new methods for dealing with this that work really well.
I would imagine that an OpenAL game / application would probably only make
device enumeration calls at initialization time, and then at some time that
was at the user's request - e.g. if the user goes to the "Audio Options".
That would make sense to me ... e.g. a user launches a game, then plugs in
their USB headset, and then goes to the audio options screen to select them
as his output device.
If that is the most likely scenario, then simply updating the router to
always offer an up-to-date list of devices in response to enumerate calls
may be sufficient.
> I personally
> tried to change the code to force a reinitialization of the structures
> every time the function BuildDeviceList was called, but I had no success
> when trying to select them afterwards (the device was listed, but I
> couldn't use it; the alcOpenDevice issued error opening the device).
I'll take a look at the code - it's been a while!
> Do you see any solution for this in the OpenAL roadmap? Or this
> "feature" should be implemented elsewhere?
I think it could potentially be added in the very near future.
Dan
Creative Labs, UK
More information about the Openal-devel
mailing list