shithub: zuke

Download patch

ref: 4ca30bfbe8de3aa2727a4e32d7d32a54d4d29438
parent: 4c5bf2f861bb45cb1c2fbce54217c06948c1c8ab
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sat Feb 20 13:10:39 EST 2016

count bytes written; increase relay buffer size; chanclose?chanfree

--- a/zuke.c
+++ b/zuke.c
@@ -15,6 +15,8 @@
 	Cstart = 1,
 	Cstop,
 	Ctoggle,
+
+	Relbufsz = 65536,
 };
 
 static Meta *pl;
@@ -31,6 +33,7 @@
 int mainstacksize = 32768;
 
 static int audio;
+static u64int byteswritten;
 static int pcur, pcurplaying;
 static int scroll, scrollsz;
 static Image *cola, *colb;
@@ -65,7 +68,7 @@
 			line(screen, left, right, 0, 0, 0, colb, sp);
 		}
 
-		snprint(tmp, sizeof(tmp), "%s - %s - %s", pl[i].artist[0], pl[i].album, pl[i].title);
+		snprint(tmp, sizeof(tmp), "%s  -  %s  -  %s", pl[i].artist[0], pl[i].album, pl[i].title);
 		if(pcur == i){
 			Rectangle sel;
 			sel = screen->r;
@@ -118,13 +121,14 @@
 		if(c != Cstart)
 			return;
 		io = ioproc();
-		buf = malloc(8192);
+		buf = malloc(Relbufsz);
+		byteswritten = 0;
 	}
 
 	pcurplaying = player->pcur;
 	redraw(screen, 1);
 
-	while((n = ioread(io, p[1], buf, 8192)) > 0){
+	while((n = ioread(io, p[1], buf, Relbufsz)) > 0){
 		c = nbrecvul(player->ctl);
 		if(c == Cstop)
 			goto stop;
@@ -135,6 +139,7 @@
 		}
 		if(iowrite(io, audio, buf, n) != n)
 			break;
+		byteswritten += n;
 	}
 
 	if(n == 0){ /* end of the song, need to skip to the next one */
@@ -176,8 +181,8 @@
 
 	sendul(player->ctl, Cstop);
 	recvp(player->ev); /* wait until it dies */
-	chanclose(player->ev);
-	chanclose(player->ctl);
+	chanfree(player->ev);
+	chanfree(player->ctl);
 	free(player);
 }