[Winmm/winealsa] Don't use asynchronous callbacks in dsound any more

Maarten Lankhorst m.b.lankhorst at gmail.com
Tue Dec 26 09:38:37 CST 2006

2006/12/25, Eric Pouech <eric.pouech at wanadoo.fr>:
> Maarten,
> nice work on Alsa (which is definitively needed !!)
> a couple of comments:
> - I know the winmm code (and drivers) is crippled by bad synchronisation
> tricks (like cleaning a field in a structure to signal a thread). This
> is bad (TM). So I'd suggest using here a real synchronisation object.

Well, what I have now works well enough, thread is sure to be killed,
which makes life easier. I don't see the point in making code more
complicated then it needs to be.

> - I wonder if it's a good idea to create another thread for this... but
> before merging all existing drivers' threads into a single one, I'd
> suggest using the fd oriented functions & poll (see
> snd_pcm_poll_descriptors and friends) instead of snd_pcm_wait, that'll
> ease up the future work.

I'm not sure if it's a good thing either to create a new thread for
it, but in the current driver model there are no other alternatives,
you are right it is easy enough to use poll(), but basically all I
would be doing is copy the code from snd_pcm_wait(), which does it for
me. If anyone wants to use poll() it is easy enough to copy the code
1:1 from the LGPL alsa sound library. However I saw no need for it and
to keep the code simple I just used snd_pcm_wait.

See alsa-lib/src/pcm/pcm.c for how snd_pcm_wait is implemented: It
just uses poll()

> Maarten Lankhorst a écrit :
> > Instead of using asynchronous callbacks that uses signals, use a
> > seperate thread that can be cancelled, this prevents deadlock issues.
> >
> > Basically we use snd_pcm_wait() that tells us when enough room is free
> > to commit another buffer, then we commit the previous buffer and make
> > the next buffer ready.
> > .....

More information about the wine-devel mailing list