summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2005-07-03 18:36:24 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2005-07-03 18:36:24 +0000
commit9bde0380a6b58610fc8fcc5cdc81b6462f2bb0b9 (patch)
treef39b08a1b1e5bc6a79cd59a1d0d2ff14b7d9a838
parentf46c9f204c2d1a4d477364d5f3a87e59e06a0aa9 (diff)
downloadrockbox-9bde0380a6b58610fc8fcc5cdc81b6462f2bb0b9.zip
rockbox-9bde0380a6b58610fc8fcc5cdc81b6462f2bb0b9.tar.gz
rockbox-9bde0380a6b58610fc8fcc5cdc81b6462f2bb0b9.tar.bz2
rockbox-9bde0380a6b58610fc8fcc5cdc81b6462f2bb0b9.tar.xz
Updated the track_unbuffer event callback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6995 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c43
-rw-r--r--apps/playback.h2
2 files changed, 31 insertions, 14 deletions
diff --git a/apps/playback.c b/apps/playback.c
index c5b6fbc..875a157 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -162,7 +162,7 @@ static int new_track;
/* Callback function to call when current track has really changed. */
void (*track_changed_callback)(struct track_info *ti);
void (*track_buffer_callback)(struct mp3entry *id3, bool last_track);
-void (*track_unbuffer_callback)(struct mp3entry *id3, bool disk_spinning);
+void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track);
/* Configuration */
static int conf_bufferlimit;
@@ -598,7 +598,7 @@ void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3,
}
void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3,
- bool disk_spinning))
+ bool last_track))
{
track_unbuffer_callback = handler;
}
@@ -990,17 +990,37 @@ void audio_play_start(int offset)
void audio_clear_track_entries(void)
{
- int cur_idx;
+ int cur_idx, event_count;
int i;
cur_idx = track_widx;
+ event_count = 0;
for (i = 0; i < MAX_TRACK - track_count; i++) {
if (++cur_idx >= MAX_TRACK)
cur_idx = 0;
- /* Send event to notify that track has finished. */
- if (track_unbuffer_callback && tracks[cur_idx].event_sent)
- track_unbuffer_callback(&tracks[cur_idx].id3, filling);
+ if (tracks[cur_idx].event_sent)
+ event_count++;
+
+ if (!track_unbuffer_callback)
+ memset(&tracks[cur_idx], 0, sizeof(struct track_info));
+ }
+
+ if (!track_unbuffer_callback)
+ return ;
+
+ cur_idx = track_widx;
+ for (i = 0; i < MAX_TRACK - track_count; i++) {
+ if (++cur_idx >= MAX_TRACK)
+ cur_idx = 0;
+
+ /* Send an event to notify that track has finished. */
+ if (tracks[cur_idx].event_sent) {
+ tracks[cur_idx].event_sent = true;
+ event_count--;
+ track_unbuffer_callback(&tracks[cur_idx].id3, event_count == 0);
+ }
+
memset(&tracks[cur_idx], 0, sizeof(struct track_info));
}
}
@@ -1163,7 +1183,6 @@ static void audio_stop_playback(void)
pcm_play_stop();
pcm_play_pause(true);
track_count = 0;
- filling = true;
audio_clear_track_entries();
filling = false;
}
@@ -1695,17 +1714,17 @@ void mpeg_id3_options(bool _v1first)
v1first = _v1first;
}
-/*
+
void test_buffer_event(struct mp3entry *id3, bool last_track)
{
logf("be:%d%s", last_track, id3->title);
}
-void test_unbuffer_event(struct mp3entry *id3, bool disk_spinning)
+void test_unbuffer_event(struct mp3entry *id3, bool last_track)
{
- logf("ube:%d%s", disk_spinning, id3->title);
+ logf("ube:%d%s", last_track, id3->title);
}
-*/
+
void audio_init(void)
{
@@ -1729,10 +1748,8 @@ void audio_init(void)
logf("fbuf:%0x", codecbuflen);
logf("mbuf:%0x", MALLOC_BUFSIZE);
- /*
audio_set_track_buffer_event(test_buffer_event);
audio_set_track_unbuffer_event(test_unbuffer_event);
- */
/* Initialize codec api. */
ci.read_filebuf = codec_filebuf_callback;
diff --git a/apps/playback.h b/apps/playback.h
index 8148a34..b00d5c3 100644
--- a/apps/playback.h
+++ b/apps/playback.h
@@ -66,7 +66,7 @@ void audio_set_track_changed_event(void (*handler)(struct track_info *ti));
void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3,
bool last_track));
void audio_set_track_unbufer_event(void (*handler)(struct mp3entry *id3,
- bool disk_spinning));
+ bool last_track));
void audio_invalidate_tracks(void);
#endif