shithub: riscv

Download patch

ref: a6f3ba79c2b50bb6f946a7c5904859971dee6908
parent: 90148cbe87e347d9cc9a86d11e76ba1615291805
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Mar 19 17:15:43 EDT 2014

audiohda: start playback only when we have a minimum delay buffered

--- a/sys/src/9/pc/audiohda.c
+++ b/sys/src/9/pc/audiohda.c
@@ -1319,9 +1319,12 @@
 static void
 hdakick(Ctlr *ctlr)
 {
+	int delay;
+
 	if(ctlr->sout.active)
 		return;
-	if(buffered(&ctlr->sout.ring) > Blocksize)
+	delay = ctlr->adev->delay*BytesPerSample;
+	if(buffered(&ctlr->sout.ring) >= delay)
 		streamstart(ctlr, &ctlr->sout);
 }
 
@@ -1486,7 +1489,13 @@
 		adev->speed = a[0];
 		break;
 	case Vdelay:
-		adev->delay = a[0];
+		if(a[0] < Blocksize/BytesPerSample) {
+			adev->delay = Blocksize/BytesPerSample;
+		} else if(a[0] > (ctlr->sout.ring.nbuf/BytesPerSample)-1) {
+			adev->delay = (ctlr->sout.ring.nbuf/BytesPerSample)-1;
+		} else {
+			adev->delay = a[0];
+		}
 		break;
 	}
 	return 0;