diff options
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index a4632aae38..c09ef38376 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -118,8 +118,8 @@ static int track_write_idx = 0; | |||
118 | 118 | ||
119 | /* Callback function to call when current track has really changed. */ | 119 | /* Callback function to call when current track has really changed. */ |
120 | void (*track_changed_callback)(struct mp3entry *id3) = NULL; | 120 | void (*track_changed_callback)(struct mp3entry *id3) = NULL; |
121 | void (*track_buffer_callback)(struct mp3entry *id3, bool last_track); | 121 | void (*track_buffer_callback)(struct mp3entry *id3); |
122 | void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track); | 122 | void (*track_unbuffer_callback)(struct mp3entry *id3); |
123 | 123 | ||
124 | /* Cuesheet callback */ | 124 | /* Cuesheet callback */ |
125 | static bool (*cuesheet_callback)(const char *filename) = NULL; | 125 | static bool (*cuesheet_callback)(const char *filename) = NULL; |
@@ -475,14 +475,12 @@ unsigned long mpeg_get_last_header(void) | |||
475 | #endif /* !SIMULATOR */ | 475 | #endif /* !SIMULATOR */ |
476 | } | 476 | } |
477 | 477 | ||
478 | void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3, | 478 | void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3)) |
479 | bool last_track)) | ||
480 | { | 479 | { |
481 | track_buffer_callback = handler; | 480 | track_buffer_callback = handler; |
482 | } | 481 | } |
483 | 482 | ||
484 | void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3, | 483 | void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3)) |
485 | bool last_track)) | ||
486 | { | 484 | { |
487 | track_unbuffer_callback = handler; | 485 | track_unbuffer_callback = handler; |
488 | } | 486 | } |
@@ -502,29 +500,16 @@ void audio_set_cuesheet_callback(bool (*handler)(const char *filename)) | |||
502 | static void generate_unbuffer_events(void) | 500 | static void generate_unbuffer_events(void) |
503 | { | 501 | { |
504 | int i; | 502 | int i; |
505 | int event_count = 0; | ||
506 | int numentries = MAX_TRACK_ENTRIES - num_tracks_in_memory(); | 503 | int numentries = MAX_TRACK_ENTRIES - num_tracks_in_memory(); |
507 | int cur_idx = track_write_idx; | 504 | int cur_idx = track_write_idx; |
508 | |||
509 | for (i = 0; i < numentries; i++) | ||
510 | { | ||
511 | if (trackdata[cur_idx].event_sent) | ||
512 | event_count++; | ||
513 | |||
514 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; | ||
515 | } | ||
516 | |||
517 | cur_idx = track_write_idx; | ||
518 | 505 | ||
519 | for (i = 0; i < numentries; i++) | 506 | for (i = 0; i < numentries; i++) |
520 | { | 507 | { |
521 | /* Send an event to notify that track has finished. */ | 508 | /* Send an event to notify that track has finished. */ |
522 | if (trackdata[cur_idx].event_sent) | 509 | if (trackdata[cur_idx].event_sent) |
523 | { | 510 | { |
524 | event_count--; | ||
525 | if (track_unbuffer_callback) | 511 | if (track_unbuffer_callback) |
526 | track_unbuffer_callback(&trackdata[cur_idx].id3, | 512 | track_unbuffer_callback(&trackdata[cur_idx].id3); |
527 | event_count == 0); | ||
528 | trackdata[cur_idx].event_sent = false; | 513 | trackdata[cur_idx].event_sent = false; |
529 | } | 514 | } |
530 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; | 515 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; |
@@ -535,28 +520,15 @@ static void generate_unbuffer_events(void) | |||
535 | static void generate_postbuffer_events(void) | 520 | static void generate_postbuffer_events(void) |
536 | { | 521 | { |
537 | int i; | 522 | int i; |
538 | int event_count = 0; | ||
539 | int numentries = num_tracks_in_memory(); | 523 | int numentries = num_tracks_in_memory(); |
540 | int cur_idx = track_read_idx; | 524 | int cur_idx = track_read_idx; |
541 | 525 | ||
542 | for (i = 0; i < numentries; i++) | 526 | for (i = 0; i < numentries; i++) |
543 | { | 527 | { |
544 | if (!trackdata[cur_idx].event_sent) | 528 | if (!trackdata[cur_idx].event_sent) |
545 | event_count++; | ||
546 | |||
547 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; | ||
548 | } | ||
549 | |||
550 | cur_idx = track_read_idx; | ||
551 | |||
552 | for (i = 0; i < numentries; i++) | ||
553 | { | ||
554 | if (!trackdata[cur_idx].event_sent) | ||
555 | { | 529 | { |
556 | event_count--; | ||
557 | if (track_buffer_callback) | 530 | if (track_buffer_callback) |
558 | track_buffer_callback(&trackdata[cur_idx].id3, | 531 | track_buffer_callback(&trackdata[cur_idx].id3); |
559 | event_count == 0); | ||
560 | trackdata[cur_idx].event_sent = true; | 532 | trackdata[cur_idx].event_sent = true; |
561 | } | 533 | } |
562 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; | 534 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; |