diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2008-03-16 13:55:16 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2008-03-16 13:55:16 +0000 |
commit | 19c6e66c1353993659ee007a6c1792a6b0b7ba13 (patch) | |
tree | 1dd7f88282b2e543fb5b22458fcb2f3bf1c7eb80 /firmware/mpeg.c | |
parent | 478ba0afa11061a620e44cd9cc60debd955b1b33 (diff) | |
download | rockbox-19c6e66c1353993659ee007a6c1792a6b0b7ba13.tar.gz rockbox-19c6e66c1353993659ee007a6c1792a6b0b7ba13.zip |
Implement the playback event handling as a system-wide multi-purpose event system. Unified mpeg.c and playback.c audio event handling. Converted ata_idle_notify to use the new event handling system also.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16682 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 693e2df480..9023c304d2 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -100,7 +100,6 @@ struct trackdata | |||
100 | struct mp3entry id3; | 100 | struct mp3entry id3; |
101 | int mempos; | 101 | int mempos; |
102 | int load_ahead_index; | 102 | int load_ahead_index; |
103 | bool event_sent; | ||
104 | }; | 103 | }; |
105 | 104 | ||
106 | static struct trackdata trackdata[MAX_TRACK_ENTRIES]; | 105 | static struct trackdata trackdata[MAX_TRACK_ENTRIES]; |
@@ -116,11 +115,6 @@ static int track_read_idx = 0; | |||
116 | static int track_write_idx = 0; | 115 | static int track_write_idx = 0; |
117 | #endif /* !SIMULATOR */ | 116 | #endif /* !SIMULATOR */ |
118 | 117 | ||
119 | /* Callback function to call when current track has really changed. */ | ||
120 | void (*track_changed_callback)(struct mp3entry *id3) = NULL; | ||
121 | void (*track_buffer_callback)(struct mp3entry *id3) = NULL; | ||
122 | void (*track_unbuffer_callback)(struct mp3entry *id3) = NULL; | ||
123 | |||
124 | /* Cuesheet callback */ | 118 | /* Cuesheet callback */ |
125 | static bool (*cuesheet_callback)(const char *filename) = NULL; | 119 | static bool (*cuesheet_callback)(const char *filename) = NULL; |
126 | 120 | ||
@@ -475,21 +469,6 @@ unsigned long mpeg_get_last_header(void) | |||
475 | #endif /* !SIMULATOR */ | 469 | #endif /* !SIMULATOR */ |
476 | } | 470 | } |
477 | 471 | ||
478 | void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3)) | ||
479 | { | ||
480 | track_buffer_callback = handler; | ||
481 | } | ||
482 | |||
483 | void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3)) | ||
484 | { | ||
485 | track_unbuffer_callback = handler; | ||
486 | } | ||
487 | |||
488 | void audio_set_track_changed_event(void (*handler)(struct mp3entry *id3)) | ||
489 | { | ||
490 | track_changed_callback = handler; | ||
491 | } | ||
492 | |||
493 | void audio_set_cuesheet_callback(bool (*handler)(const char *filename)) | 472 | void audio_set_cuesheet_callback(bool (*handler)(const char *filename)) |
494 | { | 473 | { |
495 | cuesheet_callback = handler; | 474 | cuesheet_callback = handler; |
@@ -506,12 +485,7 @@ static void generate_unbuffer_events(void) | |||
506 | for (i = 0; i < numentries; i++) | 485 | for (i = 0; i < numentries; i++) |
507 | { | 486 | { |
508 | /* Send an event to notify that track has finished. */ | 487 | /* Send an event to notify that track has finished. */ |
509 | if (trackdata[cur_idx].event_sent) | 488 | send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &trackdata[cur_idx].id3); |
510 | { | ||
511 | if (track_unbuffer_callback) | ||
512 | track_unbuffer_callback(&trackdata[cur_idx].id3); | ||
513 | trackdata[cur_idx].event_sent = false; | ||
514 | } | ||
515 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; | 489 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; |
516 | } | 490 | } |
517 | } | 491 | } |
@@ -525,12 +499,7 @@ static void generate_postbuffer_events(void) | |||
525 | 499 | ||
526 | for (i = 0; i < numentries; i++) | 500 | for (i = 0; i < numentries; i++) |
527 | { | 501 | { |
528 | if (!trackdata[cur_idx].event_sent) | 502 | send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &trackdata[cur_idx].id3); |
529 | { | ||
530 | if (track_buffer_callback) | ||
531 | track_buffer_callback(&trackdata[cur_idx].id3); | ||
532 | trackdata[cur_idx].event_sent = true; | ||
533 | } | ||
534 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; | 503 | cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; |
535 | } | 504 | } |
536 | } | 505 | } |
@@ -1080,8 +1049,7 @@ static void track_change(void) | |||
1080 | if (num_tracks_in_memory() > 0) | 1049 | if (num_tracks_in_memory() > 0) |
1081 | { | 1050 | { |
1082 | remove_current_tag(); | 1051 | remove_current_tag(); |
1083 | if (track_changed_callback) | 1052 | send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track()); |
1084 | track_changed_callback(audio_current_track()); | ||
1085 | update_playlist(); | 1053 | update_playlist(); |
1086 | } | 1054 | } |
1087 | 1055 | ||
@@ -1134,8 +1102,7 @@ static void start_playback_if_ready(void) | |||
1134 | if (play_pending_track_change) | 1102 | if (play_pending_track_change) |
1135 | { | 1103 | { |
1136 | play_pending_track_change = false; | 1104 | play_pending_track_change = false; |
1137 | if(track_changed_callback) | 1105 | send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track()); |
1138 | track_changed_callback(audio_current_track()); | ||
1139 | } | 1106 | } |
1140 | play_pending = false; | 1107 | play_pending = false; |
1141 | } | 1108 | } |