Currently (and since I'm supposed to be doing stuff for TransGaming now),
I'm looking at moving/merging the DirectSound device-specific code with
the WINMM device drivers, so that we'd have common drivers for both
standard WINMM and DirectSound, instead of the current mess of two
different implementations. (The same thing should preferably be done about
DirectInput, but I'm concentrating on DirectSound right now.)
So I looked at the DirectX DDK to see how Windows does it. As expected,
DirectSound is just extra functionality in the normal soundcard device
drivers. The Win95 interface for this is supposedly obsoleted by Win98's
new WDM device driver structure, but since the current WINMM use Win95's
model and not the WDM model, I'll just ignore WDM (it doesn't really
matter for us since we can't use native soundcard drivers anyway).
Well, the DirectSound extension to a normal WINMM device drivers is like
this:
- when a soundcard driver is loaded/initialized/configured/whatever
(CONFIG_START), it calls into dsound.vxd's exported VxD call
DSOUND_RegisterDeviceDriver with a pointer to its IDsDriver interface
(which seems to be the hardware-level version of IDirectSound).
- when the IDsDriver interface is registered with DirectSound, then
DirectSound will just call the methods in there for future communication
with the driver, including grabbing it with Open(), getting capabilities,
and creating primary surfaces etc.
(If a IDsDriver is not available, then DirectSound will emulate using the
standard waveOut routines instead, which is why running native dsound.dll
seems to work for some.)
The IDsDriver stuff is straightforward and should probably be added to the
winmm drivers, no problem... the question is how we should let DirectSound
contact the winmm drivers to get the IDsDriver interface in the first
place in Wine, since it seems rather kludgy to implement that VxD
interface, considering that loading libdsound.so should preferably be
optional.
Of course, I can easily think up a few possible ways myself, but I'd
rather hear what the design/multimedia authorities (Eric?) have to say
first...