Alsa initialization change

Kevin Koltzau kevin at
Wed Jun 15 19:39:36 CDT 2005

On Tuesday 14 June 2005 11:21 pm, Jeremy White wrote:
> Kevin Koltzau wrote:
> Actually, try this one instead.  Turns out that if
> you open a device with default:0 on some versions
> of alsalib (my laptop, as opposed to my work box),
> then snd_pcm_name() fails.  Sigh.

Getting closer, I had to change
+            /*----------------------------------------------------------------
+            ** See if it's a valid playback device 
+            **--------------------------------------------------------------*/
+            if (ALSA_TestDeviceForWine(card, device, SND_PCM_STREAM_PLAYBACK) == 0)

to check for < 0 (would return -16 when it failed), and it detected default and worked great!

One try it was actually able to open hw:0,0, though the format I was sending through was
unsupported and ended up failing to play. It would have worked if plug:hw:0,0 was opened instead
as plug will do format conversion. I would prefer default in that case also however, as wine
was blocking all my other audio apps from working. Always checking for default, even if hw works,
might be a good idea.

Also for
+        sprintf(ctlname, "hw:%d", fixedctlcard == -1 ? card : fixedctlcard);
+        rc = snd_ctl_open(&ctl, ctlname, SND_CTL_NONBLOCK);
the case default was used,  you should open default as well rather then hw:0

More information about the wine-devel mailing list