ref: cb6134fd87a05a2cc2b8502d0a883bb93487555a
parent: 277e60764d872ef9fdd0fbe7c18bcf0a9d20499b
author: Sigrid Haflínudóttir <[email protected]>
date: Sat Dec 28 19:21:15 EST 2019
fix seeking backwards while seek is already in progress
--- a/zuke.c
+++ b/zuke.c
@@ -381,7 +381,7 @@
Image *thiscover;
ulong c;
int p[2], fd, pid, n, got, noinit, trycoverload;
- u64int bytesfrom;
+ u64int bytesfrom, bf;
threadsetname("player");
player = player_;
@@ -457,6 +457,7 @@
player->img = nil;
}
c = nbrecvul(player->ctl);
+ bf = bytesfrom != 0 ? bytesfrom : byteswritten;
if(c == Cstop || c == -1)
goto stop;
if(c == Ctoggle){
@@ -464,15 +465,15 @@
if(c == Cstop)
goto stop;
}else if(c == Cforward){
- bytesfrom = byteswritten + Seekbytes;
+ bytesfrom = bf + Seekbytes;
}else if(c == Cforwardfast){
- bytesfrom = byteswritten + Seekbytesfast;
+ bytesfrom = bf + Seekbytesfast;
}else if(c == Cbackward){ /* to seek backwards we need to restart playback */
- bytesfrom = byteswritten >= Seekbytes ? byteswritten - Seekbytes : 0;
+ bytesfrom = bf >= Seekbytes ? bf - Seekbytes : 0;
n = 0; /* not an error */
break;
}else if(c == Cbackwardfast){
- bytesfrom = byteswritten >= Seekbytesfast ? byteswritten - Seekbytesfast : 0;
+ bytesfrom = bf >= Seekbytesfast ? bf - Seekbytesfast : 0;
n = 0; /* not an error */
break;
}