shithub: zuke

Download patch

ref: 29431d5c36b1ddfb4050b753d816cf1a673e7dd5
parent: 6d6c45d94e4a4a3eebf344f646027a6e939b45d2
author: Sigrid Haflínudóttir <[email protected]>
date: Thu Jun 18 04:57:00 EDT 2020

don't get stuck forever on broken streams, skip to the next one

--- a/zuke.c
+++ b/zuke.c
@@ -440,7 +440,6 @@
 	player = player_;
 	noinit = 0;
 	bytesfrom = 0;
-	c = 0;
 	buf = nil;
 	trycoverload = 1;
 	io = nil;
@@ -479,6 +478,7 @@
 	close(p[0]);
 
 	byteswritten = 0;
+	c = 0;
 	if(!noinit){
 		sendul(player->ev, Evready);
 		buf = malloc(Relbufsz);
@@ -486,11 +486,12 @@
 			sysfatal("player: %r");
 		if((n = ioreadn(io, p[1], buf, Relbufsz)) < 0)
 			fprint(2, "player: %r\n");
-		if(n < 1 || recv(player->ctl, &c) < 0 || c != Cstart)
+		if(recv(player->ctl, &c) < 0 || c != Cstart)
 			goto freeplayer;
+		if(n < 1)
+			goto next;
 		byteswritten = iowrite(io, audio, buf, n);
 		bytesfrom = 0;
-		c = 0;
 		noinit = 1;
 	}
 
@@ -558,6 +559,7 @@
 		close(p[1]);
 		p[1] = -1;
 		if(c != Cbackward && c != Cbackwardfast){
+next:
 			playercurr = nil;
 			playercurr = newplayer((player->pcur+1) % plnum, 1);
 			start(playercurr);