summaryrefslogtreecommitdiffstats
path: root/apps/tagtree.c
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2011-01-02 02:49:13 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2011-01-02 02:49:13 +0000
commit66e8fc0f0d05d926a90e8d9991f78b7a855eb7f3 (patch)
tree7db19ba9c1f166c1f35e0581cd69801d7dc7e234 /apps/tagtree.c
parent4048cf27a24b93e76c4262974831669e79c71da8 (diff)
downloadrockbox-66e8fc0f0d05d926a90e8d9991f78b7a855eb7f3.tar.gz
rockbox-66e8fc0f0d05d926a90e8d9991f78b7a855eb7f3.tar.bz2
rockbox-66e8fc0f0d05d926a90e8d9991f78b7a855eb7f3.zip
Commit part of FS#11748 by Michael Hohmuth. Adds support for automatically resuming any song that is not played to completion at any point later in time, regardless of how many intermediate tracks are played. This is accomplished by expanding the database to record incompletely played tracks. Currently, the feature is simply on or off, in which case all tracks automatically resume, or they do not. The remainder of patches in the task expand this feature by allowing only certain file to automatically resume, only resuming in certain circumstances, etc but are not included until we reach agreement on what should be included. Additionally, the manual will need to be updated once we agree on the available settings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28942 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c84
1 files changed, 62 insertions, 22 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 75caab01d4..8ebac0b3a5 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -53,6 +53,8 @@
#include "storage.h"
#include "dir.h"
+#define str_or_empty(x) (x ? x : "(NULL)")
+
#define FILE_SEARCH_INSTRUCTIONS ROCKBOX_DIR "/tagnavi.config"
static int tagtree_play_folder(struct tree_context* c);
@@ -168,6 +170,8 @@ static int current_entry_count;
static struct tree_context *tc;
+extern bool automatic_skip; /* Who initiated in-progress skip? (C/A-) */
+
static int get_token_str(char *buf, int size)
{
/* Find the start. */
@@ -239,6 +243,7 @@ static int get_tag(int *tag)
MATCH(tag, buf, "playcount", tag_playcount);
MATCH(tag, buf, "rating", tag_rating);
MATCH(tag, buf, "lastplayed", tag_lastplayed);
+ MATCH(tag, buf, "lastoffset", tag_lastoffset);
MATCH(tag, buf, "commitid", tag_commitid);
MATCH(tag, buf, "entryage", tag_virt_entryage);
MATCH(tag, buf, "autoscore", tag_virt_autoscore);
@@ -647,7 +652,7 @@ static void tagtree_buffer_event(void *data)
struct mp3entry *id3 = (struct mp3entry*)data;
/* Do not gather data unless proper setting has been enabled. */
- if (!global_settings.runtimedb)
+ if (!global_settings.runtimedb && !global_settings.autoresume_enable)
return;
logf("be:%s", id3->path);
@@ -661,12 +666,30 @@ static void tagtree_buffer_event(void *data)
return;
}
- id3->playcount = tagcache_get_numeric(&tcs, tag_playcount);
- if (!id3->rating)
- id3->rating = tagcache_get_numeric(&tcs, tag_rating);
- id3->lastplayed = tagcache_get_numeric(&tcs, tag_lastplayed);
- id3->score = tagcache_get_numeric(&tcs, tag_virt_autoscore) / 10;
- id3->playtime = tagcache_get_numeric(&tcs, tag_playtime);
+ if (global_settings.runtimedb)
+ {
+ id3->playcount = tagcache_get_numeric(&tcs, tag_playcount);
+ if (!id3->rating)
+ id3->rating = tagcache_get_numeric(&tcs, tag_rating);
+ id3->lastplayed = tagcache_get_numeric(&tcs, tag_lastplayed);
+ id3->score = tagcache_get_numeric(&tcs, tag_virt_autoscore) / 10;
+ id3->playtime = tagcache_get_numeric(&tcs, tag_playtime);
+
+ logf("-> %ld/%ld", id3->playcount, id3->playtime);
+ }
+
+ if (global_settings.autoresume_enable)
+ {
+ /* Load current file resume offset if not already defined (by
+ another resume mechanism) */
+ if (id3->offset == 0)
+ {
+ id3->offset = tagcache_get_numeric(&tcs, tag_lastoffset);
+
+ logf("tagtree_buffer_event: Set offset for %s to %lX\n",
+ str_or_empty(id3->title), id3->offset);
+ }
+ }
/* Store our tagcache index pointer. */
id3->tagcache_idx = tcs.idx_id+1;
@@ -676,16 +699,14 @@ static void tagtree_buffer_event(void *data)
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)
+ if (!global_settings.runtimedb && !global_settings.autoresume_enable)
{
- logf("runtimedb gathering not enabled");
+ logf("runtimedb gathering and autoresume not enabled");
return;
}
@@ -704,7 +725,6 @@ static void tagtree_track_finish_event(void *data)
return;
}
- playcount = id3->playcount + 1;
lastplayed = tagcache_increase_serial();
if (lastplayed < 0)
{
@@ -712,17 +732,37 @@ static void tagtree_track_finish_event(void *data)
return;
}
- /* Ignore the last 15s (crossfade etc.) */
- playtime = id3->playtime + MIN(id3->length, id3->elapsed + 15 * 1000);
-
- logf("ube:%s", id3->path);
- logf("-> %ld/%ld", playcount, playtime);
- logf("-> %ld/%ld/%ld", id3->elapsed, id3->length, MIN(id3->length, id3->elapsed + 15 * 1000));
+ if (global_settings.runtimedb)
+ {
+ long playcount;
+ long playtime;
+
+ playcount = id3->playcount + 1;
+
+ /* Ignore the last 15s (crossfade etc.) */
+ playtime = id3->playtime + MIN(id3->length, id3->elapsed + 15 * 1000);
+
+ logf("ube:%s", id3->path);
+ logf("-> %ld/%ld", playcount, playtime);
+ logf("-> %ld/%ld/%ld", id3->elapsed, id3->length,
+ MIN(id3->length, id3->elapsed + 15 * 1000));
- /* Queue the updates to the tagcache system. */
- tagcache_update_numeric(tagcache_idx, tag_playcount, playcount);
- tagcache_update_numeric(tagcache_idx, tag_playtime, playtime);
- tagcache_update_numeric(tagcache_idx, tag_lastplayed, lastplayed);
+ /* Queue the updates to the tagcache system. */
+ tagcache_update_numeric(tagcache_idx, tag_playcount, playcount);
+ tagcache_update_numeric(tagcache_idx, tag_playtime, playtime);
+ tagcache_update_numeric(tagcache_idx, tag_lastplayed, lastplayed);
+ }
+
+ if (global_settings.autoresume_enable)
+ {
+ unsigned long offset
+ = automatic_skip ? 0 : id3->offset;
+
+ tagcache_update_numeric(tagcache_idx, tag_lastoffset, offset);
+
+ logf("tagtree_track_finish_event: Save offset for %s: %lX",
+ str_or_empty(id3->title), offset);
+ }
}
bool tagtree_export(void)