git: 9front

Download patch

ref: 5ec1726dcd72112659584310100d7acef126c434
parent: 41aea3af9c3c5c16c04fc37af26d00368eb17cb4
author: cinap_lenrek <cinap_lenrek@gmx.de>
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;
 	}
 }
 
--