summaryrefslogtreecommitdiff
path: root/firmware/id3.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/id3.c')
-rw-r--r--firmware/id3.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/firmware/id3.c b/firmware/id3.c
index 0cb7118a19..902b0527bb 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -29,6 +29,7 @@
29#include <stdbool.h> 29#include <stdbool.h>
30#include "file.h" 30#include "file.h"
31#include "debug.h" 31#include "debug.h"
32#include "atoi.h"
32 33
33#include "id3.h" 34#include "id3.h"
34 35
@@ -164,9 +165,10 @@ setid3v2title(int fd, struct mp3entry *entry)
164 char *title = NULL; 165 char *title = NULL;
165 char *artist = NULL; 166 char *artist = NULL;
166 char *album = NULL; 167 char *album = NULL;
168 char *tracknum = NULL;
167 char header[10]; 169 char header[10];
168 unsigned short int version; 170 unsigned short int version;
169 int titlen=0, artistn=0, albumn=0; 171 int titlen=0, artistn=0, albumn=0, tracknumn=0;
170 char *buffer = entry->id3v2buf; 172 char *buffer = entry->id3v2buf;
171 173
172 /* 10 = headerlength */ 174 /* 10 = headerlength */
@@ -249,6 +251,17 @@ setid3v2title(int fd, struct mp3entry *entry)
249 albumn = headerlen; 251 albumn = headerlen;
250 readsize += headerlen; 252 readsize += headerlen;
251 } 253 }
254 else if(!strncmp(header, "TRCK", strlen("TRCK"))) {
255 readsize++;
256 headerlen--;
257 if(headerlen > (size - readsize))
258 headerlen = (size - readsize);
259 tracknum = buffer + readsize;
260 tracknumn = headerlen;
261 readsize += headerlen;
262 } else {
263 readsize += headerlen;
264 }
252 } 265 }
253 266
254 if(artist) { 267 if(artist) {
@@ -265,6 +278,11 @@ setid3v2title(int fd, struct mp3entry *entry)
265 entry->album = album; 278 entry->album = album;
266 album[albumn]=0; 279 album[albumn]=0;
267 } 280 }
281
282 if(tracknum) {
283 tracknum[tracknumn] = 0;
284 entry->tracknum = atoi(tracknum);
285 }
268} 286}
269 287
270/* 288/*
@@ -493,6 +511,8 @@ mp3info(struct mp3entry *entry, char *filename)
493 entry->title = NULL; 511 entry->title = NULL;
494 entry->filesize = getfilesize(fd); 512 entry->filesize = getfilesize(fd);
495 entry->id3v2len = getid3v2len(fd); 513 entry->id3v2len = getid3v2len(fd);
514 entry->tracknum = 0;
515
496 if(HASID3V2(entry)) 516 if(HASID3V2(entry))
497 setid3v2title(fd, entry); 517 setid3v2title(fd, entry);
498 entry->length = getsonglength(fd, entry); 518 entry->length = getsonglength(fd, entry);