summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-06-30 18:39:13 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-06-30 18:39:13 +0000
commit1a1ac92f453410b6f81ce6092b18162c1903af35 (patch)
tree5cfac987c700f4f2d4d4159cec4ae2d3536e8dd0 /apps
parent617d1e9f6b7969aff5e45746b9c5e3cee9ce2c45 (diff)
downloadrockbox-1a1ac92f453410b6f81ce6092b18162c1903af35.tar.gz
rockbox-1a1ac92f453410b6f81ce6092b18162c1903af35.zip
Use id3v2buf to read the title of MOD files. Avoids additional declaration of a 1KB buffer and saves a bit codesize as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30105 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/metadata/mod.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/apps/metadata/mod.c b/apps/metadata/mod.c
index cbc9fc11f6..de76823e91 100644
--- a/apps/metadata/mod.c
+++ b/apps/metadata/mod.c
@@ -35,17 +35,20 @@
bool get_mod_metadata(int fd, struct mp3entry* id3)
{
/* Use the trackname part of the id3 structure as a temporary buffer */
- unsigned char buf[MODULEHEADERSIZE];
+ unsigned char *buf = id3->id3v2buf;
unsigned char id[4];
bool is_mod_file = false;
- char *p;
- if ((lseek(fd, 0, SEEK_SET) < 0)
- || (read(fd, buf, sizeof(buf)) < MODULEHEADERSIZE))
- {
+ /* Seek to file begin */
+ if (lseek(fd, 0, SEEK_SET) < 0)
return false;
- }
-
+ /* Use id3v2buf as buffer for the track name */
+ if (read(fd, buf, sizeof(id3->id3v2buf)) < (ssize_t)sizeof(id3->id3v2buf))
+ return false;
+ /* Seek to MOD ID position */
+ if (lseek(fd, MODULEHEADERSIZE, SEEK_SET) < 0)
+ return false;
+ /* Read MOD ID */
if (read(fd, id, sizeof(id)) < (ssize_t)sizeof(id))
return false;
@@ -88,14 +91,7 @@ bool get_mod_metadata(int fd, struct mp3entry* id3)
if (!is_mod_file)
return false;
- p = id3->id3v2buf;
-
- /* Copy Title */
- if (strlcpy(p, buf, sizeof(id3->id3v2buf)) >= sizeof(id3->id3v2buf))
- return false;
-
- id3->title = p;
-
+ id3->title = id3->id3v2buf; /* Point title to previous read ID3 buffer. */
id3->bitrate = filesize(fd)/1024; /* size in kb */
id3->frequency = 44100;
id3->length = 120*1000;