code: plan9front

Download patch

ref: d589632207181a7960607a5938f315422386b9cb
parent: 674a47f7bfced5a91c621d139b0551826fae299a
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Feb 19 12:52:30 EST 2024

libtags/wav: don't stop on data (tags may follow after); don't stop after 8 sections either

--- a/sys/src/cmd/audio/libtags/wav.c
+++ b/sys/src/cmd/audio/libtags/wav.c
@@ -26,7 +26,7 @@
 
 	sz = 1;
 	info = 0;
-	for(i = 0; i < 8 && sz > 0; i++){
+	for(i = 0; sz > 0; i++){
 		if(ctx->read(ctx, d, 4+4+(i?0:4)) != 4+4+(i?0:4))
 			return -1;
 		if(i == 0){
@@ -66,13 +66,10 @@
 		}else if(memcmp(d, "LIST", 4) == 0){
 			sz = csz - 4;
 			continue;
-		}else if(memcmp(d, "data", 4) == 0){
-			break;
 		}else if(info){
-			csz++;
 			for(n = 0; n < nelem(t); n++){
 				if(memcmp(d, t[n].s, 4) == 0){
-					if(ctx->read(ctx, d, csz) != csz)
+					if(ctx->read(ctx, d, csz) != (int)csz)
 						return -1;
 					d[csz-1] = 0;
 					txtcb(ctx, t[n].type, "", d);
@@ -80,6 +77,8 @@
 					break;
 				}
 			}
+			if(n < nelem(t))
+				continue;
 		}
 
 		if(ctx->seek(ctx, csz, 1) < 0)