diff options
author | Thomas Martitz <kugel@rockbox.org> | 2014-03-14 23:15:16 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-03-14 23:36:30 +0100 |
commit | 470989bd708d9a425dbbf2d83b8fcbd0a8d0f488 (patch) | |
tree | f3bef37bc0f8ff7da4beddad9903209ced1bc25a /apps/gui/wps.c | |
parent | 50f0dd80d660b332a1739e07a630c2cef1b678c6 (diff) | |
download | rockbox-470989bd708d9a425dbbf2d83b8fcbd0a8d0f488.tar.gz rockbox-470989bd708d9a425dbbf2d83b8fcbd0a8d0f488.zip |
events: Rework event subsystem (add_event, send_event) to be more versatile.
add_event_ex is added that takes an extra user_data pointer. This pointer is
passed to the callback (add_event and add_event_ex have slightly different
callbacks types). All callbacks also get the event id passed. Events added
with add_event_ex must be removed with remove_event_ex because the user_data
pointer must match in addition to the callback pointer.
On the other add_event is simplified to omit the oneshort parameter which
was almost always false (still there with add_event_ex).
As a side effect the ata_idle_notify callbacks are changed as well, they
do not take a data parameter anymore which was always NULL anyway.
This commit also adds some documentation to events.h
Change-Id: I13e29a0f88ef908f175b376d83550f9e0231f772
Diffstat (limited to 'apps/gui/wps.c')
-rw-r--r-- | apps/gui/wps.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index b4c3f40e9f..d1161ea71d 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c | |||
@@ -74,8 +74,7 @@ | |||
74 | 74 | ||
75 | /* initial setup of wps_data */ | 75 | /* initial setup of wps_data */ |
76 | static void wps_state_init(void); | 76 | static void wps_state_init(void); |
77 | static void track_changed_callback(void *param); | 77 | static void track_info_callback(unsigned short id, void *param); |
78 | static void nextid3available_callback(void* param); | ||
79 | 78 | ||
80 | #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" | 79 | #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" |
81 | #ifdef HAVE_REMOTE_LCD | 80 | #ifdef HAVE_REMOTE_LCD |
@@ -626,8 +625,9 @@ static void play_hop(int direction) | |||
626 | * we suppress updates until the wps is activated again (the lcd driver will | 625 | * we suppress updates until the wps is activated again (the lcd driver will |
627 | * call this hook to issue an instant update) | 626 | * call this hook to issue an instant update) |
628 | * */ | 627 | * */ |
629 | static void wps_lcd_activation_hook(void *param) | 628 | static void wps_lcd_activation_hook(unsigned short id, void *param) |
630 | { | 629 | { |
630 | (void)id; | ||
631 | (void)param; | 631 | (void)param; |
632 | skin_request_full_update(WPS); | 632 | skin_request_full_update(WPS); |
633 | /* force timeout in wps main loop, so that the update is instantly */ | 633 | /* force timeout in wps main loop, so that the update is instantly */ |
@@ -1119,7 +1119,7 @@ long gui_wps_show(void) | |||
1119 | restore = false; | 1119 | restore = false; |
1120 | restoretimer = RESTORE_WPS_INSTANTLY; | 1120 | restoretimer = RESTORE_WPS_INSTANTLY; |
1121 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | 1121 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) |
1122 | add_event(LCD_EVENT_ACTIVATION, false, wps_lcd_activation_hook); | 1122 | add_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook); |
1123 | #endif | 1123 | #endif |
1124 | /* we remove the update delay since it's not very usable in the wps, | 1124 | /* we remove the update delay since it's not very usable in the wps, |
1125 | * e.g. during volume changing or ffwd/rewind */ | 1125 | * e.g. during volume changing or ffwd/rewind */ |
@@ -1187,35 +1187,27 @@ long gui_wps_show(void) | |||
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | /* this is called from the playback thread so NO DRAWING! */ | 1189 | /* this is called from the playback thread so NO DRAWING! */ |
1190 | static void track_changed_callback(void *param) | 1190 | static void track_info_callback(unsigned short id, void *param) |
1191 | { | 1191 | { |
1192 | struct wps_state *state = skin_get_global_state(); | 1192 | struct wps_state *state = skin_get_global_state(); |
1193 | state->id3 = ((struct track_event *)param)->id3; | 1193 | |
1194 | state->nid3 = audio_next_track(); | 1194 | if (id == PLAYBACK_EVENT_TRACK_CHANGE || id == PLAYBACK_EVENT_CUR_TRACK_READY) |
1195 | if (state->id3->cuesheet) | ||
1196 | { | 1195 | { |
1197 | cue_find_current_track(state->id3->cuesheet, state->id3->elapsed); | 1196 | state->id3 = ((struct track_event *)param)->id3; |
1197 | if (state->id3->cuesheet) | ||
1198 | { | ||
1199 | cue_find_current_track(state->id3->cuesheet, state->id3->elapsed); | ||
1200 | } | ||
1198 | } | 1201 | } |
1199 | skin_request_full_update(WPS); | ||
1200 | } | ||
1201 | static void nextid3available_callback(void* param) | ||
1202 | { | ||
1203 | (void)param; | ||
1204 | skin_get_global_state()->nid3 = audio_next_track(); | ||
1205 | skin_request_full_update(WPS); | ||
1206 | } | ||
1207 | |||
1208 | #ifdef AUDIO_FAST_SKIP_PREVIEW | 1202 | #ifdef AUDIO_FAST_SKIP_PREVIEW |
1209 | /* this is called on the audio_skip caller thread */ | 1203 | else if (id == PLAYBACK_EVENT_TRACK_SKIP) |
1210 | static void track_skip_callback(void *param) | 1204 | { |
1211 | { | 1205 | state->id3 = audio_current_track(); |
1212 | struct wps_state *state = skin_get_global_state(); | 1206 | } |
1213 | state->id3 = audio_current_track(); | 1207 | #endif |
1214 | state->nid3 = audio_next_track(); | 1208 | skin_get_global_state()->nid3 = audio_next_track(); |
1215 | skin_request_full_update(WPS); | 1209 | skin_request_full_update(WPS); |
1216 | (void)param; | ||
1217 | } | 1210 | } |
1218 | #endif /* AUDIO_FAST_SKIP_PREVIEW */ | ||
1219 | 1211 | ||
1220 | static void wps_state_init(void) | 1212 | static void wps_state_init(void) |
1221 | { | 1213 | { |
@@ -1235,15 +1227,15 @@ static void wps_state_init(void) | |||
1235 | /* We'll be updating due to restore initialized with true */ | 1227 | /* We'll be updating due to restore initialized with true */ |
1236 | skin_request_full_update(WPS); | 1228 | skin_request_full_update(WPS); |
1237 | /* add the WPS track event callbacks */ | 1229 | /* add the WPS track event callbacks */ |
1238 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); | 1230 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, track_info_callback); |
1239 | add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); | 1231 | add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, track_info_callback); |
1240 | #if CONFIG_CODEC == SWCODEC | 1232 | #if CONFIG_CODEC == SWCODEC |
1241 | /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have | 1233 | /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have |
1242 | finished */ | 1234 | finished */ |
1243 | add_event(PLAYBACK_EVENT_CUR_TRACK_READY, false, track_changed_callback); | 1235 | add_event(PLAYBACK_EVENT_CUR_TRACK_READY, track_info_callback); |
1244 | #endif | 1236 | #endif |
1245 | #ifdef AUDIO_FAST_SKIP_PREVIEW | 1237 | #ifdef AUDIO_FAST_SKIP_PREVIEW |
1246 | add_event(PLAYBACK_EVENT_TRACK_SKIP, false, track_skip_callback); | 1238 | add_event(PLAYBACK_EVENT_TRACK_SKIP, track_info_callback); |
1247 | #endif | 1239 | #endif |
1248 | } | 1240 | } |
1249 | 1241 | ||