ref: 0fbecab00e9354a08e8099d1ffd1e10830c25885
parent: d67596f1bbdce63cd6a053cc17443fde1631ed10
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Oct 17 19:58:24 EDT 2022
libtags: opus/vorbis: make sure to get to the last frame to have the full duration
--- a/sys/src/cmd/audio/libtags/opus.c
+++ b/sys/src/cmd/audio/libtags/opus.c
@@ -83,11 +83,12 @@
if(v != nil && v[1] == 'g' && v[2] == 'g' && v[3] == 'S'){
uvlong g = leuint(v+6) | (uvlong)leuint(v+10)<<32;
ctx->duration = g * 1000 / 48000; /* granule positions are always 48KHz */
- return 0;
}
if(v != nil)
v++;
}
+ if(ctx->duration != 0)
+ break;
}
}
--- a/sys/src/cmd/audio/libtags/vorbis.c
+++ b/sys/src/cmd/audio/libtags/vorbis.c
@@ -119,11 +119,12 @@
if(v != nil && v[1] == 'g' && v[2] == 'g' && v[3] == 'S' && (v[5] & 4) == 4){ /* last page */
uvlong g = leuint(v+6) | (uvlong)leuint(v+10)<<32;
ctx->duration = g * 1000 / ctx->samplerate;
- return 0;
}
if(v != nil)
v++;
}
+ if(ctx->duration != 0)
+ break;
}
}