shithub: zuke

Download patch

ref: dd231a1c06f2da190f5d29f3f2aa01323600d1af
parent: 6ddf9ac048b1440a328eb6273113ff177bdbf7ee
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Mar 4 09:30:59 EST 2021

do not use -s with decoders unless actually seeking; allow seeking with known formats but no duration

--- a/zuke.c
+++ b/zuke.c
@@ -595,7 +595,7 @@
 		if(*fmt){
 			snprint(cmd, sizeof(cmd), "/bin/audio/%sdec", fmt);
 			snprint(seekpos, sizeof(seekpos), "%g", (double)boffset/Bps);
-			execl(cmd, cmd, "-s", seekpos, nil);
+			execl(cmd, cmd, boffset ? "-s" : nil, seekpos, nil);
 		}else{
 			execl("/bin/play", "play", "-o", "/fd/1", cur->path, nil);
 		}
@@ -684,7 +684,7 @@
 	if(n < 1){ /* seeking backwards or end of the song */
 		close(p[1]);
 		p[1] = -1;
-		if(c != Cseekrel || boffset >= getmeta(pcurplaying)->duration/1000*Bps){
+		if(c != Cseekrel || (getmeta(pcurplaying)->duration && boffset >= getmeta(pcurplaying)->duration/1000*Bps)){
 next:
 			playercurr = nil;
 			playercurr = newplayer((player->pcur+1) % pl->n, 1);
@@ -724,7 +724,7 @@
 static void
 seekrel(Player *player, double off)
 {
-	if(player != nil && getmeta(pcurplaying)->duration > 0){
+	if(player != nil && *getmeta(pcurplaying)->filefmt){
 		player->seek = off;
 		sendul(player->ctl, Cseekrel);
 	}