ref: a75eb317520c72ab129ba2164550d68ed07ad560
parent: c470e77eae8d37cb084e1b195cba5643b88f8ea7
author: cinap_lenrek <cinap_lenrek@localhost>
date: Fri May 20 16:45:17 EDT 2011
devaudio: attach
--- a/sys/src/9/port/devaudio.c
+++ b/sys/src/9/port/devaudio.c
@@ -116,7 +116,7 @@
static Chan*
audioattach(char *spec)
{
- static int first = 1;
+ static int attached = 0;
Audiochan *ac;
Audio *adev;
Chan *c;
@@ -127,7 +127,7 @@
else
i = 0;
for(adev = audiodevs; adev; adev = adev->next)
- if(i-- == 0)
+ if(adev->ctlrno == i)
break;
if(adev == nil)
error(Enodev);
@@ -138,9 +138,10 @@
if((ac = audioclone(c, adev)) == nil)
error(Enomem);
- if(first && adev->volwrite){
- first = 0;
-
+ i = 1<<adev->ctlrno;
+ if((attached & i) == 0 && adev->volwrite){
+ attached |= i;
+
strcpy(ac->buf, "speed 44100");
if(!waserror()){
adev->volwrite(adev, ac->buf, strlen(ac->buf), 0);