diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-06-30 18:39:13 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-06-30 18:39:13 +0000 |
commit | 1a1ac92f453410b6f81ce6092b18162c1903af35 (patch) | |
tree | 5cfac987c700f4f2d4d4159cec4ae2d3536e8dd0 | |
parent | 617d1e9f6b7969aff5e45746b9c5e3cee9ce2c45 (diff) | |
download | rockbox-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
-rw-r--r-- | apps/metadata/mod.c | 26 |
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 @@ | |||
35 | bool get_mod_metadata(int fd, struct mp3entry* id3) | 35 | bool get_mod_metadata(int fd, struct mp3entry* id3) |
36 | { | 36 | { |
37 | /* Use the trackname part of the id3 structure as a temporary buffer */ | 37 | /* Use the trackname part of the id3 structure as a temporary buffer */ |
38 | unsigned char buf[MODULEHEADERSIZE]; | 38 | unsigned char *buf = id3->id3v2buf; |
39 | unsigned char id[4]; | 39 | unsigned char id[4]; |
40 | bool is_mod_file = false; | 40 | bool is_mod_file = false; |
41 | char *p; | ||
42 | 41 | ||
43 | if ((lseek(fd, 0, SEEK_SET) < 0) | 42 | /* Seek to file begin */ |
44 | || (read(fd, buf, sizeof(buf)) < MODULEHEADERSIZE)) | 43 | if (lseek(fd, 0, SEEK_SET) < 0) |
45 | { | ||
46 | return false; | 44 | return false; |
47 | } | 45 | /* Use id3v2buf as buffer for the track name */ |
48 | 46 | if (read(fd, buf, sizeof(id3->id3v2buf)) < (ssize_t)sizeof(id3->id3v2buf)) | |
47 | return false; | ||
48 | /* Seek to MOD ID position */ | ||
49 | if (lseek(fd, MODULEHEADERSIZE, SEEK_SET) < 0) | ||
50 | return false; | ||
51 | /* Read MOD ID */ | ||
49 | if (read(fd, id, sizeof(id)) < (ssize_t)sizeof(id)) | 52 | if (read(fd, id, sizeof(id)) < (ssize_t)sizeof(id)) |
50 | return false; | 53 | return false; |
51 | 54 | ||
@@ -88,14 +91,7 @@ bool get_mod_metadata(int fd, struct mp3entry* id3) | |||
88 | if (!is_mod_file) | 91 | if (!is_mod_file) |
89 | return false; | 92 | return false; |
90 | 93 | ||
91 | p = id3->id3v2buf; | 94 | id3->title = id3->id3v2buf; /* Point title to previous read ID3 buffer. */ |
92 | |||
93 | /* Copy Title */ | ||
94 | if (strlcpy(p, buf, sizeof(id3->id3v2buf)) >= sizeof(id3->id3v2buf)) | ||
95 | return false; | ||
96 | |||
97 | id3->title = p; | ||
98 | |||
99 | id3->bitrate = filesize(fd)/1024; /* size in kb */ | 95 | id3->bitrate = filesize(fd)/1024; /* size in kb */ |
100 | id3->frequency = 44100; | 96 | id3->frequency = 44100; |
101 | id3->length = 120*1000; | 97 | id3->length = 120*1000; |