Skip to content

Commit 2dc245f

Browse files
troisiemetypePierre-Loup Martin
and
Pierre-Loup Martin
authored
Fix tags framesize endless loop, add add'l tag support (#336)
* Modified AudioFileSourceFS.h to add resolution operator on items defined into the fs namespace in esp32 libraries. * Added track, set, popularimeter, compilation tags. Changed framesize loop with 32bit counter to avoid endless loops for large frames (like APIC). Co-authored-by: Pierre-Loup Martin <[email protected]>
1 parent 7f3908c commit 2dc245f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/AudioFileSourceID3.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
143143
if (ret<10) return ret;
144144

145145
if ((buff[0]!='I') || (buff[1]!='D') || (buff[2]!='3') || (buff[3]>0x04) || (buff[3]<0x02) || (buff[4]!=0)) {
146+
cb.md("eof", false, "id3");
146147
return 10 + src->read(buff+10, len-10);
147148
}
148149

@@ -212,7 +213,7 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
212213

213214
// Read the value and send to callback
214215
char value[64];
215-
uint16_t i;
216+
uint32_t i;
216217
bool isUnicode = (id3.getByte()==1) ? true : false;
217218
for (i=0; i<framesize-1; i++) {
218219
if (i<sizeof(value)-1) value[i] = id3.getByte();
@@ -231,10 +232,24 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
231232
} else if ( (frameid[0]=='T' && frameid[1]=='Y' && frameid[2]=='E' && frameid[3] == 'R') ||
232233
(frameid[0]=='T' && frameid[1]=='Y' && frameid[2]=='E' && rev==2) ) {
233234
cb.md("Year", isUnicode, value);
235+
} else if ( (frameid[0]=='T' && frameid[1]=='R' && frameid[2]=='C' && frameid[3] == 'K') ||
236+
(frameid[0]=='T' && frameid[1]=='R' && frameid[2]=='K' && rev==2) ) {
237+
cb.md("track", isUnicode, value);
238+
} else if ( (frameid[0]=='T' && frameid[1]=='P' && frameid[2]=='O' && frameid[3] == 'S') ||
239+
(frameid[0]=='T' && frameid[1]=='P' && frameid[2]=='A' && rev==2) ) {
240+
cb.md("Set", isUnicode, value);
241+
} else if ( (frameid[0]=='P' && frameid[1]=='O' && frameid[2]=='P' && frameid[3] == 'M') ||
242+
(frameid[0]=='P' && frameid[1]=='O' && frameid[2]=='P' && rev==2) ) {
243+
cb.md("Popularimeter", isUnicode, value);
244+
} else if ( (frameid[0]=='T' && frameid[1]=='C' && frameid[2]=='M' && frameid[3] == 'P') ) {
245+
cb.md("Compilation", isUnicode, value);
234246
}
235247
}
236248
} while (!id3.eof());
237249

250+
// use callback function to signal end of tags and beginning of content.
251+
cb.md("eof", false, "id3");
252+
238253
// All ID3 processing done, return to main caller
239254
return src->read(data, len);
240255
}

0 commit comments

Comments
 (0)