mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-18 17:42:36 -05:00
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
This commit is contained in:
parent
617d1e9f6b
commit
1a1ac92f45
1 changed files with 11 additions and 15 deletions
|
|
@ -35,17 +35,20 @@
|
||||||
bool get_mod_metadata(int fd, struct mp3entry* id3)
|
bool get_mod_metadata(int fd, struct mp3entry* id3)
|
||||||
{
|
{
|
||||||
/* Use the trackname part of the id3 structure as a temporary buffer */
|
/* 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];
|
unsigned char id[4];
|
||||||
bool is_mod_file = false;
|
bool is_mod_file = false;
|
||||||
char *p;
|
|
||||||
|
|
||||||
if ((lseek(fd, 0, SEEK_SET) < 0)
|
/* Seek to file begin */
|
||||||
|| (read(fd, buf, sizeof(buf)) < MODULEHEADERSIZE))
|
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||||
{
|
|
||||||
return false;
|
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))
|
if (read(fd, id, sizeof(id)) < (ssize_t)sizeof(id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -88,14 +91,7 @@ bool get_mod_metadata(int fd, struct mp3entry* id3)
|
||||||
if (!is_mod_file)
|
if (!is_mod_file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
p = id3->id3v2buf;
|
id3->title = id3->id3v2buf; /* Point title to previous read ID3 buffer. */
|
||||||
|
|
||||||
/* Copy Title */
|
|
||||||
if (strlcpy(p, buf, sizeof(id3->id3v2buf)) >= sizeof(id3->id3v2buf))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
id3->title = p;
|
|
||||||
|
|
||||||
id3->bitrate = filesize(fd)/1024; /* size in kb */
|
id3->bitrate = filesize(fd)/1024; /* size in kb */
|
||||||
id3->frequency = 44100;
|
id3->frequency = 44100;
|
||||||
id3->length = 120*1000;
|
id3->length = 120*1000;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue