devaudio: serialize calls in devaudio, sb16: remove qlock

This commit is contained in:
cinap_lenrek 2011-06-04 00:28:17 +00:00
parent 5a333eb240
commit 15cdb69f61
2 changed files with 11 additions and 26 deletions

View file

@ -63,7 +63,6 @@ struct Blaster
struct Ctlr struct Ctlr
{ {
QLock;
Rendez vous; Rendez vous;
int active; /* boolean dma running */ int active; /* boolean dma running */
int major; /* SB16 major version number (sb 4) */ int major; /* SB16 major version number (sb 4) */
@ -535,11 +534,6 @@ audiowrite(Audio *adev, void *vp, long n, vlong)
p = vp; p = vp;
e = p + n; e = p + n;
ctlr = adev->ctlr; ctlr = adev->ctlr;
qlock(ctlr);
if(waserror()){
qunlock(ctlr);
nexterror();
}
ring = &ctlr->ring; ring = &ctlr->ring;
while(p < e) { while(p < e) {
if((n = writering(ring, p, e - p)) <= 0){ if((n = writering(ring, p, e - p)) <= 0){
@ -552,9 +546,6 @@ audiowrite(Audio *adev, void *vp, long n, vlong)
} }
p += n; p += n;
} }
poperror();
qunlock(ctlr);
return p - (uchar*)vp; return p - (uchar*)vp;
} }
@ -564,15 +555,8 @@ audioclose(Audio *adev)
Ctlr *ctlr; Ctlr *ctlr;
ctlr = adev->ctlr; ctlr = adev->ctlr;
qlock(ctlr);
if(waserror()){
qunlock(ctlr);
nexterror();
}
sleep(&ctlr->vous, inactive, ctlr); sleep(&ctlr->vous, inactive, ctlr);
setempty(ctlr); setempty(ctlr);
poperror();
qunlock(ctlr);
} }
static long static long

View file

@ -269,6 +269,11 @@ audiowrite(Chan *c, void *a, long n, vlong off)
if(fn == nil) if(fn == nil)
error(Egreg); error(Egreg);
qlock(ac);
if(waserror()){
qunlock(ac);
nexterror();
}
switch((ulong)c->qid.path){ switch((ulong)c->qid.path){
case Qaudioctl: case Qaudioctl:
case Qvolume: case Qvolume:
@ -276,20 +281,16 @@ audiowrite(Chan *c, void *a, long n, vlong off)
error(Etoobig); error(Etoobig);
/* copy data to audiochan buffer so it can be modified */ /* copy data to audiochan buffer so it can be modified */
qlock(ac);
if(waserror()){
qunlock(ac);
nexterror();
}
ac->data = nil; ac->data = nil;
memmove(ac->buf, a, n); memmove(ac->buf, a, n);
ac->buf[n] = 0; ac->buf[n] = 0;
n = fn(adev, ac->buf, n, 0); a = ac->buf;
qunlock(ac); off = 0;
poperror();
return n;
} }
return fn(adev, a, n, off); n = fn(adev, a, n, off);
qunlock(ac);
poperror();
return n;
} }
static void static void