summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/id3.h31
-rw-r--r--firmware/id3.c48
2 files changed, 79 insertions, 0 deletions
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 */
27enum {
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
24struct mp3entry { 53struct 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
77bool mp3info(struct mp3entry *entry, const char *filename, bool v1first); 107bool mp3info(struct mp3entry *entry, const char *filename, bool v1first);
78char* id3_get_genre(const struct mp3entry* id3); 108char* id3_get_genre(const struct mp3entry* id3);
109char* 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
81static 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
80char* id3_get_genre(const struct mp3entry* id3) 106char* 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
116char* 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 */