summaryrefslogtreecommitdiffstats
path: root/apps/playback.c
diff options
context:
space:
mode:
authorSean Bartell <wingedtachikoma@gmail.com>2011-08-22 01:36:25 -0400
committerNils Wallménius <nils@rockbox.org>2012-05-01 11:28:38 +0200
commit4bef502d4d7fb95f0afb4ac8cb293315d35bb3da (patch)
treef9f9a7fba4a45b86eb779e1d86aef598924290cd /apps/playback.c
parent9b363c6cedc31f135e831a1b57dcf08578d34ee7 (diff)
downloadrockbox-4bef502d4d7fb95f0afb4ac8cb293315d35bb3da.tar.gz
rockbox-4bef502d4d7fb95f0afb4ac8cb293315d35bb3da.tar.bz2
rockbox-4bef502d4d7fb95f0afb4ac8cb293315d35bb3da.zip
rbcodec refactoring: autoresumable
Moved to playback.c, since it doesn't use metadata from the music file. Change-Id: I5c3ad7750d94b36754f64eb302f96ec163785cb9 Reviewed-on: http://gerrit.rockbox.org/142 Reviewed-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 944775d6e1..997a374410 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1379,6 +1379,64 @@ static bool audio_init_codec(struct track_info *track_info,
(void)track_info; /* When codec buffering isn't supported */
}
+#ifdef HAVE_TAGCACHE
+/* Check settings for whether the file should be autoresumed */
+enum { AUTORESUMABLE_UNKNOWN = 0, AUTORESUMABLE_TRUE, AUTORESUMABLE_FALSE };
+static bool autoresumable(struct mp3entry *id3)
+{
+ char *endp, *path;
+ size_t len;
+ bool is_resumable;
+
+ if (id3->autoresumable) /* result cached? */
+ return id3->autoresumable == AUTORESUMABLE_TRUE;
+
+ is_resumable = false;
+
+ if (id3->path)
+ {
+ for (path = global_settings.autoresume_paths;
+ *path; /* search terms left? */
+ path++)
+ {
+ if (*path == ':') /* Skip empty search patterns */
+ continue;
+
+ /* FIXME: As soon as strcspn or strchrnul are made available in
+ the core, the following can be made more efficient. */
+ endp = strchr(path, ':');
+ if (endp)
+ len = endp - path;
+ else
+ len = strlen(path);
+
+ /* Note: At this point, len is always > 0 */
+
+ if (strncasecmp(id3->path, path, len) == 0)
+ {
+ /* Full directory-name matches only. Trailing '/' in
+ search path OK. */
+ if (id3->path[len] == '/' || id3->path[len - 1] == '/')
+ {
+ is_resumable = true;
+ break;
+ }
+ }
+ path += len - 1;
+ }
+ }
+
+ /* cache result */
+ id3->autoresumable =
+ is_resumable ? AUTORESUMABLE_TRUE : AUTORESUMABLE_FALSE;
+
+ logf("autoresumable: %s is%s resumable",
+ id3->path, is_resumable ? "" : " not");
+
+ return is_resumable;
+}
+#endif /* HAVE_TAGCACHE */
+
/* Start the codec for the current track scheduled to be decoded */
static bool audio_start_codec(bool auto_skip)
{