ref: 866ee3ab5d0818194cca8c04d1f3ec2ff1d148c9
parent: 47bb182b5bf5b6c7f1e5f92eefad5791bafce94c
author: cinap_lenrek <[email protected]>
date: Sun Jan 27 09:00:42 EST 2013
audioac97, audiohda: dont block on close, just pad the last block with zeros
--- a/sys/src/9/pc/audioac97.c
+++ b/sys/src/9/pc/audioac97.c
@@ -390,16 +390,15 @@
{
Ctlr *ctlr;
Ring *ring;
- uchar z[1];
if(mode == OREAD)
return;
- z[0] = 0;
ctlr = adev->ctlr;
ring = &ctlr->outring;
while(ring->wi % Blocksize)
- ac97write(adev, z, sizeof(z), 0);
+ if(writering(ring, (uchar*)"", 1) <= 0)
+ break;
}
static Pcidev*
--- a/sys/src/9/pc/audiohda.c
+++ b/sys/src/9/pc/audiohda.c
@@ -1296,7 +1296,7 @@
hdaclose(Audio *adev, int mode)
{
Ctlr *ctlr;
- uchar z[1];
+ Ring *ring;
ctlr = adev->ctlr;
if(mode == OREAD || mode == ORDWR){
@@ -1304,11 +1304,10 @@
streamstop(ctlr, &ctlr->sin);
}
if(mode == OWRITE || mode == ORDWR){
- if(ctlr->sout.active){
- z[0] = 0;
- while(ctlr->sout.ring.wi % Blocksize)
- hdawrite(adev, z, sizeof(z), 0);
- }
+ ring = &ctlr->sout.ring;
+ while(ring->wi % Blocksize)
+ if(writering(ring, (uchar*)"", 1) <= 0)
+ break;
}
}