shithub: pplay

Download patch

ref: 868c43888581afd3c678b88d21890c8b110ab7cd
parent: 13c8ff13ac27366573699e1690d91640d99f1b79
author: qwx <[email protected]>
date: Sun Oct 30 18:32:23 EDT 2022

really decouple drawing samples from playback, fix graphics glitch at startup

apparently the last change there didn't really fix anything, despite full
conviction that the solution was arrived at and observed.  very me!
this patch fixes it all.

--- a/draw.c
+++ b/draw.c
@@ -39,9 +39,10 @@
 
 	for(;;){
 		recvul(drawc);
-		lockdisplay(display);
 again:
+		lockdisplay(display);
 		draw(viewbg, viewbg->r, display->black, nil, ZP);
+		unlockdisplay(display);
 		n = viewe - views;
 		/*if(!file)*/
 			p = pcmbuf + views;
@@ -81,12 +82,13 @@
 				x+1, bgscalyl - lmin / bgscalf);
 			r = Rect(x, bgscalyr - rmax / bgscalf,
 				x+1, bgscalyr - rmin / bgscalf);
+		lockdisplay(display);
 			draw(viewbg, l, col[Csamp], nil, ZP);
+		unlockdisplay(display);
 			if(stereo)
 				draw(viewbg, r, col[Csamp], nil, ZP);
 			x++;
 		}
-		unlockdisplay(display);
 	}
 }
 
@@ -244,7 +246,7 @@
 	viewr = rectsubpt(screen->r, screen->r.min);
 	freeimage(viewbg);
 	freeimage(view);
-	viewbg = eallocimage(viewr, 0, DNofill);
+	viewbg = eallocimage(viewr, 0, DBlack);
 	view = eallocimage(viewr, 0, DBlack);
 	if(stereo){
 		midr = viewr;
@@ -297,7 +299,7 @@
 	col[Cline] = eallocimage(Rect(0,0,1,1), 1, 0x884400FF);
 	col[Cloop] = eallocimage(Rect(0,0,1,1), 1, 0x777777FF);
 	loope = filesz;
-	if((drawc = chancreate(sizeof(ulong), 0)) == nil)
+	if((drawc = chancreate(sizeof(ulong), 4)) == nil)
 		sysfatal("chancreate: %r");
 	if(proccreate(drawsamps, nil, mainstacksize) < 0)
 		sysfatal("proccreate: %r");