diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-08-22 01:36:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-05-01 11:28:38 +0200 |
commit | 4bef502d4d7fb95f0afb4ac8cb293315d35bb3da (patch) | |
tree | f9f9a7fba4a45b86eb779e1d86aef598924290cd /apps | |
parent | 9b363c6cedc31f135e831a1b57dcf08578d34ee7 (diff) | |
download | rockbox-4bef502d4d7fb95f0afb4ac8cb293315d35bb3da.tar.gz 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')
-rw-r--r-- | apps/playback.c | 58 |
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, | |||
1379 | (void)track_info; /* When codec buffering isn't supported */ | 1379 | (void)track_info; /* When codec buffering isn't supported */ |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | #ifdef HAVE_TAGCACHE | ||
1383 | /* Check settings for whether the file should be autoresumed */ | ||
1384 | enum { AUTORESUMABLE_UNKNOWN = 0, AUTORESUMABLE_TRUE, AUTORESUMABLE_FALSE }; | ||
1385 | static bool autoresumable(struct mp3entry *id3) | ||
1386 | { | ||
1387 | char *endp, *path; | ||
1388 | size_t len; | ||
1389 | bool is_resumable; | ||
1390 | |||
1391 | if (id3->autoresumable) /* result cached? */ | ||
1392 | return id3->autoresumable == AUTORESUMABLE_TRUE; | ||
1393 | |||
1394 | is_resumable = false; | ||
1395 | |||
1396 | if (id3->path) | ||
1397 | { | ||
1398 | for (path = global_settings.autoresume_paths; | ||
1399 | *path; /* search terms left? */ | ||
1400 | path++) | ||
1401 | { | ||
1402 | if (*path == ':') /* Skip empty search patterns */ | ||
1403 | continue; | ||
1404 | |||
1405 | /* FIXME: As soon as strcspn or strchrnul are made available in | ||
1406 | the core, the following can be made more efficient. */ | ||
1407 | endp = strchr(path, ':'); | ||
1408 | if (endp) | ||
1409 | len = endp - path; | ||
1410 | else | ||
1411 | len = strlen(path); | ||
1412 | |||
1413 | /* Note: At this point, len is always > 0 */ | ||
1414 | |||
1415 | if (strncasecmp(id3->path, path, len) == 0) | ||
1416 | { | ||
1417 | /* Full directory-name matches only. Trailing '/' in | ||
1418 | search path OK. */ | ||
1419 | if (id3->path[len] == '/' || id3->path[len - 1] == '/') | ||
1420 | { | ||
1421 | is_resumable = true; | ||
1422 | break; | ||
1423 | } | ||
1424 | } | ||
1425 | path += len - 1; | ||
1426 | } | ||
1427 | } | ||
1428 | |||
1429 | /* cache result */ | ||
1430 | id3->autoresumable = | ||
1431 | is_resumable ? AUTORESUMABLE_TRUE : AUTORESUMABLE_FALSE; | ||
1432 | |||
1433 | logf("autoresumable: %s is%s resumable", | ||
1434 | id3->path, is_resumable ? "" : " not"); | ||
1435 | |||
1436 | return is_resumable; | ||
1437 | } | ||
1438 | #endif /* HAVE_TAGCACHE */ | ||
1439 | |||
1382 | /* Start the codec for the current track scheduled to be decoded */ | 1440 | /* Start the codec for the current track scheduled to be decoded */ |
1383 | static bool audio_start_codec(bool auto_skip) | 1441 | static bool audio_start_codec(bool auto_skip) |
1384 | { | 1442 | { |