devaudio: interlock reads too

This commit is contained in:
cinap_lenrek 2011-06-04 01:04:14 +00:00
parent 75edd13d78
commit f83d4972db

View file

@ -215,15 +215,15 @@ audioread(Chan *c, void *a, long n, vlong off)
if(fn == nil) if(fn == nil)
error(Egreg); error(Egreg);
switch((ulong)c->qid.path){
case Qaudioctl:
case Qaudiostatus:
case Qvolume:
qlock(ac); qlock(ac);
if(waserror()){ if(waserror()){
qunlock(ac); qunlock(ac);
nexterror(); nexterror();
} }
switch((ulong)c->qid.path){
case Qaudioctl:
case Qaudiostatus:
case Qvolume:
/* generate the text on first read */ /* generate the text on first read */
if(ac->data == nil || off == 0){ if(ac->data == nil || off == 0){
long l; long l;
@ -237,12 +237,15 @@ audioread(Chan *c, void *a, long n, vlong off)
} }
/* then serve all requests from buffer */ /* then serve all requests from buffer */
n = readstr(off, a, n, ac->data); n = readstr(off, a, n, ac->data);
break;
default:
n = fn(adev, a, n, off);
}
qunlock(ac); qunlock(ac);
poperror(); poperror();
return n; return n;
} }
return fn(adev, a, n, off);
}
static long static long
audiowrite(Chan *c, void *a, long n, vlong off) audiowrite(Chan *c, void *a, long n, vlong off)