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
This commit is contained in:
Thomas Martitz 2009-10-20 21:54:44 +00:00
parent 872852639f
commit 774bacc692
13 changed files with 51 additions and 50 deletions

View file

@ -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.

View file

@ -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 = &current_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)

View file

@ -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,

View file

@ -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 */

View file

@ -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());

View file

@ -19,9 +19,13 @@
*
****************************************************************************/
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__ */

View file

@ -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);
}
/*

View file

@ -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);
}

View file

@ -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)

View file

@ -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)

View file

@ -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;

View file

@ -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)

View file

@ -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