diff options
author | Dave Chapman <dave@dchapman.com> | 2005-06-18 16:24:27 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2005-06-18 16:24:27 +0000 |
commit | 961c9a3e4103e766f52ff1d7c2af2db6119c72ec (patch) | |
tree | c4fd5b0ea3b7063315910fea159a590e74680ed4 | |
parent | 2bfd2585a9cfb8541047a3f5eedbfd05fe36f9f9 (diff) | |
download | rockbox-961c9a3e4103e766f52ff1d7c2af2db6119c72ec.tar.gz rockbox-961c9a3e4103e766f52ff1d7c2af2db6119c72ec.zip |
Added %fc WPS tag to display codec type - moved codectype from track_info struct into mp3info struct, initialise it on MAS platforms, and add it to the WPS.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6748 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/metadata.c | 2 | ||||
-rw-r--r-- | apps/playback.c | 10 | ||||
-rw-r--r-- | apps/playback.h | 18 | ||||
-rw-r--r-- | apps/wps-display.c | 3 | ||||
-rw-r--r-- | firmware/export/id3.h | 31 | ||||
-rw-r--r-- | firmware/id3.c | 48 |
6 files changed, 88 insertions, 24 deletions
diff --git a/apps/metadata.c b/apps/metadata.c index e4b4cf061e..2e39ab1685 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -94,7 +94,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname, | |||
94 | int rc; | 94 | int rc; |
95 | 95 | ||
96 | /* Load codec specific track tag information. */ | 96 | /* Load codec specific track tag information. */ |
97 | switch (track->codectype) { | 97 | switch (track->id3.codectype) { |
98 | case AFMT_MPA_L1: | 98 | case AFMT_MPA_L1: |
99 | case AFMT_MPA_L2: | 99 | case AFMT_MPA_L2: |
100 | case AFMT_MPA_L3: | 100 | case AFMT_MPA_L3: |
diff --git a/apps/playback.c b/apps/playback.c index fb9a788ac4..f4ec05b369 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -531,7 +531,7 @@ bool loadcodec(const char *trackname, bool start_play) | |||
531 | codec_path = NULL; | 531 | codec_path = NULL; |
532 | } | 532 | } |
533 | 533 | ||
534 | tracks[track_widx].codectype = filetype; | 534 | tracks[track_widx].id3.codectype = filetype; |
535 | tracks[track_widx].codecsize = 0; | 535 | tracks[track_widx].codecsize = 0; |
536 | if (codec_path == NULL) | 536 | if (codec_path == NULL) |
537 | return false; | 537 | return false; |
@@ -540,7 +540,7 @@ bool loadcodec(const char *trackname, bool start_play) | |||
540 | prev_track = track_widx - 1; | 540 | prev_track = track_widx - 1; |
541 | if (prev_track < 0) | 541 | if (prev_track < 0) |
542 | prev_track = MAX_TRACK-1; | 542 | prev_track = MAX_TRACK-1; |
543 | if (track_count > 0 && filetype == tracks[prev_track].codectype) { | 543 | if (track_count > 0 && filetype == tracks[prev_track].id3.codectype) { |
544 | logf("Reusing prev. codec"); | 544 | logf("Reusing prev. codec"); |
545 | return true; | 545 | return true; |
546 | } | 546 | } |
@@ -667,8 +667,8 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) | |||
667 | 667 | ||
668 | /* Starting playback from an offset is only support in MPA at the moment */ | 668 | /* Starting playback from an offset is only support in MPA at the moment */ |
669 | if (offset > 0) { | 669 | if (offset > 0) { |
670 | if ((tracks[track_widx].codectype==AFMT_MPA_L2) || | 670 | if ((tracks[track_widx].id3.codectype==AFMT_MPA_L2) || |
671 | (tracks[track_widx].codectype==AFMT_MPA_L3)) { | 671 | (tracks[track_widx].id3.codectype==AFMT_MPA_L3)) { |
672 | lseek(fd, offset, SEEK_SET); | 672 | lseek(fd, offset, SEEK_SET); |
673 | tracks[track_widx].id3.offset = offset; | 673 | tracks[track_widx].id3.offset = offset; |
674 | mp3_set_elapsed(&tracks[track_widx].id3); | 674 | mp3_set_elapsed(&tracks[track_widx].id3); |
@@ -955,7 +955,7 @@ bool codec_request_next_track_callback(void) | |||
955 | 955 | ||
956 | ci.reload_codec = false; | 956 | ci.reload_codec = false; |
957 | 957 | ||
958 | if (cur_ti->codectype != tracks[track_ridx].codectype) { | 958 | if (cur_ti->id3.codectype != tracks[track_ridx].id3.codectype) { |
959 | if (--track_ridx < 0) | 959 | if (--track_ridx < 0) |
960 | track_ridx = MAX_TRACK-1; | 960 | track_ridx = MAX_TRACK-1; |
961 | logf("New codec"); | 961 | logf("New codec"); |
diff --git a/apps/playback.h b/apps/playback.h index 1df283e6b8..06b82b40e4 100644 --- a/apps/playback.h +++ b/apps/playback.h | |||
@@ -27,23 +27,6 @@ | |||
27 | #include "id3.h" | 27 | #include "id3.h" |
28 | #include "mp3data.h" | 28 | #include "mp3data.h" |
29 | 29 | ||
30 | /* Supported file types. */ | ||
31 | #define AFMT_MPA_L1 0x0001 // MPEG Audio layer 1 | ||
32 | #define AFMT_MPA_L2 0x0002 // MPEG Audio layer 2 | ||
33 | #define AFMT_MPA_L3 0x0004 // MPEG Audio layer 3 | ||
34 | /* (MPEG-1, 2, 2.5 layers 1, 2 and 3 */ | ||
35 | #define AFMT_PCM_WAV 0x0008 // Uncompressed PCM in a WAV file | ||
36 | #define AFMT_OGG_VORBIS 0x0010 // Ogg Vorbis | ||
37 | #define AFMT_FLAC 0x0020 // FLAC | ||
38 | #define AFMT_MPC 0x0040 // Musepack | ||
39 | #define AFMT_AAC 0x0080 // AAC | ||
40 | #define AFMT_APE 0x0100 // Monkey's Audio | ||
41 | #define AFMT_WMA 0x0200 // Windows Media Audio | ||
42 | #define AFMT_A52 0x0400 // A/52 (aka AC3) audio | ||
43 | #define AFMT_REAL 0x0800 // Realaudio | ||
44 | #define AFMT_UNKNOWN 0x1000 // Unknown file format | ||
45 | #define AFMT_WAVPACK 0x2000 // WavPack | ||
46 | |||
47 | /* File buffer configuration keys. */ | 30 | /* File buffer configuration keys. */ |
48 | #define CODEC_SET_FILEBUF_WATERMARK 1 | 31 | #define CODEC_SET_FILEBUF_WATERMARK 1 |
49 | #define CODEC_SET_FILEBUF_CHUNKSIZE 2 | 32 | #define CODEC_SET_FILEBUF_CHUNKSIZE 2 |
@@ -58,7 +41,6 @@ struct track_info { | |||
58 | struct mp3info mp3data; /* MP3 metadata */ | 41 | struct mp3info mp3data; /* MP3 metadata */ |
59 | char *codecbuf; /* Pointer to codec buffer */ | 42 | char *codecbuf; /* Pointer to codec buffer */ |
60 | size_t codecsize; /* Codec length in bytes */ | 43 | size_t codecsize; /* Codec length in bytes */ |
61 | int codectype; /* Codec type (example AFMT_MPA_L3) */ | ||
62 | 44 | ||
63 | off_t filerem; /* Remaining bytes of file NOT in buffer */ | 45 | off_t filerem; /* Remaining bytes of file NOT in buffer */ |
64 | off_t filesize; /* File total length */ | 46 | off_t filesize; /* File total length */ |
diff --git a/apps/wps-display.c b/apps/wps-display.c index 39d0475886..aca7350904 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -445,6 +445,9 @@ static char* get_tag(struct mp3entry* cid3, | |||
445 | case 's': /* File Size (in kilobytes) */ | 445 | case 's': /* File Size (in kilobytes) */ |
446 | snprintf(buf, buf_size, "%d", id3->filesize / 1024); | 446 | snprintf(buf, buf_size, "%d", id3->filesize / 1024); |
447 | return buf; | 447 | return buf; |
448 | |||
449 | case 'c': /* File Codec */ | ||
450 | return id3_get_codec(id3); | ||
448 | } | 451 | } |
449 | break; | 452 | break; |
450 | 453 | ||
diff --git a/firmware/export/id3.h b/firmware/export/id3.h index 8a79cb0ce1..99999817c2 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h | |||
@@ -19,8 +19,37 @@ | |||
19 | #ifndef ID3_H | 19 | #ifndef ID3_H |
20 | #define ID3_H | 20 | #define ID3_H |
21 | 21 | ||
22 | #include "config.h" | ||
22 | #include "file.h" | 23 | #include "file.h" |
23 | 24 | ||
25 | /* Audio file types. */ | ||
26 | /* NOTE: When adding new audio types, also add to codec_labels[] in id3.c */ | ||
27 | enum { | ||
28 | AFMT_UNKNOWN = 0, /* Unknown file format */ | ||
29 | |||
30 | #if CONFIG_HWCODEC==MASNONE | ||
31 | AFMT_MPA_L1, /* MPEG Audio layer 1 */ | ||
32 | #endif | ||
33 | |||
34 | AFMT_MPA_L2, /* MPEG Audio layer 2 */ | ||
35 | AFMT_MPA_L3, /* MPEG Audio layer 3 */ | ||
36 | |||
37 | #if CONFIG_HWCODEC==MASNONE | ||
38 | AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */ | ||
39 | AFMT_OGG_VORBIS, /* Ogg Vorbis */ | ||
40 | AFMT_FLAC, /* FLAC */ | ||
41 | AFMT_MPC, /* Musepack */ | ||
42 | AFMT_AAC, /* AAC */ | ||
43 | AFMT_APE, /* Monkey's Audio */ | ||
44 | AFMT_WMA, /* Windows Media Audio */ | ||
45 | AFMT_A52, /* A/52 (aka AC3) audio */ | ||
46 | AFMT_REAL, /* Realaudio */ | ||
47 | AFMT_WAVPACK, /* WavPack */ | ||
48 | #endif | ||
49 | |||
50 | AFMT_ENDMARKER /* THIS MUST BE THE LAST VALUE */ | ||
51 | }; | ||
52 | |||
24 | struct mp3entry { | 53 | struct mp3entry { |
25 | char path[MAX_PATH]; | 54 | char path[MAX_PATH]; |
26 | char *title; | 55 | char *title; |
@@ -33,6 +62,7 @@ struct mp3entry { | |||
33 | int tracknum; | 62 | int tracknum; |
34 | int version; | 63 | int version; |
35 | int layer; | 64 | int layer; |
65 | int codectype; | ||
36 | int year; | 66 | int year; |
37 | unsigned char id3version; | 67 | unsigned char id3version; |
38 | unsigned char genre; | 68 | unsigned char genre; |
@@ -76,5 +106,6 @@ enum { | |||
76 | 106 | ||
77 | bool mp3info(struct mp3entry *entry, const char *filename, bool v1first); | 107 | bool mp3info(struct mp3entry *entry, const char *filename, bool v1first); |
78 | char* id3_get_genre(const struct mp3entry* id3); | 108 | char* id3_get_genre(const struct mp3entry* id3); |
109 | char* id3_get_codec(const struct mp3entry* id3); | ||
79 | 110 | ||
80 | #endif | 111 | #endif |
diff --git a/firmware/id3.c b/firmware/id3.c index becb6781cc..603639d1f5 100644 --- a/firmware/id3.c +++ b/firmware/id3.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <stdbool.h> | 33 | #include <stdbool.h> |
34 | #include <stddef.h> | 34 | #include <stddef.h> |
35 | #include <ctype.h> | 35 | #include <ctype.h> |
36 | #include "config.h" | ||
36 | #include "file.h" | 37 | #include "file.h" |
37 | #include "debug.h" | 38 | #include "debug.h" |
38 | #include "atoi.h" | 39 | #include "atoi.h" |
@@ -77,6 +78,31 @@ static const char* const genres[] = { | |||
77 | "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall" | 78 | "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall" |
78 | }; | 79 | }; |
79 | 80 | ||
81 | static const char* const codec_labels[] = { | ||
82 | "???", /* Unknown file format */ | ||
83 | |||
84 | #if CONFIG_HWCODEC==MASNONE | ||
85 | "MP1", /* MPEG Audio layer 1 */ | ||
86 | #endif | ||
87 | |||
88 | "MP2", /* MPEG Audio layer 2 */ | ||
89 | "MP3", /* MPEG Audio layer 3 */ | ||
90 | |||
91 | #if CONFIG_HWCODEC==MASNONE | ||
92 | "WAV", /* Uncompressed PCM in a WAV file */ | ||
93 | "OGG", /* Ogg Vorbis */ | ||
94 | "FLAC", /* FLAC */ | ||
95 | "MPC", /* Musepack */ | ||
96 | "AAC", /* AAC */ | ||
97 | "APE", /* Monkey's Audio */ | ||
98 | "WMA", /* Windows Media Audio */ | ||
99 | "AC3", /* A/52 (aka AC3) audio */ | ||
100 | "RA", /* Realaudio */ | ||
101 | "WV", /* WavPack */ | ||
102 | #endif | ||
103 | NULL | ||
104 | }; | ||
105 | |||
80 | char* id3_get_genre(const struct mp3entry* id3) | 106 | char* id3_get_genre(const struct mp3entry* id3) |
81 | { | 107 | { |
82 | if( id3->genre_string ) | 108 | if( id3->genre_string ) |
@@ -87,6 +113,15 @@ char* id3_get_genre(const struct mp3entry* id3) | |||
87 | return NULL; | 113 | return NULL; |
88 | } | 114 | } |
89 | 115 | ||
116 | char* id3_get_codec(const struct mp3entry* id3) | ||
117 | { | ||
118 | if ((id3->codectype >= 0) && (id3->codectype < AFMT_ENDMARKER)) { | ||
119 | return (char*)codec_labels[id3->codectype]; | ||
120 | } else { | ||
121 | return NULL; | ||
122 | } | ||
123 | } | ||
124 | |||
90 | /* | 125 | /* |
91 | HOW TO ADD ADDITIONAL ID3 VERSION 2 TAGS | 126 | HOW TO ADD ADDITIONAL ID3 VERSION 2 TAGS |
92 | Code and comments by Thomas Paul Diffenbach | 127 | Code and comments by Thomas Paul Diffenbach |
@@ -763,6 +798,19 @@ static int getsonglength(int fd, struct mp3entry *entry) | |||
763 | entry->frequency = info.frequency; | 798 | entry->frequency = info.frequency; |
764 | entry->version = info.version; | 799 | entry->version = info.version; |
765 | entry->layer = info.layer; | 800 | entry->layer = info.layer; |
801 | switch(entry->layer) { | ||
802 | #if CONFIG_HWCODEC==MASNONE | ||
803 | case 0: | ||
804 | entry->codectype=AFMT_MPA_L1; | ||
805 | break; | ||
806 | #endif | ||
807 | case 1: | ||
808 | entry->codectype=AFMT_MPA_L2; | ||
809 | break; | ||
810 | case 2: | ||
811 | entry->codectype=AFMT_MPA_L3; | ||
812 | break; | ||
813 | } | ||
766 | 814 | ||
767 | /* If the file time hasn't been established, this may be a fixed | 815 | /* If the file time hasn't been established, this may be a fixed |
768 | rate MP3, so just use the default formula */ | 816 | rate MP3, so just use the default formula */ |