summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/id3.h2
-rw-r--r--firmware/export/mpeg.h1
-rw-r--r--firmware/id3.c22
-rw-r--r--firmware/mpeg.c15
4 files changed, 25 insertions, 15 deletions
diff --git a/firmware/export/id3.h b/firmware/export/id3.h
index 6e53e4c66c..10f8002db6 100644
--- a/firmware/export/id3.h
+++ b/firmware/export/id3.h
@@ -74,7 +74,7 @@ enum {
74 ID3_VER_2_4 74 ID3_VER_2_4
75}; 75};
76 76
77bool mp3info(struct mp3entry *entry, char *filename); 77bool mp3info(struct mp3entry *entry, char *filename, bool v1first);
78char* id3_get_genre(struct mp3entry* id3); 78char* id3_get_genre(struct mp3entry* id3);
79 79
80#endif 80#endif
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
index 252e509c94..51932c5090 100644
--- a/firmware/export/mpeg.h
+++ b/firmware/export/mpeg.h
@@ -96,6 +96,7 @@ void mpeg_error_clear(void);
96/* in order to keep the recording here, I have to expose this */ 96/* in order to keep the recording here, I have to expose this */
97void rec_tick(void); 97void rec_tick(void);
98void playback_tick(void); /* FixMe: get rid of this, use mp3_get_playtime() */ 98void playback_tick(void); /* FixMe: get rid of this, use mp3_get_playtime() */
99void mpeg_id3_options(bool _v1first);
99 100
100#define MPEG_STATUS_PLAY 1 101#define MPEG_STATUS_PLAY 1
101#define MPEG_STATUS_PAUSE 2 102#define MPEG_STATUS_PAUSE 2
diff --git a/firmware/id3.c b/firmware/id3.c
index 70add41b6b..03c37c027e 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -798,13 +798,12 @@ static int getsonglength(int fd, struct mp3entry *entry)
798 * Checks all relevant information (such as ID3v1 tag, ID3v2 tag, length etc) 798 * Checks all relevant information (such as ID3v1 tag, ID3v2 tag, length etc)
799 * about an MP3 file and updates it's entry accordingly. 799 * about an MP3 file and updates it's entry accordingly.
800 * 800 *
801 * Arguments: entry - the entry to check and update with the new information
802 *
803 * Returns: void
804 */ 801 */
805bool mp3info(struct mp3entry *entry, char *filename) 802bool mp3info(struct mp3entry *entry, char *filename, bool v1first)
806{ 803{
807 int fd; 804 int fd;
805 int v1found = false;
806
808 fd = open(filename, O_RDONLY); 807 fd = open(filename, O_RDONLY);
809 if(-1 == fd) 808 if(-1 == fd)
810 return true; 809 return true;
@@ -819,7 +818,10 @@ bool mp3info(struct mp3entry *entry, char *filename)
819 entry->tracknum = 0; 818 entry->tracknum = 0;
820 entry->genre = 0xff; 819 entry->genre = 0xff;
821 820
822 if (entry->id3v2len) 821 if(v1first)
822 v1found = setid3v1title(fd, entry);
823
824 if (!v1found && entry->id3v2len)
823 setid3v2title(fd, entry); 825 setid3v2title(fd, entry);
824 entry->length = getsonglength(fd, entry); 826 entry->length = getsonglength(fd, entry);
825 827
@@ -827,10 +829,10 @@ bool mp3info(struct mp3entry *entry, char *filename)
827 the true size of the MP3 stream */ 829 the true size of the MP3 stream */
828 entry->filesize -= entry->first_frame_offset; 830 entry->filesize -= entry->first_frame_offset;
829 831
830 /* only seek to end of file if no id3v2 tags were found */ 832 /* only seek to end of file if no id3v2 tags were found,
831 if (!entry->id3v2len) { 833 and we already haven't looked for a v1 tag */
832 if(!entry->title) 834 if (!v1first && !entry->id3v2len) {
833 setid3v1title(fd, entry); 835 setid3v1title(fd, entry);
834 } 836 }
835 837
836 close(fd); 838 close(fd);
@@ -860,7 +862,7 @@ int main(int argc, char **argv)
860 for(i=1; i<argc; i++) { 862 for(i=1; i<argc; i++) {
861 struct mp3entry mp3; 863 struct mp3entry mp3;
862 mp3.album = "Bogus"; 864 mp3.album = "Bogus";
863 if(mp3info(&mp3, argv[i])) { 865 if(mp3info(&mp3, argv[i], false)) {
864 printf("Failed to get %s\n", argv[i]); 866 printf("Failed to get %s\n", argv[i]);
865 return 0; 867 return 0;
866 } 868 }
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 8f0612c693..a54866e0c2 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -107,6 +107,8 @@ struct id3tag
107static struct id3tag *id3tags[MAX_ID3_TAGS]; 107static struct id3tag *id3tags[MAX_ID3_TAGS];
108static struct id3tag _id3tags[MAX_ID3_TAGS]; 108static struct id3tag _id3tags[MAX_ID3_TAGS];
109 109
110static bool v1first = false;
111
110static unsigned int current_track_counter = 0; 112static unsigned int current_track_counter = 0;
111static unsigned int last_track_counter = 0; 113static unsigned int last_track_counter = 0;
112 114
@@ -736,7 +738,7 @@ static int add_track_to_tag_list(char *filename)
736 { 738 {
737 /* grab id3 tag of new file and 739 /* grab id3 tag of new file and
738 remember where in memory it starts */ 740 remember where in memory it starts */
739 if(mp3info(&(t->id3), filename)) 741 if(mp3info(&(t->id3), filename, v1first))
740 { 742 {
741 DEBUGF("Bad mp3\n"); 743 DEBUGF("Bad mp3\n");
742 return -1; 744 return -1;
@@ -1985,6 +1987,11 @@ static void mpeg_thread(void)
1985static struct mp3entry taginfo; 1987static struct mp3entry taginfo;
1986#endif /* #ifdef SIMULATOR */ 1988#endif /* #ifdef SIMULATOR */
1987 1989
1990void mpeg_id3_options(bool _v1first)
1991{
1992 v1first = _v1first;
1993}
1994
1988struct mp3entry* mpeg_current_track() 1995struct mp3entry* mpeg_current_track()
1989{ 1996{
1990#ifdef SIMULATOR 1997#ifdef SIMULATOR
@@ -2443,7 +2450,7 @@ void mpeg_play(int offset)
2443 trackname = playlist_peek( steps ); 2450 trackname = playlist_peek( steps );
2444 if (!trackname) 2451 if (!trackname)
2445 break; 2452 break;
2446 if(mp3info(&taginfo, trackname)) { 2453 if(mp3info(&taginfo, trackname, v1first)) {
2447 /* bad mp3, move on */ 2454 /* bad mp3, move on */
2448 if(++steps > playlist_amount()) 2455 if(++steps > playlist_amount())
2449 break; 2456 break;
@@ -2518,7 +2525,7 @@ void mpeg_next(void)
2518 file = playlist_peek(steps); 2525 file = playlist_peek(steps);
2519 if(!file) 2526 if(!file)
2520 break; 2527 break;
2521 if(mp3info(&taginfo, file)) { 2528 if(mp3info(&taginfo, file, v1first)) {
2522 if(++steps > playlist_amount()) 2529 if(++steps > playlist_amount())
2523 break; 2530 break;
2524 continue; 2531 continue;
@@ -2546,7 +2553,7 @@ void mpeg_prev(void)
2546 file = playlist_peek(steps); 2553 file = playlist_peek(steps);
2547 if(!file) 2554 if(!file)
2548 break; 2555 break;
2549 if(mp3info(&taginfo, file)) { 2556 if(mp3info(&taginfo, file, v1first)) {
2550 steps--; 2557 steps--;
2551 continue; 2558 continue;
2552 } 2559 }