From 774bacc692b4d5c7b769bb88d24e182db9e4656f Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 20 Oct 2009 21:54:44 +0000 Subject: Correct wrong usage of event callbacks all over the place. It's not supposed to return anything, and should take a data parameter. Fixing it because correcting the event api prototypes causes many warnings. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23301 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 11 ++++++----- apps/playlist.c | 4 ++-- apps/plugin.h | 4 ++-- apps/plugins/battery_bench.c | 14 +++++--------- apps/scrobbler.c | 7 ++++--- apps/scrobbler.h | 8 ++++++-- apps/settings.c | 14 +++++++------- apps/tagcache.c | 11 +++++------ apps/tagtree.c | 6 ++++-- firmware/ata_idle_notify.c | 8 ++++---- firmware/events.c | 4 ++-- firmware/export/ata_idle_notify.h | 6 ++---- firmware/export/events.h | 4 ++-- 13 files changed, 51 insertions(+), 50 deletions(-) diff --git a/apps/playback.c b/apps/playback.c index 3fa42b9f94..7b614cd0d0 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1562,11 +1562,12 @@ static void buffering_handle_rebuffer_callback(void *data) queue_post(&audio_queue, Q_AUDIO_FLUSH, 0); } -static void buffering_handle_finished_callback(int *data) +static void buffering_handle_finished_callback(void *data) { logf("handle %d finished buffering", *data); + int hid = (*(int*)data); - if (*data == tracks[track_widx].id3_hid) + if (hid == tracks[track_widx].id3_hid) { int offset = ci.new_track + wps_offset; int next_idx = (track_ridx + offset + 1) & MAX_TRACK_MASK; @@ -1574,16 +1575,16 @@ static void buffering_handle_finished_callback(int *data) We can ask the audio thread to load the rest of the track's data. */ LOGFQUEUE("audio >| audio Q_AUDIO_FINISH_LOAD"); queue_post(&audio_queue, Q_AUDIO_FINISH_LOAD, 0); - if (tracks[next_idx].id3_hid == *data) + if (tracks[next_idx].id3_hid == hid) send_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, NULL); } else { /* This is most likely an audio handle, so we strip the useless trailing tags that are left. */ - strip_tags(*data); + strip_tags(hid); - if (*data == tracks[track_widx-1].audio_hid + if (hid == tracks[track_widx-1].audio_hid && filling == STATE_END_OF_PLAYLIST) { /* This was the last track in the playlist. diff --git a/apps/playlist.c b/apps/playlist.c index b70fdc8a1f..1e96ebf46b 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -1214,8 +1214,9 @@ static int compare(const void* p1, const void* p2) * without affecting playlist load up performance. This thread also flushes * any pending control commands when the disk spins up. */ -static bool playlist_flush_callback(void) +static void playlist_flush_callback(void *param) { + (void)param; struct playlist_info *playlist; playlist = ¤t_playlist; if (playlist->control_fd >= 0) @@ -1228,7 +1229,6 @@ static bool playlist_flush_callback(void) } sync_control(playlist, true); } - return true; } static void playlist_thread(void) diff --git a/apps/plugin.h b/apps/plugin.h index 41375a6adb..6ff7e7e568 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -403,8 +403,8 @@ struct plugin_api { void (*storage_spin)(void); void (*storage_spindown)(int seconds); #if USING_STORAGE_CALLBACK - void (*register_storage_idle_func)(storage_idle_notify function); - void (*unregister_storage_idle_func)(storage_idle_notify function, bool run); + void (*register_storage_idle_func)(void (*function)(void *data)); + void (*unregister_storage_idle_func)(void (*function)(void *data), bool run); #endif /* USING_STORAGE_CALLBACK */ void (*reload_directory)(void); char *(*create_numbered_filename)(char *buffer, const char *path, diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 909de03512..c0b6d44e9f 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -306,22 +306,19 @@ static unsigned int charge_state(void) #endif -static bool flush_buffer(void) +static void flush_buffer(void* data) { + (void)data; int fd, secs; unsigned int i; /* don't access the disk when in usb mode, or when no data is available */ if (in_usb_mode || (buf_idx == 0)) - { - return false; - } + return; fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND); if (fd < 0) - { - return false; - } + return; for (i = 0; i < buf_idx; i++) { @@ -357,7 +354,6 @@ static bool flush_buffer(void) rb->close(fd); buf_idx = 0; - return true; } @@ -395,7 +391,7 @@ void thread(void) for this to occur because it requires > 16 hours of no disk activity. */ if (buf_idx == BUF_ELEMENTS) { - flush_buffer(); + flush_buffer(NULL); } /* sleep some time until next measurement */ diff --git a/apps/scrobbler.c b/apps/scrobbler.c index b0f65158e8..83f546b59f 100644 --- a/apps/scrobbler.c +++ b/apps/scrobbler.c @@ -128,11 +128,11 @@ static void write_cache(void) cache_pos = 0; } -static bool scrobbler_flush_callback(void) +static void scrobbler_flush_callback(void *data) { + (void)data; if (scrobbler_initialised && cache_pos) write_cache(); - return true; } static void add_to_cache(unsigned long play_length) @@ -185,8 +185,9 @@ static void add_to_cache(unsigned long play_length) } -void scrobbler_change_event(struct mp3entry *id) +static void scrobbler_change_event(void *data) { + struct mp3entry *id = (struct mp3entry*)data; /* add entry using the previous scrobbler_entry and timestamp */ if (pending) add_to_cache(audio_prev_elapsed()); diff --git a/apps/scrobbler.h b/apps/scrobbler.h index d7a9b25624..050522e43b 100644 --- a/apps/scrobbler.h +++ b/apps/scrobbler.h @@ -18,10 +18,14 @@ * KIND, either express or implied. * ****************************************************************************/ - -void scrobbler_change_event(struct mp3entry *id); + +#ifndef __SCROBBLER_H__ +#define __SCROBBLER_H__ + int scrobbler_init(void); void scrobbler_flush_cache(void); void scrobbler_shutdown(void); void scrobbler_poweroff(void); bool scrobbler_is_enabled(void); + +#endif /* __SCROBBLER_H__ */ diff --git a/apps/settings.c b/apps/settings.c index 7a36a0ee1d..f12bd92bfd 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -568,17 +568,17 @@ static bool settings_write_config(const char* filename, int options) return true; } #ifndef HAVE_RTC_RAM -static bool flush_global_status_callback(void) +static void flush_global_status_callback(void *data) { - return write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); + (void)data; + write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); } #endif -static bool flush_config_block_callback(void) +static void flush_config_block_callback(void *data) { - bool r1, r2; - r1 = write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); - r2 = settings_write_config(CONFIGFILE, SETTINGS_SAVE_CHANGED); - return r1 || r2; + (void)data; + write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); + settings_write_config(CONFIGFILE, SETTINGS_SAVE_CHANGED); } /* diff --git a/apps/tagcache.c b/apps/tagcache.c index a5df2f0ad1..14d88bbfb8 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -3068,16 +3068,16 @@ static bool command_queue_is_full(void) return (next == command_queue_ridx); } -static bool command_queue_sync_callback(void) +static void command_queue_sync_callback(void *data) { - + (void)data; struct master_header myhdr; int masterfd; mutex_lock(&command_queue_mutex); if ( (masterfd = open_master_fd(&myhdr, true)) < 0) - return false; + return; while (command_queue_ridx != command_queue_widx) { @@ -3092,7 +3092,7 @@ static bool command_queue_sync_callback(void) /* Re-open the masterfd. */ if ( (masterfd = open_master_fd(&myhdr, true)) < 0) - return true; + return; break; } @@ -3111,7 +3111,6 @@ static bool command_queue_sync_callback(void) tc_stat.queue_length = 0; mutex_unlock(&command_queue_mutex); - return true; } static void run_command_queue(bool force) @@ -3120,7 +3119,7 @@ static void run_command_queue(bool force) return; if (force || command_queue_is_full()) - command_queue_sync_callback(); + command_queue_sync_callback(NULL); else register_storage_idle_func(command_queue_sync_callback); } diff --git a/apps/tagtree.c b/apps/tagtree.c index 2962d57dac..832a49e359 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -642,9 +642,10 @@ static int compare(const void *p1, const void *p2) return strncasecmp(e1->name, e2->name, MAX_PATH); } -static void tagtree_buffer_event(struct mp3entry *id3) +static void tagtree_buffer_event(void *data) { struct tagcache_search tcs; + struct mp3entry *id3 = (struct mp3entry*)data; /* Do not gather data unless proper setting has been enabled. */ if (!global_settings.runtimedb) @@ -671,12 +672,13 @@ static void tagtree_buffer_event(struct mp3entry *id3) tagcache_search_finish(&tcs); } -static void tagtree_track_finish_event(struct mp3entry *id3) +static void tagtree_track_finish_event(void *data) { long playcount; long playtime; long lastplayed; long tagcache_idx; + struct mp3entry *id3 = (struct mp3entry*)data; /* Do not gather data unless proper setting has been enabled. */ if (!global_settings.runtimedb) diff --git a/firmware/ata_idle_notify.c b/firmware/ata_idle_notify.c index 99b1d4d786..35d192bee0 100644 --- a/firmware/ata_idle_notify.c +++ b/firmware/ata_idle_notify.c @@ -25,12 +25,12 @@ #include "kernel.h" #include "string.h" -void register_storage_idle_func(storage_idle_notify function) +void register_storage_idle_func(void (*function)(void *data)) { #if USING_STORAGE_CALLBACK add_event(DISK_EVENT_SPINUP, true, function); #else - function(); /* just call the function now */ + function(NULL); /* just call the function now */ /* this _may_ cause problems later if the calling function sets a variable expecting the callback to unset it, because the callback will be run before this function exits, so before the var is set */ @@ -38,12 +38,12 @@ void register_storage_idle_func(storage_idle_notify function) } #if USING_STORAGE_CALLBACK -void unregister_storage_idle_func(storage_idle_notify func, bool run) +void unregister_storage_idle_func(void (*func)(void *data), bool run) { remove_event(DISK_EVENT_SPINUP, func); if (run) - func(); + func(NULL); } bool call_storage_idle_notifys(bool force) diff --git a/firmware/events.c b/firmware/events.c index 951214377e..dca612bc7b 100644 --- a/firmware/events.c +++ b/firmware/events.c @@ -33,7 +33,7 @@ struct sysevent { static struct sysevent events[MAX_SYS_EVENTS]; -bool add_event(unsigned short id, bool oneshot, void (*handler)) +bool add_event(unsigned short id, bool oneshot, void (*handler)(void *data)) { int i; @@ -60,7 +60,7 @@ bool add_event(unsigned short id, bool oneshot, void (*handler)) return false; } -void remove_event(unsigned short id, void (*handler)) +void remove_event(unsigned short id, void (*handler)(void *data)) { int i; diff --git a/firmware/export/ata_idle_notify.h b/firmware/export/ata_idle_notify.h index 18f1648e00..348165f1d1 100644 --- a/firmware/export/ata_idle_notify.h +++ b/firmware/export/ata_idle_notify.h @@ -48,11 +48,9 @@ enum { && (CONFIG_NAND == NAND_IFP7XX)) \ && !defined(BOOTLOADER) -typedef bool (*storage_idle_notify)(void); - -extern void register_storage_idle_func(storage_idle_notify function); +extern void register_storage_idle_func(void (*function)(void *data)); #if USING_STORAGE_CALLBACK -extern void unregister_storage_idle_func(storage_idle_notify function, bool run); +extern void unregister_storage_idle_func(void (*function)(void *data), bool run); extern bool call_storage_idle_notifys(bool force); #else #define unregister_storage_idle_func(f,r) diff --git a/firmware/export/events.h b/firmware/export/events.h index cad0fad895..694566a43e 100644 --- a/firmware/export/events.h +++ b/firmware/export/events.h @@ -38,8 +38,8 @@ #define EVENT_CLASS_BUFFERING 0x0400 #define EVENT_CLASS_GUI 0x0800 -bool add_event(unsigned short id, bool oneshot, void (*handler)); -void remove_event(unsigned short id, void (*handler)); +bool add_event(unsigned short id, bool oneshot, void (*handler)(void *data)); +void remove_event(unsigned short id, void (*handler)(void *data)); void send_event(unsigned short id, void *data); #endif -- cgit v1.2.3