diff options
| author | Björn Stenberg <bjorn@haxx.se> | 2002-12-09 15:01:37 +0000 |
|---|---|---|
| committer | Björn Stenberg <bjorn@haxx.se> | 2002-12-09 15:01:37 +0000 |
| commit | cf1317c336c946ee2eeda61729171bae82d87769 (patch) | |
| tree | 9a4ea79ca5b14a267ed905ad8b80ec93c197c9c0 | |
| parent | fd25bbd8ff47ba5741311d58d7c1d388f2a9e235 (diff) | |
| download | rockbox-cf1317c336c946ee2eeda61729171bae82d87769.zip rockbox-cf1317c336c946ee2eeda61729171bae82d87769.tar.gz rockbox-cf1317c336c946ee2eeda61729171bae82d87769.tar.bz2 rockbox-cf1317c336c946ee2eeda61729171bae82d87769.tar.xz | |
Added id3 version wps tag: %iv. Fixed id3v1 parsing bug.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2967 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/wps-display.c | 21 | ||||
| -rw-r--r-- | firmware/id3.c | 42 | ||||
| -rw-r--r-- | firmware/id3.h | 9 |
3 files changed, 60 insertions, 12 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index 19e505c..5ac2aa1 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c @@ -295,6 +295,27 @@ static char* get_tag(struct mp3entry* id3, else return NULL; break; + + case 'v': /* id3 version */ + switch (id3->id3version) { + case ID3_VER_1_0: + return "1"; + + case ID3_VER_1_1: + return "1.1"; + + case ID3_VER_2_2: + return "2.2"; + + case ID3_VER_2_3: + return "2.3"; + + case ID3_VER_2_4: + return "2.4"; + + default: + return NULL; + } } break; diff --git a/firmware/id3.c b/firmware/id3.c index 4b72e4c..2dd03c1 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -168,6 +168,8 @@ static bool setid3v1title(int fd, struct mp3entry *entry) if (strncmp(buffer, "TAG", 3)) return false; + entry->id3version = ID3_VER_1_0; + for (i=0; i < (int)sizeof offsets; i++) { char* ptr = buffer + offsets[i]; @@ -179,17 +181,17 @@ static bool setid3v1title(int fd, struct mp3entry *entry) switch(i) { case 0: - strcpy(entry->id3v1buf[2], ptr); + strncpy(entry->id3v1buf[2], ptr, 30); entry->title = entry->id3v1buf[2]; break; case 1: - strcpy(entry->id3v1buf[0], ptr); + strncpy(entry->id3v1buf[0], ptr, 30); entry->artist = entry->id3v1buf[0]; break; case 2: - strcpy(entry->id3v1buf[1], ptr); + strncpy(entry->id3v1buf[1], ptr, 30); entry->album = entry->id3v1buf[1]; break; @@ -201,8 +203,10 @@ static bool setid3v1title(int fd, struct mp3entry *entry) case 4: /* id3v1.1 uses last two bytes of comment field for track number: first must be 0 and second is track num */ - if (*ptr == 0) + if (!ptr[0] && ptr[1]) { entry->tracknum = ptr[1]; + entry->id3version = ID3_VER_1_1; + } break; case 5: @@ -230,7 +234,7 @@ static void setid3v2title(int fd, struct mp3entry *entry) int size; int bufferpos = 0, totframelen, framelen; char header[10]; - unsigned short int version; + unsigned char version; char *buffer = entry->id3v2buf; char *tracknum = NULL; int bytesread = 0; @@ -245,16 +249,30 @@ static void setid3v2title(int fd, struct mp3entry *entry) if(10 != read(fd, header, 10)) return; - version = (unsigned short int)header[3]; - /* Get the total ID3 tag size */ size = entry->id3v2len - 10; - /* Set minimum frame size according to ID3v2 version */ - if(version > 2) - minframesize = 12; - else - minframesize = 8; + version = header[3]; + switch ( version ) { + case 2: + entry->id3version = ID3_VER_2_2; + minframesize = 8; + break; + + case 3: + entry->id3version = ID3_VER_2_3; + minframesize = 12; + break; + + case 4: + entry->id3version = ID3_VER_2_4; + minframesize = 12; + break; + + default: + /* unsupported id3 version */ + return; + } /* * We must have at least minframesize bytes left for the diff --git a/firmware/id3.h b/firmware/id3.h index 11d9eee..55ce002 100644 --- a/firmware/id3.h +++ b/firmware/id3.h @@ -30,6 +30,7 @@ struct mp3entry { int version; int layer; int year; + unsigned char id3version; unsigned char genre; unsigned int bitrate; unsigned int frequency; @@ -62,6 +63,14 @@ struct mp3entry { #define VBR_BYTES_FLAG 0x02 #define VBR_TOC_FLAG 0x04 +enum { + ID3_VER_1_0 = 1, + ID3_VER_1_1, + ID3_VER_2_2, + ID3_VER_2_3, + ID3_VER_2_4 +}; + bool mp3info(struct mp3entry *entry, char *filename); #endif |