shithub: riscv

Download patch

ref: 15cdb69f61478a7a8133808f198f74ef38f33041
parent: 5a333eb240a9e3622c2f443310a7c1856a6551e8
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Fri Jun 3 20:28:17 EDT 2011

devaudio: serialize calls in devaudio, sb16: remove qlock

--- a/sys/src/9/pc/audiosb16.c
+++ b/sys/src/9/pc/audiosb16.c
@@ -63,7 +63,6 @@
 
 struct Ctlr
 {
-	QLock;
 	Rendez	vous;
 	int	active;		/* boolean dma running */
 	int	major;		/* SB16 major version number (sb 4) */
@@ -535,11 +534,6 @@
 	p = vp;
 	e = p + n;
 	ctlr = adev->ctlr;
-	qlock(ctlr);
-	if(waserror()){
-		qunlock(ctlr);
-		nexterror();
-	}
 	ring = &ctlr->ring;
 	while(p < e) {
 		if((n = writering(ring, p, e - p)) <= 0){
@@ -552,9 +546,6 @@
 		}
 		p += n;
 	}
-	poperror();
-	qunlock(ctlr);
-
 	return p - (uchar*)vp;
 }
 
@@ -564,15 +555,8 @@
 	Ctlr *ctlr;
 
 	ctlr = adev->ctlr;
-	qlock(ctlr);
-	if(waserror()){
-		qunlock(ctlr);
-		nexterror();
-	}
 	sleep(&ctlr->vous, inactive, ctlr);
 	setempty(ctlr);
-	poperror();
-	qunlock(ctlr);
 }
 
 static long
--- a/sys/src/9/port/devaudio.c
+++ b/sys/src/9/port/devaudio.c
@@ -269,6 +269,11 @@
 	if(fn == nil)
 		error(Egreg);
 
+	qlock(ac);
+	if(waserror()){
+		qunlock(ac);
+		nexterror();
+	}
 	switch((ulong)c->qid.path){
 	case Qaudioctl:
 	case Qvolume:
@@ -276,20 +281,16 @@
 			error(Etoobig);
 
 		/* copy data to audiochan buffer so it can be modified */
-		qlock(ac);
-		if(waserror()){
-			qunlock(ac);
-			nexterror();
-		}
 		ac->data = nil;
 		memmove(ac->buf, a, n);
 		ac->buf[n] = 0;
-		n = fn(adev, ac->buf, n, 0);
-		qunlock(ac);
-		poperror();
-		return n;
+		a = ac->buf;
+		off = 0;
 	}
-	return fn(adev, a, n, off);
+	n = fn(adev, a, n, off);
+	qunlock(ac);
+	poperror();
+	return n;
 }
 
 static void