summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-10-31 13:43:50 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-10-31 13:43:50 +0000
commit7f79564abc7b0a7afce8c4519c69684d86d57829 (patch)
tree9ca5f4576f2f76c8306398816622ce86304ef733
parentb41b1b3141e87491826749c0e074b18ea5d25d77 (diff)
downloadrockbox-7f79564abc7b0a7afce8c4519c69684d86d57829.tar.gz
rockbox-7f79564abc7b0a7afce8c4519c69684d86d57829.zip
Accept FS#8053 by Bertrik Sikken: playback.c and mpeg.c simplification by removal of last_track argument in track_(un)buffer callback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15384 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c55
-rw-r--r--apps/playback.h6
-rw-r--r--apps/tagtree.c6
-rw-r--r--firmware/export/mpeg.h6
-rw-r--r--firmware/mpeg.c40
5 files changed, 25 insertions, 88 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 793832322b..5cd8e6def3 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -252,9 +252,9 @@ static bool skipped_during_pause = false; /* Do we need to clear the PCM buffer
/* When the playing track has changed from the user's perspective */
void (*track_changed_callback)(struct mp3entry *id3) = NULL;
/* When a track has been buffered */
-void (*track_buffer_callback)(struct mp3entry *id3, bool last_track) = NULL;
+void (*track_buffer_callback)(struct mp3entry *id3) = NULL;
/* When a track's buffer has been overwritten or cleared */
-void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track) = NULL;
+void (*track_unbuffer_callback)(struct mp3entry *id3) = NULL;
static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) */
@@ -2129,7 +2129,6 @@ static void audio_update_trackinfo(void)
static void audio_clear_track_entries(bool clear_unbuffered)
{
int cur_idx = track_widx;
- int last_idx = -1;
logf("Clearing tracks:%d/%d, %d", track_ridx, track_widx, clear_unbuffered);
@@ -2146,30 +2145,16 @@ static void audio_clear_track_entries(bool clear_unbuffered)
* otherwise clear the track if that option is selected */
if (tracks[cur_idx].event_sent)
{
- if (last_idx >= 0)
- {
- /* If there is an unbuffer callback, call it, otherwise,
- * just clear the track */
- if (track_unbuffer_callback && tracks[last_idx].id3_hid > 0)
- track_unbuffer_callback(bufgetid3(tracks[last_idx].id3_hid), false);
+ /* If there is an unbuffer callback, call it, otherwise,
+ * just clear the track */
+ if (track_unbuffer_callback && tracks[cur_idx].id3_hid > 0)
+ track_unbuffer_callback(bufgetid3(tracks[cur_idx].id3_hid));
- clear_track_info(&tracks[last_idx]);
- }
- last_idx = cur_idx;
+ clear_track_info(&tracks[cur_idx]);
}
else if (clear_unbuffered)
clear_track_info(&tracks[cur_idx]);
}
-
- /* We clear the previous instance of a buffered track throughout
- * the above loop to facilitate 'last' detection. Clear/notify
- * the last track here */
- if (last_idx >= 0)
- {
- if (track_unbuffer_callback && tracks[last_idx].id3_hid > 0)
- track_unbuffer_callback(bufgetid3(tracks[last_idx].id3_hid), true);
- clear_track_info(&tracks[last_idx]);
- }
}
static bool audio_release_tracks(void)
@@ -2527,7 +2512,6 @@ static bool audio_load_track(int offset, bool start_play)
static void audio_generate_postbuffer_events(void)
{
int cur_idx;
- int last_idx = -1;
logf("Postbuffer:%d/%d",track_ridx,track_widx);
@@ -2538,27 +2522,16 @@ static void audio_generate_postbuffer_events(void)
while (1) {
if (!tracks[cur_idx].event_sent)
{
- if (last_idx >= 0 && !tracks[last_idx].event_sent)
- {
- /* Mark the event 'sent' even if we don't really send one */
- tracks[last_idx].event_sent = true;
- if (track_buffer_callback && tracks[last_idx].id3_hid > 0)
- track_buffer_callback(bufgetid3(tracks[last_idx].id3_hid), false);
- }
- last_idx = cur_idx;
+ /* Mark the event 'sent' even if we don't really send one */
+ tracks[cur_idx].event_sent = true;
+ if (track_buffer_callback && tracks[cur_idx].id3_hid > 0)
+ track_buffer_callback(bufgetid3(tracks[cur_idx].id3_hid));
}
if (cur_idx == track_widx)
break;
cur_idx++;
cur_idx &= MAX_TRACK_MASK;
}
-
- if (last_idx >= 0 && !tracks[last_idx].event_sent)
- {
- tracks[last_idx].event_sent = true;
- if (track_buffer_callback && tracks[last_idx].id3_hid > 0)
- track_buffer_callback(bufgetid3(tracks[last_idx].id3_hid), true);
- }
}
}
@@ -2767,14 +2740,12 @@ skip_done:
return Q_CODEC_REQUEST_COMPLETE;
}
-void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track))
+void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3))
{
track_buffer_callback = handler;
}
-void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track))
+void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3))
{
track_unbuffer_callback = handler;
}
diff --git a/apps/playback.h b/apps/playback.h
index 9088af9b6e..b005e63b3c 100644
--- a/apps/playback.h
+++ b/apps/playback.h
@@ -42,10 +42,8 @@
/* Functions */
const char * get_codec_filename(int cod_spec);
void audio_set_track_changed_event(void (*handler)(struct mp3entry *id3));
-void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track));
-void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track));
+void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3));
+void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3));
void voice_wait(void);
#if CONFIG_CODEC == SWCODEC /* This #ifdef is better here than gui/gwps.c */
diff --git a/apps/tagtree.c b/apps/tagtree.c
index c0d9f0f425..60bdfb2c0e 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -633,10 +633,9 @@ 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, bool last_track)
+static void tagtree_buffer_event(struct mp3entry *id3)
{
(void)id3;
- (void)last_track;
/* Do not gather data unless proper setting has been enabled. */
if (!global_settings.runtimedb)
@@ -663,9 +662,8 @@ static void tagtree_buffer_event(struct mp3entry *id3, bool last_track)
tagcache_search_finish(&tcs);
}
-static void tagtree_unbuffer_event(struct mp3entry *id3, bool last_track)
+static void tagtree_unbuffer_event(struct mp3entry *id3)
{
- (void)last_track;
long playcount;
long playtime;
long lastplayed;
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
index 9de8c499af..3e36c44ac5 100644
--- a/firmware/export/mpeg.h
+++ b/firmware/export/mpeg.h
@@ -57,10 +57,8 @@ void rec_tick(void);
void playback_tick(void); /* FixMe: get rid of this, use mp3_get_playtime() */
void audio_set_track_changed_event(void (*handler)(struct mp3entry *id3));
-void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track));
-void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track));
+void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3));
+void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3));
void audio_set_cuesheet_callback(bool (*handler)(const char *filename));
#endif
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index a4632aae38..c09ef38376 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -118,8 +118,8 @@ static int track_write_idx = 0;
/* Callback function to call when current track has really changed. */
void (*track_changed_callback)(struct mp3entry *id3) = NULL;
-void (*track_buffer_callback)(struct mp3entry *id3, bool last_track);
-void (*track_unbuffer_callback)(struct mp3entry *id3, bool last_track);
+void (*track_buffer_callback)(struct mp3entry *id3);
+void (*track_unbuffer_callback)(struct mp3entry *id3);
/* Cuesheet callback */
static bool (*cuesheet_callback)(const char *filename) = NULL;
@@ -475,14 +475,12 @@ unsigned long mpeg_get_last_header(void)
#endif /* !SIMULATOR */
}
-void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track))
+void audio_set_track_buffer_event(void (*handler)(struct mp3entry *id3))
{
track_buffer_callback = handler;
}
-void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3,
- bool last_track))
+void audio_set_track_unbuffer_event(void (*handler)(struct mp3entry *id3))
{
track_unbuffer_callback = handler;
}
@@ -502,29 +500,16 @@ void audio_set_cuesheet_callback(bool (*handler)(const char *filename))
static void generate_unbuffer_events(void)
{
int i;
- int event_count = 0;
int numentries = MAX_TRACK_ENTRIES - num_tracks_in_memory();
int cur_idx = track_write_idx;
-
- for (i = 0; i < numentries; i++)
- {
- if (trackdata[cur_idx].event_sent)
- event_count++;
-
- cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
- }
-
- cur_idx = track_write_idx;
for (i = 0; i < numentries; i++)
{
/* Send an event to notify that track has finished. */
if (trackdata[cur_idx].event_sent)
{
- event_count--;
if (track_unbuffer_callback)
- track_unbuffer_callback(&trackdata[cur_idx].id3,
- event_count == 0);
+ track_unbuffer_callback(&trackdata[cur_idx].id3);
trackdata[cur_idx].event_sent = false;
}
cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
@@ -535,28 +520,15 @@ static void generate_unbuffer_events(void)
static void generate_postbuffer_events(void)
{
int i;
- int event_count = 0;
int numentries = num_tracks_in_memory();
int cur_idx = track_read_idx;
for (i = 0; i < numentries; i++)
{
if (!trackdata[cur_idx].event_sent)
- event_count++;
-
- cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
- }
-
- cur_idx = track_read_idx;
-
- for (i = 0; i < numentries; i++)
- {
- if (!trackdata[cur_idx].event_sent)
{
- event_count--;
if (track_buffer_callback)
- track_buffer_callback(&trackdata[cur_idx].id3,
- event_count == 0);
+ track_buffer_callback(&trackdata[cur_idx].id3);
trackdata[cur_idx].event_sent = true;
}
cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;