summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-02-20 09:29:58 +1100
committerjacqueline <me@jacqueline.id.au>2024-02-20 09:29:58 +1100
commit403bd4672c1aa0bd5f0ac8e6da700bfb1aec9768 (patch)
treed4efc9eb817b0831f693e5c95db05366bff04ced
parent5866513c532114654c1a0e616be3c64ef0aa92ed (diff)
downloadtangara-fw-403bd4672c1aa0bd5f0ac8e6da700bfb1aec9768.tar.gz
Update to latest libtags
Mostly for wav fixes
-rw-r--r--lib/libtags/examples/readtags.c6
-rw-r--r--lib/libtags/id3v1.c3
-rw-r--r--lib/libtags/id3v2.c4
-rw-r--r--lib/libtags/m4a.c6
-rw-r--r--lib/libtags/opus.c2
-rw-r--r--lib/libtags/tags.c4
-rw-r--r--lib/libtags/tags.h2
-rw-r--r--lib/libtags/vorbis.c51
-rw-r--r--lib/libtags/wav.c22
9 files changed, 62 insertions, 38 deletions
diff --git a/lib/libtags/examples/readtags.c b/lib/libtags/examples/readtags.c
index fb5b5d21..81c5a80e 100644
--- a/lib/libtags/examples/readtags.c
+++ b/lib/libtags/examples/readtags.c
@@ -35,6 +35,8 @@ static const char *t2s[] =
[Ttrackpeak] = "trackpeak",
[Tgenre] = "genre",
[Timage] = "image",
+ [Tcomposer] = "composer",
+ [Tcomment] = "comment",
};
static void
@@ -43,7 +45,9 @@ tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagr
USED(ctx); USED(k); USED(f);
if(t == Timage)
print("%-12s %s %d %d\n", t2s[t], v, offset, size);
- else if(t != Tunknown)
+ else if(t == Tunknown)
+ print("%-12s %s\n", k, v);
+ else
print("%-12s %s\n", t2s[t], v);
}
diff --git a/lib/libtags/id3v1.c b/lib/libtags/id3v1.c
index afcf90e9..d375cfd7 100644
--- a/lib/libtags/id3v1.c
+++ b/lib/libtags/id3v1.c
@@ -36,6 +36,9 @@ tagid3v1(Tagctx *ctx)
if((ctx->found & 1<<Tdate) == 0 && in[93] != 0)
txtcb(ctx, Tdate, "", &in[93]);
+ if((ctx->found & 1<<Tcomment) == 0 && in[97] != 0)
+ txtcb(ctx, Tcomment, "", &in[97]);
+
if((ctx->found & 1<<Ttrack) == 0 && in[125] == 0 && in[126] > 0){
snprint((char*)out, Outsz, "%d", in[126]);
txtcb(ctx, Ttrack, "", out);
diff --git a/lib/libtags/id3v2.c b/lib/libtags/id3v2.c
index e1529d4a..78a0a5fe 100644
--- a/lib/libtags/id3v2.c
+++ b/lib/libtags/id3v2.c
@@ -31,6 +31,8 @@ v2cb(Tagctx *ctx, char *k, char *v)
txtcb(ctx, Ttrack, k-1, v);
else if(strcmp(k, "LEN") == 0)
ctx->duration = atoi(v);
+ else if(strcmp(k, "CM") == 0 || strcmp(k, "COM") == 0)
+ txtcb(ctx, Tcomposer, k-1, v);
else if(strcmp(k, "CO") == 0 || strcmp(k, "CON") == 0){
for(; v[0]; v++){
if(v[0] == '(' && v[1] <= '9' && v[1] >= '0'){
@@ -64,6 +66,8 @@ v2cb(Tagctx *ctx, char *k, char *v)
txtcb(ctx, type, k-1, v+5);
else
return 0;
+ }else if(strcmp(k-1, "COM") == 0 || strcmp(k-1, "COMM") == 0){
+ txtcb(ctx, Tcomment, k-1, v);
}else{
txtcb(ctx, Tunknown, k-1, v);
}
diff --git a/lib/libtags/m4a.c b/lib/libtags/m4a.c
index 924ba51a..ec254c3f 100644
--- a/lib/libtags/m4a.c
+++ b/lib/libtags/m4a.c
@@ -93,6 +93,10 @@ tagm4a(Tagctx *ctx)
type = Timage;
else if(memcmp(d, "trkn", 4) == 0)
type = Ttrack;
+ else if(memcmp(d, "\251wrt", 4) == 0)
+ type = Tcomposer;
+ else if(memcmp(d, "\251cmt", 4) == 0)
+ type = Tcomment;
else if(memcmp(d, "mdhd", 4) == 0){
if(ctx->read(ctx, d, 4) != 4)
return -1;
@@ -133,7 +137,7 @@ tagm4a(Tagctx *ctx)
sz -= 4;
snprint((char*)d, ctx->bufsz, "%d", beuint(d));
txtcb(ctx, type, "", d);
- }else if(type == Tgenre){
+ }else if(type == Tgenre && dtype != 1){
if(ctx->read(ctx, d, 2) != 2)
return -1;
sz -= 2;
diff --git a/lib/libtags/opus.c b/lib/libtags/opus.c
index fcea57d8..fa2c7d40 100644
--- a/lib/libtags/opus.c
+++ b/lib/libtags/opus.c
@@ -63,7 +63,7 @@ tagopus(Tagctx *ctx)
ctx->buf[sz] = 0;
if((v = strchr(ctx->buf, '=')) == nil)
- continue;
+ return -1;
*v++ = 0;
cbvorbiscomment(ctx, ctx->buf, v);
}
diff --git a/lib/libtags/tags.c b/lib/libtags/tags.c
index a027a9ab..750d9077 100644
--- a/lib/libtags/tags.c
+++ b/lib/libtags/tags.c
@@ -46,8 +46,8 @@ tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size,
e = s + strlen(s);
while(e != s && (uchar)e[-1] <= ' ')
e--;
- if (*e != 0)
- *e = 0;
+ if(*e != 0)
+ *e = 0;
}
if(*s){
ctx->tag(ctx, type, k, s, offset, size, f);
diff --git a/lib/libtags/tags.h b/lib/libtags/tags.h
index 91045218..4b10349a 100644
--- a/lib/libtags/tags.h
+++ b/lib/libtags/tags.h
@@ -21,6 +21,8 @@ enum
Ttrackpeak,
Tgenre,
Timage,
+ Tcomposer,
+ Tcomment,
};
/* Format of the audio file. */
diff --git a/lib/libtags/vorbis.c b/lib/libtags/vorbis.c
index c98a0e4e..e57f8989 100644
--- a/lib/libtags/vorbis.c
+++ b/lib/libtags/vorbis.c
@@ -4,33 +4,38 @@
*/
#include "tagspriv.h"
+static const struct {
+ char *s;
+ int type;
+}t[] = {
+ {"album", Talbum},
+ {"title", Ttitle},
+ {"artist", Tartist},
+ {"albumartist", Talbumartist},
+ {"tracknumber", Ttrack},
+ {"date", Tdate},
+ {"replaygain_track_peak", Ttrackpeak},
+ {"replaygain_track_gain", Ttrackgain},
+ {"replaygain_album_peak", Talbumpeak},
+ {"replaygain_album_gain", Talbumgain},
+ {"genre", Tgenre},
+ {"composer", Tcomposer},
+ {"comment", Tcomment},
+};
+
void
cbvorbiscomment(Tagctx *ctx, char *k, char *v){
+ int i;
+
if(*v == 0)
return;
- if(cistrcmp(k, "album") == 0)
- txtcb(ctx, Talbum, k, v);
- else if(cistrcmp(k, "title") == 0)
- txtcb(ctx, Ttitle, k, v);
- else if(cistrcmp(k, "artist") == 0)
- txtcb(ctx, Tartist, k, v);
- else if(cistrcmp(k, "albumartist") == 0)
- txtcb(ctx, Talbumartist, k, v);
- else if(cistrcmp(k, "tracknumber") == 0)
- txtcb(ctx, Ttrack, k, v);
- else if(cistrcmp(k, "date") == 0)
- txtcb(ctx, Tdate, k, v);
- else if(cistrcmp(k, "replaygain_track_peak") == 0)
- txtcb(ctx, Ttrackpeak, k, v);
- else if(cistrcmp(k, "replaygain_track_gain") == 0)
- txtcb(ctx, Ttrackgain, k, v);
- else if(cistrcmp(k, "replaygain_album_peak") == 0)
- txtcb(ctx, Talbumpeak, k, v);
- else if(cistrcmp(k, "replaygain_album_gain") == 0)
- txtcb(ctx, Talbumgain, k, v);
- else if(cistrcmp(k, "genre") == 0)
- txtcb(ctx, Tgenre, k, v);
- else
+ for(i = 0; i < nelem(t); i++){
+ if(cistrcmp(k, t[i].s) == 0){
+ txtcb(ctx, t[i].type, k, v);
+ break;
+ }
+ }
+ if(i == nelem(t))
txtcb(ctx, Tunknown, k, v);
}
diff --git a/lib/libtags/wav.c b/lib/libtags/wav.c
index 55e1566b..69b1946a 100644
--- a/lib/libtags/wav.c
+++ b/lib/libtags/wav.c
@@ -2,7 +2,7 @@
#define le16u(d) (u16int)((d)[0] | (d)[1]<<8)
-static struct {
+static const struct {
char *s;
int type;
}t[] = {
@@ -12,6 +12,8 @@ static struct {
{"INAM", Ttitle},
{"IPRD", Talbum},
{"ITRK", Ttrack},
+ {"ICMT", Tcomment},
+ {"????", Tunknown},
};
int
@@ -26,7 +28,7 @@ tagwav(Tagctx *ctx)
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,20 +68,20 @@ tagwav(Tagctx *ctx)
}else if(memcmp(d, "LIST", 4) == 0){
sz = csz - 4;
continue;
- }else if(memcmp(d, "data", 4) == 0){
- break;
- }else if(info){
- csz++;
+ }else if(info && csz < (u32int)ctx->bufsz){
for(n = 0; n < nelem(t); n++){
- if(memcmp(d, t[n].s, 4) == 0){
- if(ctx->read(ctx, d, csz) != (int)csz)
+ if(memcmp(d, t[n].s, 4) == 0 || t[n].type == Tunknown){
+ if(ctx->read(ctx, d+5, csz) != (int)csz)
return -1;
- d[csz-1] = 0;
- txtcb(ctx, t[n].type, "", d);
+ d[4] = 0;
+ d[5+csz] = 0;
+ txtcb(ctx, t[n].type, t[n].type == Tunknown ? (char*)d : "", d+5);
csz = 0;
break;
}
}
+ if(n < nelem(t))
+ continue;
}
if(ctx->seek(ctx, csz, 1) < 0)