diff options
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index a85545efce..f9df3236f2 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "id3.h" | 23 | #include "id3.h" |
24 | #include "mpeg.h" | 24 | #include "mpeg.h" |
25 | #include "ata.h" | 25 | #include "ata.h" |
26 | #include "malloc.h" | ||
27 | #include "string.h" | 26 | #include "string.h" |
28 | #ifndef SIMULATOR | 27 | #ifndef SIMULATOR |
29 | #include "i2c.h" | 28 | #include "i2c.h" |
@@ -147,9 +146,11 @@ struct id3tag | |||
147 | { | 146 | { |
148 | struct mp3entry id3; | 147 | struct mp3entry id3; |
149 | int mempos; | 148 | int mempos; |
149 | bool used; | ||
150 | }; | 150 | }; |
151 | 151 | ||
152 | static struct id3tag *id3tags[MAX_ID3_TAGS]; | 152 | static struct id3tag *id3tags[MAX_ID3_TAGS]; |
153 | static struct id3tag _id3tags[MAX_ID3_TAGS]; | ||
153 | 154 | ||
154 | static unsigned int current_track_counter = 0; | 155 | static unsigned int current_track_counter = 0; |
155 | static unsigned int last_track_counter = 0; | 156 | static unsigned int last_track_counter = 0; |
@@ -202,7 +203,6 @@ static bool append_tag(struct id3tag *tag) | |||
202 | static void remove_current_tag(void) | 203 | static void remove_current_tag(void) |
203 | { | 204 | { |
204 | int oldidx = tag_read_idx; | 205 | int oldidx = tag_read_idx; |
205 | struct id3tag *tag = id3tags[tag_read_idx]; | ||
206 | 206 | ||
207 | if(num_tracks_in_memory() > 0) | 207 | if(num_tracks_in_memory() > 0) |
208 | { | 208 | { |
@@ -210,8 +210,8 @@ static void remove_current_tag(void) | |||
210 | tag_read_idx = (tag_read_idx+1) & MAX_ID3_TAGS_MASK; | 210 | tag_read_idx = (tag_read_idx+1) & MAX_ID3_TAGS_MASK; |
211 | 211 | ||
212 | /* Now delete it */ | 212 | /* Now delete it */ |
213 | id3tags[oldidx]->used = false; | ||
213 | id3tags[oldidx] = NULL; | 214 | id3tags[oldidx] = NULL; |
214 | free(tag); | ||
215 | debug_tags(); | 215 | debug_tags(); |
216 | } | 216 | } |
217 | } | 217 | } |
@@ -578,21 +578,26 @@ void IMIA1(void) | |||
578 | 578 | ||
579 | static void add_track_to_tag_list(char *filename) | 579 | static void add_track_to_tag_list(char *filename) |
580 | { | 580 | { |
581 | struct id3tag *t; | 581 | struct id3tag *t = NULL; |
582 | int i; | ||
582 | 583 | ||
583 | /* grab id3 tag of new file and | 584 | /* find a free tag */ |
584 | remember where in memory it starts */ | 585 | for (i=0; i < MAX_ID3_TAGS_MASK; i++ ) |
585 | t = malloc(sizeof(struct id3tag)); | 586 | if ( !_id3tags[i].used ) |
587 | t = &_id3tags[i]; | ||
586 | if(t) | 588 | if(t) |
587 | { | 589 | { |
590 | /* grab id3 tag of new file and | ||
591 | remember where in memory it starts */ | ||
588 | mp3info(&(t->id3), filename); | 592 | mp3info(&(t->id3), filename); |
589 | t->mempos = mp3buf_write; | 593 | t->mempos = mp3buf_write; |
590 | t->id3.elapsed = 0; | 594 | t->id3.elapsed = 0; |
591 | if(!append_tag(t)) | 595 | if(!append_tag(t)) |
592 | { | 596 | { |
593 | free(t); | ||
594 | DEBUGF("Tag list is full\n"); | 597 | DEBUGF("Tag list is full\n"); |
595 | } | 598 | } |
599 | else | ||
600 | t->used = true; | ||
596 | } | 601 | } |
597 | else | 602 | else |
598 | { | 603 | { |
@@ -659,7 +664,7 @@ static void mpeg_thread(void) | |||
659 | int amount_to_read; | 664 | int amount_to_read; |
660 | int amount_to_swap; | 665 | int amount_to_swap; |
661 | int t1, t2; | 666 | int t1, t2; |
662 | 667 | ||
663 | play_pending = false; | 668 | play_pending = false; |
664 | playing = false; | 669 | playing = false; |
665 | mpeg_file = -1; | 670 | mpeg_file = -1; |
@@ -1411,4 +1416,5 @@ void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost, i | |||
1411 | #endif /* !SIMULATOR */ | 1416 | #endif /* !SIMULATOR */ |
1412 | 1417 | ||
1413 | memset(id3tags, sizeof(id3tags), 0); | 1418 | memset(id3tags, sizeof(id3tags), 0); |
1419 | memset(_id3tags, sizeof(id3tags), 0); | ||
1414 | } | 1420 | } |