diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-11-26 18:02:50 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-11-26 18:02:50 +0000 |
commit | 9393e4c24b4c18d7fe1fa8313008f30370cb726e (patch) | |
tree | 746e9210b2144c96b6d58a3f858ccdcb358d854e /apps/metadata.c | |
parent | 756c59a534d2e26b0e62fb94a326182f376b8a97 (diff) | |
download | rockbox-9393e4c24b4c18d7fe1fa8313008f30370cb726e.tar.gz rockbox-9393e4c24b4c18d7fe1fa8313008f30370cb726e.zip |
Change how all the metadata parsers are read from a giant swich/case to function pointers via array index. Also unify the api.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28672 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/metadata.c')
-rw-r--r-- | apps/metadata.c | 368 |
1 files changed, 80 insertions, 288 deletions
diff --git a/apps/metadata.c b/apps/metadata.c index 15b7d9f72b..fb0ce0341c 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -37,154 +37,171 @@ | |||
37 | 37 | ||
38 | #include "metadata/metadata_common.h" | 38 | #include "metadata/metadata_common.h" |
39 | 39 | ||
40 | static bool get_shn_metadata(int fd, struct mp3entry *id3) | ||
41 | { | ||
42 | /* TODO: read the id3v2 header if it exists */ | ||
43 | id3->vbr = true; | ||
44 | id3->filesize = filesize(fd); | ||
45 | return skip_id3v2(fd, id3); | ||
46 | } | ||
47 | |||
48 | static bool get_other_asap_metadata(int fd, struct mp3entry *id3) | ||
49 | { | ||
50 | id3->bitrate = 706; | ||
51 | id3->frequency = 44100; | ||
52 | id3->vbr = false; | ||
53 | id3->filesize = filesize(fd); | ||
54 | id3->genre_string = id3_get_num_genre(36); | ||
55 | return true; | ||
56 | } | ||
40 | #endif /* CONFIG_CODEC == SWCODEC */ | 57 | #endif /* CONFIG_CODEC == SWCODEC */ |
41 | 58 | ||
42 | const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | 59 | const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = |
43 | { | 60 | { |
44 | /* Unknown file format */ | 61 | /* Unknown file format */ |
45 | [AFMT_UNKNOWN] = | 62 | [AFMT_UNKNOWN] = |
46 | AFMT_ENTRY("???", NULL, NULL, NULL ), | 63 | AFMT_ENTRY("???", NULL, NULL, NULL, NULL ), |
47 | 64 | ||
48 | /* MPEG Audio layer 1 */ | 65 | /* MPEG Audio layer 1 */ |
49 | [AFMT_MPA_L1] = | 66 | [AFMT_MPA_L1] = |
50 | AFMT_ENTRY("MP1", "mpa", NULL, "mp1\0" ), | 67 | AFMT_ENTRY("MP1", "mpa", NULL, get_mp3_metadata, "mp1\0"), |
51 | /* MPEG Audio layer 2 */ | 68 | /* MPEG Audio layer 2 */ |
52 | [AFMT_MPA_L2] = | 69 | [AFMT_MPA_L2] = |
53 | AFMT_ENTRY("MP2", "mpa", NULL, "mpa\0mp2\0" ), | 70 | AFMT_ENTRY("MP2", "mpa", NULL, get_mp3_metadata, "mpa\0mp2\0"), |
54 | /* MPEG Audio layer 3 */ | 71 | /* MPEG Audio layer 3 */ |
55 | [AFMT_MPA_L3] = | 72 | [AFMT_MPA_L3] = |
56 | AFMT_ENTRY("MP3", "mpa", "mp3_enc", "mp3\0" ), | 73 | AFMT_ENTRY("MP3", "mpa", "mp3_enc", get_mp3_metadata, "mp3\0"), |
57 | 74 | ||
58 | #if CONFIG_CODEC == SWCODEC | 75 | #if CONFIG_CODEC == SWCODEC |
59 | /* Audio Interchange File Format */ | 76 | /* Audio Interchange File Format */ |
60 | [AFMT_AIFF] = | 77 | [AFMT_AIFF] = |
61 | AFMT_ENTRY("AIFF", "aiff", "aiff_enc", "aiff\0aif\0"), | 78 | AFMT_ENTRY("AIFF", "aiff", "aiff_enc", get_aiff_metadata, "aiff\0aif\0"), |
62 | /* Uncompressed PCM in a WAV file OR ATRAC3 stream in WAV file (.at3) */ | 79 | /* Uncompressed PCM in a WAV file OR ATRAC3 stream in WAV file (.at3) */ |
63 | [AFMT_PCM_WAV] = | 80 | [AFMT_PCM_WAV] = |
64 | AFMT_ENTRY("WAV", "wav", "wav_enc", "wav\0at3\0" ), | 81 | AFMT_ENTRY("WAV", "wav", "wav_enc", get_wave_metadata, "wav\0at3\0"), |
65 | /* Ogg Vorbis */ | 82 | /* Ogg Vorbis */ |
66 | [AFMT_OGG_VORBIS] = | 83 | [AFMT_OGG_VORBIS] = |
67 | AFMT_ENTRY("Ogg", "vorbis", NULL, "ogg\0oga\0" ), | 84 | AFMT_ENTRY("Ogg", "vorbis", NULL, get_ogg_metadata, "ogg\0oga\0"), |
68 | /* FLAC */ | 85 | /* FLAC */ |
69 | [AFMT_FLAC] = | 86 | [AFMT_FLAC] = |
70 | AFMT_ENTRY("FLAC", "flac", NULL, "flac\0" ), | 87 | AFMT_ENTRY("FLAC", "flac", NULL, get_flac_metadata, "flac\0"), |
71 | /* Musepack */ | 88 | /* Musepack */ |
72 | [AFMT_MPC] = | 89 | [AFMT_MPC] = |
73 | AFMT_ENTRY("MPC", "mpc", NULL, "mpc\0" ), | 90 | AFMT_ENTRY("MPC", "mpc", NULL, get_musepack_metadata,"mpc\0"), |
74 | /* A/52 (aka AC3) audio */ | 91 | /* A/52 (aka AC3) audio */ |
75 | [AFMT_A52] = | 92 | [AFMT_A52] = |
76 | AFMT_ENTRY("AC3", "a52", NULL, "a52\0ac3\0" ), | 93 | AFMT_ENTRY("AC3", "a52", NULL, get_a52_metadata, "a52\0ac3\0"), |
77 | /* WavPack */ | 94 | /* WavPack */ |
78 | [AFMT_WAVPACK] = | 95 | [AFMT_WAVPACK] = |
79 | AFMT_ENTRY("WV", "wavpack", "wavpack_enc", "wv\0" ), | 96 | AFMT_ENTRY("WV","wavpack","wavpack_enc",get_wavpack_metadata,"wv\0"), |
80 | /* Apple Lossless Audio Codec */ | 97 | /* Apple Lossless Audio Codec */ |
81 | [AFMT_MP4_ALAC] = | 98 | [AFMT_MP4_ALAC] = |
82 | AFMT_ENTRY("ALAC", "alac", NULL, "m4a\0m4b\0" ), | 99 | AFMT_ENTRY("ALAC", "alac", NULL, get_mp4_metadata, "m4a\0m4b\0"), |
83 | /* Advanced Audio Coding in M4A container */ | 100 | /* Advanced Audio Coding in M4A container */ |
84 | [AFMT_MP4_AAC] = | 101 | [AFMT_MP4_AAC] = |
85 | AFMT_ENTRY("AAC", "aac", NULL, "mp4\0" ), | 102 | AFMT_ENTRY("AAC", "aac", NULL, get_mp4_metadata, "mp4\0"), |
86 | /* Shorten */ | 103 | /* Shorten */ |
87 | [AFMT_SHN] = | 104 | [AFMT_SHN] = |
88 | AFMT_ENTRY("SHN", "shorten", NULL, "shn\0" ), | 105 | AFMT_ENTRY("SHN","shorten", NULL, get_shn_metadata, "shn\0"), |
89 | /* SID File Format */ | 106 | /* SID File Format */ |
90 | [AFMT_SID] = | 107 | [AFMT_SID] = |
91 | AFMT_ENTRY("SID", "sid", NULL, "sid\0" ), | 108 | AFMT_ENTRY("SID", "sid", NULL, get_sid_metadata, "sid\0"), |
92 | /* ADX File Format */ | 109 | /* ADX File Format */ |
93 | [AFMT_ADX] = | 110 | [AFMT_ADX] = |
94 | AFMT_ENTRY("ADX", "adx", NULL, "adx\0" ), | 111 | AFMT_ENTRY("ADX", "adx", NULL, get_adx_metadata, "adx\0"), |
95 | /* NESM (NES Sound Format) */ | 112 | /* NESM (NES Sound Format) */ |
96 | [AFMT_NSF] = | 113 | [AFMT_NSF] = |
97 | AFMT_ENTRY("NSF", "nsf", NULL, "nsf\0nsfe\0" ), | 114 | AFMT_ENTRY("NSF", "nsf", NULL, get_nsf_metadata, "nsf\0nsfe\0"), |
98 | /* Speex File Format */ | 115 | /* Speex File Format */ |
99 | [AFMT_SPEEX] = | 116 | [AFMT_SPEEX] = |
100 | AFMT_ENTRY("Speex","speex", NULL, "spx\0" ), | 117 | AFMT_ENTRY("Speex", "speex",NULL, get_ogg_metadata, "spx\0"), |
101 | /* SPC700 Save State */ | 118 | /* SPC700 Save State */ |
102 | [AFMT_SPC] = | 119 | [AFMT_SPC] = |
103 | AFMT_ENTRY("SPC", "spc", NULL, "spc\0" ), | 120 | AFMT_ENTRY("SPC", "spc", NULL, get_spc_metadata, "spc\0"), |
104 | /* APE (Monkey's Audio) */ | 121 | /* APE (Monkey's Audio) */ |
105 | [AFMT_APE] = | 122 | [AFMT_APE] = |
106 | AFMT_ENTRY("APE", "ape", NULL, "ape\0mac\0" ), | 123 | AFMT_ENTRY("APE", "ape", NULL, get_monkeys_metadata,"ape\0mac\0"), |
107 | /* WMA (WMAV1/V2 in ASF) */ | 124 | /* WMA (WMAV1/V2 in ASF) */ |
108 | [AFMT_WMA] = | 125 | [AFMT_WMA] = |
109 | AFMT_ENTRY("WMA", "wma", NULL, "wma\0wmv\0asf\0" ), | 126 | AFMT_ENTRY("WMA", "wma", NULL, get_asf_metadata,"wma\0wmv\0asf\0"), |
110 | /* WMA Professional in ASF */ | 127 | /* WMA Professional in ASF */ |
111 | [AFMT_WMAPRO] = | 128 | [AFMT_WMAPRO] = |
112 | AFMT_ENTRY("WMAPro", "wmapro", NULL, "wma\0wmv\0asf\0" ), | 129 | AFMT_ENTRY("WMAPro","wmapro",NULL, NULL, "wma\0wmv\0asf\0"), |
113 | /* Amiga MOD File */ | 130 | /* Amiga MOD File */ |
114 | [AFMT_MOD] = | 131 | [AFMT_MOD] = |
115 | AFMT_ENTRY("MOD", "mod", NULL, "mod\0" ), | 132 | AFMT_ENTRY("MOD", "mod", NULL, get_mod_metadata, "mod\0"), |
116 | /* Atari SAP File */ | 133 | /* Atari SAP File */ |
117 | [AFMT_SAP] = | 134 | [AFMT_SAP] = |
118 | AFMT_ENTRY("SAP", "asap", NULL, "sap\0" ), | 135 | AFMT_ENTRY("SAP", "asap", NULL, get_asap_metadata, "sap\0"), |
119 | /* Cook in RM/RA */ | 136 | /* Cook in RM/RA */ |
120 | [AFMT_RM_COOK] = | 137 | [AFMT_RM_COOK] = |
121 | AFMT_ENTRY("Cook", "cook", NULL, "rm\0ra\0rmvb\0" ), | 138 | AFMT_ENTRY("Cook", "cook", NULL, get_rm_metadata,"rm\0ra\0rmvb\0"), |
122 | /* AAC in RM/RA */ | 139 | /* AAC in RM/RA */ |
123 | [AFMT_RM_AAC] = | 140 | [AFMT_RM_AAC] = |
124 | AFMT_ENTRY("RAAC", "raac", NULL, "rm\0ra\0rmvb\0" ), | 141 | AFMT_ENTRY("RAAC", "raac", NULL, NULL, "rm\0ra\0rmvb\0"), |
125 | /* AC3 in RM/RA */ | 142 | /* AC3 in RM/RA */ |
126 | [AFMT_RM_AC3] = | 143 | [AFMT_RM_AC3] = |
127 | AFMT_ENTRY("AC3", "a52_rm", NULL, "rm\0ra\0rmvb\0" ), | 144 | AFMT_ENTRY("AC3", "a52_rm", NULL, NULL, "rm\0ra\0rmvb\0"), |
128 | /* ATRAC3 in RM/RA */ | 145 | /* ATRAC3 in RM/RA */ |
129 | [AFMT_RM_ATRAC3] = | 146 | [AFMT_RM_ATRAC3] = |
130 | AFMT_ENTRY("ATRAC3","atrac3_rm", NULL, "rm\0ra\0rmvb\0" ), | 147 | AFMT_ENTRY("ATRAC3","atrac3_rm",NULL, NULL, "rm\0ra\0rmvb\0"), |
131 | /* Atari CMC File */ | 148 | /* Atari CMC File */ |
132 | [AFMT_CMC] = | 149 | [AFMT_CMC] = |
133 | AFMT_ENTRY("CMC", "asap", NULL, "cmc\0" ), | 150 | AFMT_ENTRY("CMC", "asap", NULL, get_other_asap_metadata,"cmc\0"), |
134 | /* Atari CM3 File */ | 151 | /* Atari CM3 File */ |
135 | [AFMT_CM3] = | 152 | [AFMT_CM3] = |
136 | AFMT_ENTRY("CM3", "asap", NULL, "cm3\0" ), | 153 | AFMT_ENTRY("CM3", "asap", NULL, get_other_asap_metadata,"cm3\0"), |
137 | /* Atari CMR File */ | 154 | /* Atari CMR File */ |
138 | [AFMT_CMR] = | 155 | [AFMT_CMR] = |
139 | AFMT_ENTRY("CMR", "asap", NULL, "cmr\0" ), | 156 | AFMT_ENTRY("CMR", "asap", NULL, get_other_asap_metadata,"cmr\0"), |
140 | /* Atari CMS File */ | 157 | /* Atari CMS File */ |
141 | [AFMT_CMS] = | 158 | [AFMT_CMS] = |
142 | AFMT_ENTRY("CMS", "asap", NULL, "cms\0" ), | 159 | AFMT_ENTRY("CMS", "asap", NULL, get_other_asap_metadata,"cms\0"), |
143 | /* Atari DMC File */ | 160 | /* Atari DMC File */ |
144 | [AFMT_DMC] = | 161 | [AFMT_DMC] = |
145 | AFMT_ENTRY("DMC", "asap", NULL, "dmc\0" ), | 162 | AFMT_ENTRY("DMC", "asap", NULL, get_other_asap_metadata,"dmc\0"), |
146 | /* Atari DLT File */ | 163 | /* Atari DLT File */ |
147 | [AFMT_DLT] = | 164 | [AFMT_DLT] = |
148 | AFMT_ENTRY("DLT", "asap", NULL, "dlt\0" ), | 165 | AFMT_ENTRY("DLT", "asap", NULL, get_other_asap_metadata,"dlt\0"), |
149 | /* Atari MPT File */ | 166 | /* Atari MPT File */ |
150 | [AFMT_MPT] = | 167 | [AFMT_MPT] = |
151 | AFMT_ENTRY("MPT", "asap", NULL, "mpt\0" ), | 168 | AFMT_ENTRY("MPT", "asap", NULL, get_other_asap_metadata,"mpt\0"), |
152 | /* Atari MPD File */ | 169 | /* Atari MPD File */ |
153 | [AFMT_MPD] = | 170 | [AFMT_MPD] = |
154 | AFMT_ENTRY("MPD", "asap", NULL, "mpd\0" ), | 171 | AFMT_ENTRY("MPD", "asap", NULL, get_other_asap_metadata,"mpd\0"), |
155 | /* Atari RMT File */ | 172 | /* Atari RMT File */ |
156 | [AFMT_RMT] = | 173 | [AFMT_RMT] = |
157 | AFMT_ENTRY("RMT", "asap", NULL, "rmt\0" ), | 174 | AFMT_ENTRY("RMT", "asap", NULL, get_other_asap_metadata,"rmt\0"), |
158 | /* Atari TMC File */ | 175 | /* Atari TMC File */ |
159 | [AFMT_TMC] = | 176 | [AFMT_TMC] = |
160 | AFMT_ENTRY("TMC", "asap", NULL, "tmc\0" ), | 177 | AFMT_ENTRY("TMC", "asap", NULL, get_other_asap_metadata,"tmc\0"), |
161 | /* Atari TM8 File */ | 178 | /* Atari TM8 File */ |
162 | [AFMT_TM8] = | 179 | [AFMT_TM8] = |
163 | AFMT_ENTRY("TM8", "asap", NULL, "tm8\0" ), | 180 | AFMT_ENTRY("TM8", "asap", NULL, get_other_asap_metadata,"tm8\0"), |
164 | /* Atari TM2 File */ | 181 | /* Atari TM2 File */ |
165 | [AFMT_TM2] = | 182 | [AFMT_TM2] = |
166 | AFMT_ENTRY("TM2", "asap", NULL, "tm2\0" ), | 183 | AFMT_ENTRY("TM2", "asap", NULL, get_other_asap_metadata,"tm2\0"), |
167 | /* Atrac3 in Sony OMA Container */ | 184 | /* Atrac3 in Sony OMA Container */ |
168 | [AFMT_OMA_ATRAC3] = | 185 | [AFMT_OMA_ATRAC3] = |
169 | AFMT_ENTRY("ATRAC3", "atrac3_oma", NULL, "oma\0aa3\0" ), | 186 | AFMT_ENTRY("ATRAC3","atrac3_oma",NULL, get_oma_metadata, "oma\0aa3\0"), |
170 | /* SMAF (Synthetic music Mobile Application Format) */ | 187 | /* SMAF (Synthetic music Mobile Application Format) */ |
171 | [AFMT_SMAF] = | 188 | [AFMT_SMAF] = |
172 | AFMT_ENTRY("SMAF", "smaf", NULL, "mmf\0" ), | 189 | AFMT_ENTRY("SMAF", "smaf", NULL, get_smaf_metadata, "mmf\0"), |
173 | /* Sun Audio file */ | 190 | /* Sun Audio file */ |
174 | [AFMT_AU] = | 191 | [AFMT_AU] = |
175 | AFMT_ENTRY("AU", "au", NULL, "au\0snd\0" ), | 192 | AFMT_ENTRY("AU", "au", NULL, get_au_metadata, "au\0snd\0"), |
176 | /* VOX (Dialogic telephony file formats) */ | 193 | /* VOX (Dialogic telephony file formats) */ |
177 | [AFMT_VOX] = | 194 | [AFMT_VOX] = |
178 | AFMT_ENTRY("VOX", "vox", NULL, "vox\0" ), | 195 | AFMT_ENTRY("VOX", "vox", NULL, get_vox_metadata, "vox\0"), |
179 | /* Wave64 */ | 196 | /* Wave64 */ |
180 | [AFMT_WAVE64] = | 197 | [AFMT_WAVE64] = |
181 | AFMT_ENTRY("WAVE64", "wav64", NULL, "w64\0" ), | 198 | AFMT_ENTRY("WAVE64","wav64",NULL, get_wave64_metadata,"w64\0"), |
182 | /* True Audio */ | 199 | /* True Audio */ |
183 | [AFMT_TTA] = | 200 | [AFMT_TTA] = |
184 | AFMT_ENTRY("TTA", "tta", NULL, "tta\0" ), | 201 | AFMT_ENTRY("TTA", "tta", NULL, get_tta_metadata, "tta\0"), |
185 | /* WMA Voice in ASF */ | 202 | /* WMA Voice in ASF */ |
186 | [AFMT_WMAVOICE] = | 203 | [AFMT_WMAVOICE] = |
187 | AFMT_ENTRY("WMAVoice", "wmavoice", NULL, "wma\0wmv\0asf\0" ), | 204 | AFMT_ENTRY("WMAVoice","wmavoice",NULL, NULL, "wma\0wmv\0"), |
188 | #endif | 205 | #endif |
189 | }; | 206 | }; |
190 | 207 | ||
@@ -261,7 +278,7 @@ bool mp3info(struct mp3entry *entry, const char *filename) | |||
261 | if (fd < 0) | 278 | if (fd < 0) |
262 | return true; | 279 | return true; |
263 | 280 | ||
264 | result = !get_mp3_metadata(fd, entry, filename); | 281 | result = !get_mp3_metadata(fd, entry); |
265 | 282 | ||
266 | close(fd); | 283 | close(fd); |
267 | 284 | ||
@@ -273,255 +290,30 @@ bool mp3info(struct mp3entry *entry, const char *filename) | |||
273 | */ | 290 | */ |
274 | bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) | 291 | bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) |
275 | { | 292 | { |
293 | const struct afmt_entry *entry; | ||
276 | /* Clear the mp3entry to avoid having bogus pointers appear */ | 294 | /* Clear the mp3entry to avoid having bogus pointers appear */ |
277 | memset(id3, 0, sizeof(struct mp3entry)); | 295 | memset(id3, 0, sizeof(struct mp3entry)); |
278 | 296 | ||
279 | /* Take our best guess at the codec type based on file extension */ | 297 | /* Take our best guess at the codec type based on file extension */ |
280 | id3->codectype = probe_file_format(trackname); | 298 | id3->codectype = probe_file_format(trackname); |
281 | 299 | ||
300 | entry = &audio_formats[id3->codectype]; | ||
301 | |||
282 | /* Load codec specific track tag information and confirm the codec type. */ | 302 | /* Load codec specific track tag information and confirm the codec type. */ |
283 | switch (id3->codectype) | 303 | if (!entry->parse_func) |
284 | { | 304 | { |
285 | case AFMT_MPA_L1: | 305 | DEBUGF("nothing to parse for %s (format %s)", trackname, entry->label); |
286 | case AFMT_MPA_L2: | 306 | return false; |
287 | case AFMT_MPA_L3: | 307 | } |
288 | if (!get_mp3_metadata(fd, id3, trackname)) | ||
289 | { | ||
290 | return false; | ||
291 | } | ||
292 | |||
293 | break; | ||
294 | |||
295 | #if CONFIG_CODEC == SWCODEC | ||
296 | case AFMT_FLAC: | ||
297 | if (!get_flac_metadata(fd, id3)) | ||
298 | { | ||
299 | return false; | ||
300 | } | ||
301 | |||
302 | break; | ||
303 | |||
304 | case AFMT_WMA: | ||
305 | if (!get_asf_metadata(fd, id3)) | ||
306 | { | ||
307 | return false; | ||
308 | } | ||
309 | break; | ||
310 | |||
311 | case AFMT_APE: | ||
312 | if (!get_monkeys_metadata(fd, id3)) | ||
313 | { | ||
314 | return false; | ||
315 | } | ||
316 | read_ape_tags(fd, id3); | ||
317 | break; | ||
318 | |||
319 | case AFMT_MPC: | ||
320 | if (!get_musepack_metadata(fd, id3)) | ||
321 | return false; | ||
322 | read_ape_tags(fd, id3); | ||
323 | break; | ||
324 | |||
325 | case AFMT_OGG_VORBIS: | ||
326 | case AFMT_SPEEX: | ||
327 | if (!get_ogg_metadata(fd, id3))/*detects and handles Ogg/Speex files*/ | ||
328 | { | ||
329 | return false; | ||
330 | } | ||
331 | |||
332 | break; | ||
333 | |||
334 | case AFMT_PCM_WAV: | ||
335 | if (!get_wave_metadata(fd, id3)) | ||
336 | { | ||
337 | return false; | ||
338 | } | ||
339 | |||
340 | break; | ||
341 | |||
342 | case AFMT_WAVPACK: | ||
343 | if (!get_wavpack_metadata(fd, id3)) | ||
344 | { | ||
345 | return false; | ||
346 | } | ||
347 | |||
348 | read_ape_tags(fd, id3); /* use any apetag info we find */ | ||
349 | break; | ||
350 | |||
351 | case AFMT_A52: | ||
352 | if (!get_a52_metadata(fd, id3)) | ||
353 | { | ||
354 | return false; | ||
355 | } | ||
356 | |||
357 | break; | ||
358 | |||
359 | case AFMT_MP4_ALAC: | ||
360 | case AFMT_MP4_AAC: | ||
361 | if (!get_mp4_metadata(fd, id3)) | ||
362 | { | ||
363 | return false; | ||
364 | } | ||
365 | |||
366 | break; | ||
367 | |||
368 | case AFMT_MOD: | ||
369 | if (!get_mod_metadata(fd, id3)) | ||
370 | { | ||
371 | return false; | ||
372 | } | ||
373 | |||
374 | break; | ||
375 | |||
376 | case AFMT_SHN: | ||
377 | id3->vbr = true; | ||
378 | id3->filesize = filesize(fd); | ||
379 | if (!skip_id3v2(fd, id3)) | ||
380 | { | ||
381 | return false; | ||
382 | } | ||
383 | /* TODO: read the id3v2 header if it exists */ | ||
384 | break; | ||
385 | |||
386 | case AFMT_SID: | ||
387 | if (!get_sid_metadata(fd, id3)) | ||
388 | { | ||
389 | return false; | ||
390 | } | ||
391 | break; | ||
392 | |||
393 | case AFMT_SPC: | ||
394 | if (!get_spc_metadata(fd, id3)) | ||
395 | { | ||
396 | DEBUGF("get_spc_metadata error\n"); | ||
397 | return false; | ||
398 | } | ||
399 | id3->filesize = filesize(fd); | ||
400 | id3->genre_string = id3_get_num_genre(36); | ||
401 | break; | ||
402 | |||
403 | case AFMT_ADX: | ||
404 | if (!get_adx_metadata(fd, id3)) | ||
405 | { | ||
406 | DEBUGF("get_adx_metadata error\n"); | ||
407 | return false; | ||
408 | } | ||
409 | |||
410 | break; | ||
411 | |||
412 | case AFMT_NSF: | ||
413 | if (!get_nsf_metadata(fd, id3)) | ||
414 | { | ||
415 | DEBUGF("get_nsf_metadata error\n"); | ||
416 | return false; | ||
417 | } | ||
418 | break; | ||
419 | |||
420 | case AFMT_AIFF: | ||
421 | if (!get_aiff_metadata(fd, id3)) | ||
422 | { | ||
423 | return false; | ||
424 | } | ||
425 | |||
426 | break; | ||
427 | |||
428 | case AFMT_SAP: | ||
429 | if (!get_asap_metadata(fd, id3)) | ||
430 | { | ||
431 | DEBUGF("get_sap_metadata error\n"); | ||
432 | return false; | ||
433 | } | ||
434 | id3->filesize = filesize(fd); | ||
435 | id3->genre_string = id3_get_num_genre(36); | ||
436 | break; | ||
437 | |||
438 | case AFMT_CMC: | ||
439 | case AFMT_CM3: | ||
440 | case AFMT_CMR: | ||
441 | case AFMT_CMS: | ||
442 | case AFMT_DMC: | ||
443 | case AFMT_DLT: | ||
444 | case AFMT_MPT: | ||
445 | case AFMT_MPD: | ||
446 | case AFMT_RMT: | ||
447 | case AFMT_TMC: | ||
448 | case AFMT_TM8: | ||
449 | case AFMT_TM2: | ||
450 | id3->bitrate = 706; | ||
451 | id3->frequency = 44100; | ||
452 | id3->vbr = false; | ||
453 | id3->filesize = filesize(fd); | ||
454 | id3->genre_string = id3_get_num_genre(36); | ||
455 | break; | ||
456 | case AFMT_RM_COOK: | ||
457 | if (!get_rm_metadata(fd, id3)) | ||
458 | { | ||
459 | DEBUGF("get_rm_metadata error\n"); | ||
460 | return false; | ||
461 | } | ||
462 | break; | ||
463 | case AFMT_OMA_ATRAC3: | ||
464 | if (!get_oma_metadata(fd, id3)) | ||
465 | { | ||
466 | DEBUGF("get_oma_metadata error\n"); | ||
467 | return false; | ||
468 | } | ||
469 | break; | ||
470 | |||
471 | case AFMT_SMAF: | ||
472 | if (!get_smaf_metadata(fd, id3)) | ||
473 | { | ||
474 | DEBUGF("get_smaf_metadata error\n"); | ||
475 | return false; | ||
476 | } | ||
477 | break; | ||
478 | 308 | ||
479 | case AFMT_AU: | 309 | if (!entry->parse_func(fd, id3)) |
480 | if (!get_au_metadata(fd, id3)) | 310 | { |
481 | { | 311 | DEBUGF("parsing %s failed (format: %s)", trackname, entry->label); |
482 | DEBUGF("get_au_metadata error\n"); | ||
483 | return false; | ||
484 | } | ||
485 | break; | ||
486 | |||
487 | case AFMT_VOX: | ||
488 | if (!get_vox_metadata(fd, id3)) | ||
489 | { | ||
490 | DEBUGF("get_vox_metadata error\n"); | ||
491 | return false; | ||
492 | } | ||
493 | break; | ||
494 | |||
495 | case AFMT_WAVE64: | ||
496 | if (!get_wave64_metadata(fd, id3)) | ||
497 | { | ||
498 | DEBUGF("get_wave64_metadata error\n"); | ||
499 | return false; | ||
500 | } | ||
501 | break; | ||
502 | |||
503 | case AFMT_TTA: | ||
504 | if (!get_tta_metadata(fd, id3)) | ||
505 | { | ||
506 | DEBUGF("get_tta_metadata error\n"); | ||
507 | return false; | ||
508 | } | ||
509 | break; | ||
510 | |||
511 | #endif /* CONFIG_CODEC == SWCODEC */ | ||
512 | |||
513 | default: | ||
514 | /* If we don't know how to read the metadata, assume we can't play | ||
515 | the file */ | ||
516 | return false; | 312 | return false; |
517 | break; | ||
518 | } | 313 | } |
519 | 314 | ||
520 | /* We have successfully read the metadata from the file */ | ||
521 | |||
522 | lseek(fd, 0, SEEK_SET); | ||
523 | strlcpy(id3->path, trackname, sizeof(id3->path)); | 315 | strlcpy(id3->path, trackname, sizeof(id3->path)); |
524 | 316 | /* We have successfully read the metadata from the file */ | |
525 | return true; | 317 | return true; |
526 | } | 318 | } |
527 | 319 | ||