Commit Diff


commit - 0e430247b01565ccc002c8cc3d7038b2dabbc603
commit + 60a09ce7593620b472371bfbca3c11b6ba8d2c81
blob - 0327648d1507905618118f4ceda5bef4638be8a0
blob + e5ebfc5613ebe9e2c638498e3f532ec909c18d2a
--- amused.h
+++ amused.h
@@ -88,6 +88,7 @@ enum actions {
 struct player_seek {
 	int64_t	offset;
 	int	relative;
+	int	percent;
 };
 
 struct ctl_command;
blob - 3b2db90ddb542dc8730e9b3272d9cef356c7bb42
blob + b68cdd2b05de1c6ae29b9ea0577dc6ccdb608859
--- player.c
+++ player.c
@@ -42,6 +42,7 @@ static struct imsgbuf	*ibuf;
 static int stopped = 1;
 static int nextfd = -1;
 static int64_t samples;
+static int64_t duration;
 
 volatile sig_atomic_t halted;
 
@@ -112,10 +113,11 @@ start:
 }
 
 void
-player_setduration(int64_t duration)
+player_setduration(int64_t d)
 {
 	int64_t seconds;
 
+	duration = d;
 	seconds = duration / par.rate;
 	imsg_compose(ibuf, IMSG_LEN, 0, 0, -1, &seconds, sizeof(seconds));
 	imsg_flush(ibuf);
@@ -195,9 +197,13 @@ again:
 		if (IMSG_DATA_SIZE(imsg) != sizeof(seek))
 			fatalx("wrong size for seek ctl");
 		memcpy(&seek, imsg.data, sizeof(seek));
-		*s = seek.offset * par.rate;
-		if (seek.relative)
-			*s += samples;
+		if (seek.percent) {
+			*s = (double)seek.offset * (double)duration / 100.0;
+		} else {
+			*s = seek.offset * par.rate;
+			if (seek.relative)
+				*s += samples;
+		}
 		if (*s < 0)
 			*s = 0;
 		break;