It makes more sense for the callback registrar to decide if its a "oneshot" then the callback caller.
(Doing it this way means playback could(/should?) registar a disk spinup callback at init which is called every spinup without needing to be reregistered) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16685 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c6b6bad18f
commit
a67e5d89ef
7 changed files with 19 additions and 17 deletions
|
@ -1731,7 +1731,7 @@ static bool audio_load_track(int offset, bool start_play)
|
|||
{
|
||||
if (get_metadata(&id3, fd, trackname))
|
||||
{
|
||||
send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &id3);
|
||||
send_event(PLAYBACK_EVENT_TRACK_BUFFER, &id3);
|
||||
|
||||
tracks[track_widx].id3_hid =
|
||||
bufalloc(&id3, sizeof(struct mp3entry), TYPE_ID3);
|
||||
|
@ -1968,7 +1968,7 @@ static int audio_check_new_track(void)
|
|||
bool end_of_playlist; /* Temporary flag, not the same as playlist_end */
|
||||
|
||||
/* Now it's good time to send track unbuffer events. */
|
||||
send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &curtrack_id3);
|
||||
send_event(PLAYBACK_EVENT_TRACK_FINISH, &curtrack_id3);
|
||||
|
||||
if (dir_skip)
|
||||
{
|
||||
|
@ -2339,7 +2339,7 @@ static void audio_finalise_track_change(void)
|
|||
bufgetid3(prev_ti->id3_hid)->elapsed = 0;
|
||||
}
|
||||
|
||||
send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, &curtrack_id3);
|
||||
send_event(PLAYBACK_EVENT_TRACK_CHANGE, &curtrack_id3);
|
||||
|
||||
track_changed = true;
|
||||
playlist_update_resume_info(audio_current_track());
|
||||
|
|
|
@ -227,7 +227,7 @@ int scrobbler_init(void)
|
|||
|
||||
scrobbler_cache = buffer_alloc(SCROBBLER_MAX_CACHE*SCROBBLER_CACHE_LEN);
|
||||
|
||||
add_event(PLAYBACK_EVENT_TRACK_CHANGE, scrobbler_change_event);
|
||||
add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, scrobbler_change_event);
|
||||
cache_pos = 0;
|
||||
pending = false;
|
||||
scrobbler_initialised = true;
|
||||
|
|
|
@ -925,8 +925,8 @@ void tagtree_init(void)
|
|||
|
||||
uniqbuf = buffer_alloc(UNIQBUF_SIZE);
|
||||
|
||||
add_event(PLAYBACK_EVENT_TRACK_BUFFER, tagtree_buffer_event);
|
||||
add_event(PLAYBACK_EVENT_TRACK_FINISH, tagtree_track_finish_event);
|
||||
add_event(PLAYBACK_EVENT_TRACK_BUFFER, false, tagtree_buffer_event);
|
||||
add_event(PLAYBACK_EVENT_TRACK_FINISH, false, tagtree_track_finish_event);
|
||||
}
|
||||
|
||||
static bool show_search_progress(bool init, int count)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
void register_ata_idle_func(ata_idle_notify function)
|
||||
{
|
||||
#if USING_ATA_CALLBACK
|
||||
add_event(DISK_EVENT_SPINUP, function);
|
||||
add_event(DISK_EVENT_SPINUP, true, function);
|
||||
#else
|
||||
function(); /* just call the function now */
|
||||
/* this _may_ cause problems later if the calling function
|
||||
|
@ -55,7 +55,7 @@ bool call_ata_idle_notifys(bool force)
|
|||
}
|
||||
lock_until = current_tick + 30*HZ;
|
||||
|
||||
send_event(DISK_EVENT_SPINUP, true, NULL);
|
||||
send_event(DISK_EVENT_SPINUP, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,12 +23,13 @@
|
|||
|
||||
struct sysevent {
|
||||
unsigned short id;
|
||||
bool oneshot;
|
||||
void (*callback)(void *data);
|
||||
};
|
||||
|
||||
struct sysevent events[MAX_SYS_EVENTS];
|
||||
|
||||
bool add_event(unsigned short id, void (*handler))
|
||||
bool add_event(unsigned short id, bool oneshot, void (*handler))
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -45,6 +46,7 @@ bool add_event(unsigned short id, void (*handler))
|
|||
if (events[i].callback == NULL)
|
||||
{
|
||||
events[i].id = id;
|
||||
events[i].oneshot = oneshot;
|
||||
events[i].callback = handler;
|
||||
return true;
|
||||
}
|
||||
|
@ -70,7 +72,7 @@ void remove_event(unsigned short id, void (*handler))
|
|||
panicf("event not found");
|
||||
}
|
||||
|
||||
void send_event(unsigned short id, bool oneshot, void *data)
|
||||
void send_event(unsigned short id, void *data)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -80,7 +82,7 @@ void send_event(unsigned short id, bool oneshot, void *data)
|
|||
{
|
||||
events[i].callback(data);
|
||||
|
||||
if (oneshot)
|
||||
if (events[i].oneshot)
|
||||
events[i].callback = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
bool add_event(unsigned short id, void (*handler));
|
||||
bool add_event(unsigned short id, bool oneshot, void (*handler));
|
||||
void remove_event(unsigned short id, void (*handler));
|
||||
void send_event(unsigned short id, bool oneshot, void *data);
|
||||
void send_event(unsigned short id, void *data);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ static void generate_unbuffer_events(void)
|
|||
for (i = 0; i < numentries; i++)
|
||||
{
|
||||
/* Send an event to notify that track has finished. */
|
||||
send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &trackdata[cur_idx].id3);
|
||||
send_event(PLAYBACK_EVENT_TRACK_FINISH, &trackdata[cur_idx].id3);
|
||||
cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
|
||||
}
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ static void generate_postbuffer_events(void)
|
|||
|
||||
for (i = 0; i < numentries; i++)
|
||||
{
|
||||
send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &trackdata[cur_idx].id3);
|
||||
send_event(PLAYBACK_EVENT_TRACK_BUFFER, &trackdata[cur_idx].id3);
|
||||
cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
|
||||
}
|
||||
}
|
||||
|
@ -1049,7 +1049,7 @@ static void track_change(void)
|
|||
if (num_tracks_in_memory() > 0)
|
||||
{
|
||||
remove_current_tag();
|
||||
send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track());
|
||||
send_event(PLAYBACK_EVENT_TRACK_CHANGE, audio_current_track());
|
||||
update_playlist();
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1102,7 @@ static void start_playback_if_ready(void)
|
|||
if (play_pending_track_change)
|
||||
{
|
||||
play_pending_track_change = false;
|
||||
send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, audio_current_track());
|
||||
send_event(PLAYBACK_EVENT_TRACK_CHANGE, audio_current_track());
|
||||
}
|
||||
play_pending = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue