shithub: zuke

Download patch

ref: 1a53cab8dd1435c1b8db09c2497352c269928431
parent: 5417b9dffa9171ff3e6dd584b98be64d03b98ac6
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Nov 10 10:55:35 EST 2020

change duration to uvlong; do not seek on streams

--- a/mkplist.c
+++ b/mkplist.c
@@ -242,7 +242,7 @@
 	if(m->track != nil)
 		s = seprint(s, buf+sizeof(buf), "%c%ld %s\n", Ptrack, strlen(m->track), m->track);
 	if(m->duration > 0)
-		s = seprint(s, buf+sizeof(buf), "%c %d\n", Pduration, m->duration);
+		s = seprint(s, buf+sizeof(buf), "%c %zd\n", Pduration, m->duration);
 	if(m->imagesize > 0)
 		s = seprint(s, buf+sizeof(buf), "%c %d %d %d %s\n", Pimage, m->imageoffset, m->imagesize, m->imagereader, m->imagefmt);
 	s = seprint(s, buf+sizeof(buf), "%c %s\n%c %s\n", Pfilefmt, m->filefmt, Ppath, m->path);
--- a/plist.h
+++ b/plist.h
@@ -40,8 +40,8 @@
 	char *path;
 	char *imagefmt;
 	char *filefmt;
+	uvlong duration;
 	int numartist;
-	int duration;
 	int imageoffset;
 	int imagesize;
 	int imagereader; /* non-zero if a special reader required */
--- a/zuke.c
+++ b/zuke.c
@@ -78,7 +78,7 @@
 	.item = menu3i,
 };
 
-#pragma varargck type "P" int
+#pragma varargck type "P" uvlong
 static int
 positionfmt(Fmt *f)
 {
@@ -111,9 +111,8 @@
 	case Ptrack: snprint(tmp, sizeof(tmp), "%4s", m->track); return m->track ? tmp : nil;
 	case Ppath: return m->path;
 	case Pduration:
-		if(m->duration < 1)
-			tmp[0] = 0;
-		else
+		tmp[0] = 0;
+		if(m->duration > 0)
 			snprint(tmp, sizeof(tmp), "%8P", m->duration/1000);
 		return tmp;
 	default: sysfatal("invalid column '%c'", c);
@@ -176,6 +175,7 @@
 	Point p, sp;
 	Rectangle sel, r;
 	int i, j, left, right, scrollcenter, w;
+	uvlong dur, msec;
 	char tmp[32];
 
 	lockdisplay(display);
@@ -263,32 +263,29 @@
 		}
 	}
 
-	vlong msec = 0;
+	msec = 0;
+	dur = getmeta(pcurplaying)->duration;
 	if(pcurplaying >= 0){
 		msec = byteswritten*1000/Bps;
-		if(getmeta(pcurplaying)->duration != 0){
+		if(dur > 0){
 			snprint(tmp, sizeof(tmp), "%s%P/%P 100%%",
 				shuffle != nil ? "∫ " : "",
-				getmeta(pcurplaying)->duration/1000,
-				getmeta(pcurplaying)->duration/1000);
+				dur/1000, dur/1000);
 			w = stringwidth(f, tmp);
-			msec = MIN(msec, getmeta(pcurplaying)->duration);
+			msec = MIN(msec, dur);
 			snprint(tmp, sizeof(tmp), "%s%P/%P %d%%",
 				shuffle != nil ? "∫ " : "",
-				(int)(newseekmx >= 0 ? seekoff : msec)/1000,
-				getmeta(pcurplaying)->duration/1000,
-				volume);
+				(uvlong)(newseekmx >= 0 ? seekoff : msec)/1000,
+				dur/1000, volume);
 			seekmx = newseekmx;
 		}else{
 			snprint(tmp, sizeof(tmp), "%s%P %d%%",
 				shuffle != nil ? "∫ " : "",
-				(int)msec/1000,
-				100);
+				msec/1000, 100);
 			w = stringwidth(f, tmp);
 			snprint(tmp, sizeof(tmp), "%s%P %d%%",
 				shuffle != nil ? "∫ " : "",
-				(int)msec/1000,
-				volume);
+				msec/1000, volume);
 		}
 	}else{
 		snprint(tmp, sizeof(tmp), "%s%d%%", shuffle != nil ? "∫ " : "", 100);
@@ -299,7 +296,7 @@
 	right = r.max.x - w - 4;
 	r.min.x = left;
 	r.min.y = r.max.y - f->height - 4;
-	if(pcurplaying < 0 || getmeta(pcurplaying)->duration == 0)
+	if(pcurplaying < 0 || dur == 0)
 		r.min.x = right;
 	draw(screen, r, colors[Dblow].im, nil, ZP);
 	p = addpt(Pt(r.max.x-stringwidth(f, tmp)-4, r.min.y), Pt(2, 2));
@@ -322,11 +319,11 @@
 
 	/* seek bar */
 	seekbar = ZR;
-	if(pcurplaying >= 0 && getmeta(pcurplaying)->duration != 0){
+	if(pcurplaying >= 0 && dur > 0){
 		r = insetrect(sel, 3);
 		draw(screen, r, colors[Dback].im, nil, ZP);
 		seekbar = r;
-		r.max.x = r.min.x + Dx(r) * (double)msec / (double)getmeta(pcurplaying)->duration;
+		r.max.x = r.min.x + Dx(r) * (double)msec / (double)dur;
 		draw(screen, r, colors[Dbmed].im, nil, ZP);
 	}
 
@@ -643,7 +640,7 @@
 static void
 seekrel(Player *player, double off)
 {
-	if(player != nil){
+	if(player != nil && getmeta(pcurplaying)->duration > 0){
 		player->seek = off;
 		sendul(player->ctl, Cseekrel);
 	}