summaryrefslogtreecommitdiff
path: root/firmware/id3.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/id3.c')
-rw-r--r--firmware/id3.c48
1 files changed, 48 insertions, 0 deletions
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 */