shithub: riscv

Download patch

ref: 5211d29ed470d2bfda78b03970be6dc6a6614447
parent: cc692fa3e8f8061aa57395db2e8a4b37838e9aa2
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Oct 16 15:46:05 EDT 2022

zuke: fix repeat and replay gain modes not showing when playing network streams

--- a/sys/src/cmd/audio/zuke/zuke.c
+++ b/sys/src/cmd/audio/zuke/zuke.c
@@ -288,29 +288,25 @@
 		shuffle != nil ? "∫" : "",
 		(rg || repeatone || shuffle != nil) ? " " : ""
 	);
-	msec = 0;
+	msec = dur = w = 0;
 	if(pcurplaying >= 0){
 		msec = byteswritten*1000/Bps;
 		if((dur = getmeta(pcurplaying)->duration) > 0){
-			snprint(tmp+i, sizeof(tmp)-i, "%P/%P %d%%", dur/1000, dur/1000, 100);
+			snprint(tmp+i, sizeof(tmp)-i, "%P/%P ", dur/1000, dur/1000);
 			w = stringwidth(f, tmp);
 			msec = MIN(msec, dur);
-			snprint(tmp+i, sizeof(tmp)-i, "%P/%P %d%%",
+			i += snprint(tmp+i, sizeof(tmp)-i, "%P/%P ",
 				(uvlong)(newseekmx >= 0 ? seekoff : msec)/1000,
-				dur/1000,
-				volume
+				dur/1000
 			);
 		}else{
-			snprint(tmp+i, sizeof(tmp)-i, "%P %d%%", msec/1000, 100);
+			i += snprint(tmp+i, sizeof(tmp)-i, "%P ", msec/1000);
 			w = stringwidth(f, tmp);
-			snprint(tmp, sizeof(tmp), "%P %d%%", msec/1000, volume);
 		}
-	}else{
-		dur = 0;
-		snprint(tmp+i, sizeof(tmp)-i, "%d%%", 100);
-		w = stringwidth(f, tmp);
-		snprint(tmp+i, sizeof(tmp)-i, "%d%%", volume);
 	}
+	snprint(tmp+i, sizeof(tmp)-i, "%d%%", 100);
+	w += stringwidth(f, tmp+i);
+	snprint(tmp+i, sizeof(tmp)-i, "%d%%", volume);
 
 	lockdisplay(display);