summaryrefslogtreecommitdiffstats
path: root/apps/tagtree.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-07-12 12:06:38 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-07-13 00:08:51 -0400
commit023f6b6efd5407dc77c1253789f61baabb6607d6 (patch)
tree40d43117a7651715a2ce983eedff56b27962881a /apps/tagtree.c
parentffa8626b0c93f8a65e0e17190917f7f173160842 (diff)
downloadrockbox-023f6b6efd5407dc77c1253789f61baabb6607d6.tar.gz
rockbox-023f6b6efd5407dc77c1253789f61baabb6607d6.tar.bz2
rockbox-023f6b6efd5407dc77c1253789f61baabb6607d6.zip
Get rid of some superfluous single-purpose functions in playback.
* Remove explicit tracking of elapsed time of previous track. * Remove function to obtain auto skip flag. * Most playback events now carry the extra information instead and pass 'struct track_event *' for data. * Tweak scrobbler to use PLAYBACK_EVENT_TRACK_FINISH, which makes it cleaner and removes the struct mp3entry. Change-Id: I500d2abb4056a32646496efc3617406e36811ec5
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c71
1 files changed, 45 insertions, 26 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 6b0c6aa3dd..417b6f28f0 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -794,10 +794,13 @@ static int compare(const void *p1, const void *p2)
static void tagtree_buffer_event(void *data)
{
struct tagcache_search tcs;
- struct mp3entry *id3 = (struct mp3entry*)data;
+ struct mp3entry *id3 = ((struct track_event *)data)->id3;
+
+ bool runtimedb = global_settings.runtimedb;
+ bool autoresume = global_settings.autoresume_enable;
/* Do not gather data unless proper setting has been enabled. */
- if (!global_settings.runtimedb && !global_settings.autoresume_enable)
+ if (!runtimedb && !autoresume)
return;
logf("be:%s", id3->path);
@@ -811,7 +814,7 @@ static void tagtree_buffer_event(void *data)
return;
}
- if (global_settings.runtimedb)
+ if (runtimedb)
{
id3->playcount = tagcache_get_numeric(&tcs, tag_playcount);
if (!id3->rating)
@@ -824,7 +827,7 @@ static void tagtree_buffer_event(void *data)
}
#if CONFIG_CODEC == SWCODEC
- if (global_settings.autoresume_enable)
+ if (autoresume)
{
/* Load current file resume offset if not already defined (by
another resume mechanism) */
@@ -846,18 +849,10 @@ static void tagtree_buffer_event(void *data)
static void tagtree_track_finish_event(void *data)
{
- 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 && !global_settings.autoresume_enable)
- {
- logf("runtimedb gathering and autoresume not enabled");
- return;
- }
+ struct track_event *te = (struct track_event *)data;
+ struct mp3entry *id3 = te->id3;
- tagcache_idx=id3->tagcache_idx;
+ long tagcache_idx = id3->tagcache_idx;
if (!tagcache_idx)
{
logf("No tagcache index pointer found");
@@ -865,26 +860,51 @@ static void tagtree_track_finish_event(void *data)
}
tagcache_idx--;
- /* Don't process unplayed tracks, or tracks interrupted within the
- first 15 seconds. */
- if (id3->elapsed == 0
#if CONFIG_CODEC == SWCODEC /* HWCODEC doesn't have automatic_skip */
- || (id3->elapsed < 15 * 1000 && !audio_automatic_skip())
+ bool auto_skip = te->flags & TEF_AUTO_SKIP;
#endif
- )
+ bool runtimedb = global_settings.runtimedb;
+ bool autoresume = global_settings.autoresume_enable;
+
+ /* Don't process unplayed tracks, or tracks interrupted within the
+ first 15 seconds but always process autoresume point */
+ if (runtimedb && (id3->elapsed == 0
+#if CONFIG_CODEC == SWCODEC
+ || (id3->elapsed < 15 * 1000 && !auto_skip)
+#endif
+ ))
+ {
+ logf("not db logging unplayed or skipped track");
+ runtimedb = false;
+ }
+
+#if CONFIG_CODEC == SWCODEC
+ /* 3s because that is the threshold the WPS uses to rewind instead
+ of skip backwards */
+ if (autoresume && (id3->elapsed == 0
+ || (id3->elapsed < 3 * 1000 && !auto_skip)))
+ {
+ logf("not logging autoresume");
+ autoresume = false;
+ }
+#endif
+
+ /* Do not gather data unless proper setting has been enabled and at least
+ one is still slated to be recorded */
+ if (!(runtimedb || autoresume))
{
- logf("not logging unplayed or skipped track");
+ logf("runtimedb gathering and autoresume not enabled/ignored");
return;
}
- lastplayed = tagcache_increase_serial();
+ long lastplayed = tagcache_increase_serial();
if (lastplayed < 0)
{
logf("incorrect tc serial:%ld", lastplayed);
return;
}
- if (global_settings.runtimedb)
+ if (runtimedb)
{
long playcount;
long playtime;
@@ -906,10 +926,9 @@ static void tagtree_track_finish_event(void *data)
}
#if CONFIG_CODEC == SWCODEC
- if (global_settings.autoresume_enable)
+ if (autoresume)
{
- unsigned long offset
- = audio_automatic_skip() ? 0 : id3->offset;
+ unsigned long offset = auto_skip ? 0 : id3->offset;
tagcache_update_numeric(tagcache_idx, tag_lastoffset, offset);