Index: apps/metadata/metadata_parsers.h =================================================================== --- apps/metadata/metadata_parsers.h (revision 22553) +++ apps/metadata/metadata_parsers.h (working copy) @@ -39,3 +39,5 @@ bool get_asf_metadata(int fd, struct mp3entry* id3); bool get_asap_metadata(int fd, struct mp3entry* id3); bool get_rm_metadata(int fd, struct mp3entry* id3); +bool get_nsf_metadata(int fd, struct mp3entry* id3); + Index: apps/metadata/nsf.c =================================================================== --- apps/metadata/nsf.c (revision 0) +++ apps/metadata/nsf.c (revision 0) @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include + +#include "system.h" +#include "metadata.h" +#include "metadata_common.h" +#include "metadata_parsers.h" +#include "rbunicode.h" + +bool get_nsf_metadata(int fd, struct mp3entry* id3) +{ + /* Use the trackname part of the id3 structure as a temporary buffer */ + unsigned char* buf = (unsigned char *)id3->path; + int read_bytes; + char *p; + + + if ((lseek(fd, 0, SEEK_SET) < 0) + || ((read_bytes = read(fd, buf, 110)) < 110)) + { + return false; + } + + id3->length = 120*1000; + id3->vbr = false; + id3->filesize = filesize(fd); + + if (memcmp(buf,"NESM",4) && memcmp(buf,"NSFE",4)) + { + return false; + } + else if (memcmp(buf, "NESM",4)) /* only NESM contain metadata */ + { + return true; + } + + p = id3->id3v2buf; + + /* Title */ + memcpy(p, &buf[14], 32); + id3->title = p; + p += strlen(p)+1; + + /* Artist */ + memcpy(p, &buf[46], 32); + id3->artist = p; + p += strlen(p)+1; + + /* Copyright (per codec) */ + memcpy(p, &buf[78], 32); + id3->album = p; + p += strlen(p)+1; + + return true; +} + Index: apps/metadata.c =================================================================== --- apps/metadata.c (revision 22553) +++ apps/metadata.c (working copy) @@ -215,10 +215,6 @@ */ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) { -#if CONFIG_CODEC == SWCODEC - unsigned char* buf; -#endif - /* Clear the mp3entry to avoid having bogus pointers appear */ memset(id3, 0, sizeof(struct mp3entry)); @@ -356,15 +352,11 @@ break; case AFMT_NSF: - buf = (unsigned char *)id3->path; - if ((lseek(fd, 0, SEEK_SET) < 0) || ((read(fd, buf, 8)) < 8)) + if (!get_nsf_metadata(fd, id3)) { - DEBUGF("lseek or read failed\n"); + DEBUGF("get_nsf_metadata error\n"); return false; } - id3->vbr = false; - id3->filesize = filesize(fd); - if (memcmp(buf,"NESM",4) && memcmp(buf,"NSFE",4)) return false; break; case AFMT_AIFF: Index: apps/SOURCES =================================================================== --- apps/SOURCES (revision 22553) +++ apps/SOURCES (working copy) @@ -172,6 +172,7 @@ metadata/a52.c metadata/asap.c metadata/rm.c +metadata/nsf.c #endif #ifdef HAVE_TAGCACHE tagcache.c