From c9ea73e19df55473de9671d8fd3a4fbb7145e986 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 4 Jun 2002 22:05:00 +0000 Subject: NOTE! the 'mp3entry' struct grew quite a bit now, as the previously static buffers were moved into the struct instead and thus we enable the mp3info() function to be called in a re-entrant way. Just don't allocate that struct on the stack without careful consideration! git-svn-id: svn://svn.rockbox.org/rockbox/trunk@896 a1c6a512-1295-4272-9138-f99709370657 --- firmware/id3.c | 19 +++++++++---------- firmware/id3.h | 4 ++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/firmware/id3.c b/firmware/id3.c index 8133f7c4f6..2c1f85e0ae 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -115,7 +115,6 @@ setid3v1title(int fd, mp3entry *entry) char buffer[31]; int offsets[3] = {-95,-65,-125}; int i; - static char keepit[3][32]; for(i=0;i<3;i++) { if(-1 == lseek(fd, offsets[i], SEEK_END)) @@ -128,16 +127,16 @@ setid3v1title(int fd, mp3entry *entry) if(buffer[0]) { switch(i) { case 0: - strcpy(keepit[0], buffer); - entry->artist = keepit[0]; + strcpy(entry->id3v1buf[0], buffer); + entry->artist = entry->id3v1buf[0]; break; case 1: - strcpy(keepit[1], buffer); - entry->album = keepit[1]; + strcpy(entry->id3v1buf[1], buffer); + entry->album = entry->id3v1buf[1]; break; case 2: - strcpy(keepit[2], buffer); - entry->title = keepit[2]; + strcpy(entry->id3v1buf[2], buffer); + entry->title = entry->id3v1buf[2]; break; } } @@ -166,8 +165,8 @@ setid3v2title(int fd, mp3entry *entry) char *album = NULL; char header[10]; unsigned short int version; - static char buffer[512]; int titlen=0, artistn=0, albumn=0; + char *buffer = entry->id3v2buf; /* 10 = headerlength */ if(entry->id3v2len < 10) @@ -183,8 +182,8 @@ setid3v2title(int fd, mp3entry *entry) /* Read all frames in the tag */ size = entry->id3v2len - 10; - if(size >= (int)sizeof(buffer)) - size = sizeof(buffer)-1; + if(size >= (int)sizeof(entry->id3v2buf)) + size = sizeof(entry->id3v2buf)-1; if(size != read(fd, buffer, size)) { free(buffer); diff --git a/firmware/id3.h b/firmware/id3.h index 3f7be7bd3f..9c8d54aab8 100644 --- a/firmware/id3.h +++ b/firmware/id3.h @@ -29,6 +29,10 @@ struct mp3entry { int id3v1len; int filesize; /* in bytes */ int length; /* song length */ + + /* these following two fields are used for local buffering */ + char id3v2buf[300]; + char id3v1buf[3][32]; }; typedef struct mp3entry mp3entry; -- cgit v1.2.3