From c6e69cd886eac13fcc6c14df727757ad2ba464d5 Mon Sep 17 00:00:00 2001 From: Steve Bavin Date: Wed, 24 Feb 2010 17:20:39 +0000 Subject: Put the SMAF metadata buffer on the stack to save some memory. Only tested with one SMAF file, so please check if you have more. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24886 a1c6a512-1295-4272-9138-f99709370657 --- apps/metadata/smaf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/metadata/smaf.c b/apps/metadata/smaf.c index f7d825c96a..586802b7b5 100644 --- a/apps/metadata/smaf.c +++ b/apps/metadata/smaf.c @@ -48,8 +48,6 @@ static int support_codepages[7] = { #define TAG_ARTIST (('A'<<8)|'N') #define TAG_COMPOSER (('S'<<8)|'W') -static unsigned char smafbuf[1024]; - static bool read_datachunk(unsigned char *src, int size, unsigned short tag, int codepage, unsigned char *dst) { @@ -235,9 +233,11 @@ static bool get_smaf_metadata_score_track(struct mp3entry *id3, bool get_smaf_metadata(int fd, struct mp3entry* id3) { + unsigned char smafbuf[1024]; + /* Use the trackname part of the id3 structure as a temporary buffer */ unsigned char* buf = (unsigned char *)id3->path; - unsigned char *endbuf = smafbuf + 1024; + unsigned char *endbuf = smafbuf + sizeof(smafbuf); int i; int contents_size; int codepage = ISO_8859_1; @@ -347,8 +347,8 @@ bool get_smaf_metadata(int fd, struct mp3entry* id3) if (contents_size > i) lseek(fd, contents_size - i, SEEK_CUR); - /* assume the SMAF pcm data position is less than 1024 bytes */ - if (read(fd, smafbuf, 1024) < 1024) + /* assume the SMAF pcm data position is near the start */ + if (read(fd, smafbuf, sizeof(smafbuf)) < (ssize_t)sizeof(smafbuf)) return false; buf = smafbuf; -- cgit v1.2.3