diff options
Diffstat (limited to 'firmware/id3.c')
-rw-r--r-- | firmware/id3.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/firmware/id3.c b/firmware/id3.c index c0e6c564d0..4b72e4ca4d 100644 --- a/firmware/id3.c +++ b/firmware/id3.c | |||
@@ -156,7 +156,7 @@ static int unicode_munge(char** string, int *len) { | |||
156 | static bool setid3v1title(int fd, struct mp3entry *entry) | 156 | static bool setid3v1title(int fd, struct mp3entry *entry) |
157 | { | 157 | { |
158 | unsigned char buffer[128]; | 158 | unsigned char buffer[128]; |
159 | static int offsets[] = {3, 33, 63, 93, 125}; | 159 | static char offsets[] = {3, 33, 63, 93, 125, 127}; |
160 | int i, j; | 160 | int i, j; |
161 | 161 | ||
162 | if (-1 == lseek(fd, -128, SEEK_END)) | 162 | if (-1 == lseek(fd, -128, SEEK_END)) |
@@ -168,7 +168,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry) | |||
168 | if (strncmp(buffer, "TAG", 3)) | 168 | if (strncmp(buffer, "TAG", 3)) |
169 | return false; | 169 | return false; |
170 | 170 | ||
171 | for (i=0;i<5;i++) { | 171 | for (i=0; i < (int)sizeof offsets; i++) { |
172 | char* ptr = buffer + offsets[i]; | 172 | char* ptr = buffer + offsets[i]; |
173 | 173 | ||
174 | if (i<3) { | 174 | if (i<3) { |
@@ -204,6 +204,11 @@ static bool setid3v1title(int fd, struct mp3entry *entry) | |||
204 | if (*ptr == 0) | 204 | if (*ptr == 0) |
205 | entry->tracknum = ptr[1]; | 205 | entry->tracknum = ptr[1]; |
206 | break; | 206 | break; |
207 | |||
208 | case 5: | ||
209 | /* genre */ | ||
210 | entry->genre = ptr[0]; | ||
211 | break; | ||
207 | } | 212 | } |
208 | } | 213 | } |
209 | 214 | ||
@@ -339,6 +344,16 @@ static void setid3v2title(int fd, struct mp3entry *entry) | |||
339 | bufferpos += bytesread + 1; | 344 | bufferpos += bytesread + 1; |
340 | size -= bytesread; | 345 | size -= bytesread; |
341 | } | 346 | } |
347 | else if(!strncmp(header, "TCON", 4)) { | ||
348 | char* ptr = buffer + bufferpos; | ||
349 | bytesread = read(fd, ptr, framelen); | ||
350 | if (ptr[1] == '(' && ptr[2] != '(') | ||
351 | entry->genre = atoi(ptr+2); | ||
352 | else | ||
353 | entry->genre = 0xff; | ||
354 | bufferpos += bytesread + 1; | ||
355 | size -= bytesread; | ||
356 | } | ||
342 | else { | 357 | else { |
343 | /* Unknown frame, skip it using the total size in case | 358 | /* Unknown frame, skip it using the total size in case |
344 | it was truncated */ | 359 | it was truncated */ |