From 19c6e66c1353993659ee007a6c1792a6b0b7ba13 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sun, 16 Mar 2008 13:55:16 +0000 Subject: 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 --- firmware/mpeg.c | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) (limited to 'firmware/mpeg.c') 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 struct mp3entry id3; int mempos; int load_ahead_index; - bool event_sent; }; static struct trackdata trackdata[MAX_TRACK_ENTRIES]; @@ -116,11 +115,6 @@ static int track_read_idx = 0; static int track_write_idx = 0; #endif /* !SIMULATOR */ -/* Callback function to call when current track has really changed. */ -void (*track_changed_callback)(struct mp3entry *id3) = NULL; -void (*track_buffer_callback)(struct mp3entry *id3) = NULL; -void (*track_unbuffer_callback)(struct mp3entry *id3) = NULL; - /* Cuesheet callback */ static bool (*cuesheet_callback)(const char *filename) = NULL; @@ -475,21 +469,6 @@ unsigned long mpeg_get_last_header(void) #endif /* !SIMULATOR */ } -void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3)) -{ - track_buffer_callback = handler; -} - -void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3)) -{ - track_unbuffer_callback = handler; -} - -void audio_set_track_changed_event(void (*handler)(struct mp3entry *id3)) -{ - track_changed_callback = handler; -} - void audio_set_cuesheet_callback(bool (*handler)(const char *filename)) { cuesheet_callback = handler; @@ -506,12 +485,7 @@ static void generate_unbuffer_events(void) for (i = 0; i < numentries; i++) { /* Send an event to notify that track has finished. */ - if (trackdata[cur_idx].event_sent) - { - if (track_unbuffer_callback) - track_unbuffer_callback(&trackdata[cur_idx].id3); - trackdata[cur_idx].event_sent = false; - } + send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &trackdata[cur_idx].id3); cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; } } @@ -525,12 +499,7 @@ static void generate_postbuffer_events(void) for (i = 0; i < numentries; i++) { - if (!trackdata[cur_idx].event_sent) - { - if (track_buffer_callback) - track_buffer_callback(&trackdata[cur_idx].id3); - trackdata[cur_idx].event_sent = true; - } + send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &trackdata[cur_idx].id3); cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK; } } @@ -1080,8 +1049,7 @@ static void track_change(void) if (num_tracks_in_memory() > 0) { remove_current_tag(); - if (track_changed_callback) - track_changed_callback(audio_current_track()); + send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track()); update_playlist(); } @@ -1134,8 +1102,7 @@ static void start_playback_if_ready(void) if (play_pending_track_change) { play_pending_track_change = false; - if(track_changed_callback) - track_changed_callback(audio_current_track()); + send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track()); } play_pending = false; } -- cgit v1.2.3