1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Daniel Stenberg 2002-06-04 22:05:00 +00:00
parent fb153c5570
commit c9ea73e19d
2 changed files with 13 additions and 10 deletions

View file

@ -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);

View file

@ -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;