summaryrefslogtreecommitdiff
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
parent9b363c6cedc31f135e831a1b57dcf08578d34ee7 (diff)
downloadrockbox-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>
-rw-r--r--apps/playback.c58
-rw-r--r--lib/rbcodec/metadata/metadata.c65
-rw-r--r--lib/rbcodec/metadata/metadata.h4
3 files changed, 58 insertions, 69 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 */
1384enum { AUTORESUMABLE_UNKNOWN = 0, AUTORESUMABLE_TRUE, AUTORESUMABLE_FALSE };
1385static 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 */
1383static bool audio_start_codec(bool auto_skip) 1441static bool audio_start_codec(bool auto_skip)
1384{ 1442{
diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c
index 6837e97316..3fe9860441 100644
--- a/lib/rbcodec/metadata/metadata.c
+++ b/lib/rbcodec/metadata/metadata.c
@@ -25,7 +25,6 @@
25 25
26#include "debug.h" 26#include "debug.h"
27#include "logf.h" 27#include "logf.h"
28#include "settings.h"
29#include "cuesheet.h" 28#include "cuesheet.h"
30#include "metadata.h" 29#include "metadata.h"
31 30
@@ -571,67 +570,3 @@ void fill_metadata_from_path(struct mp3entry *id3, const char *trackname)
571 strlcpy(id3->path, trackname, sizeof (id3->path)); 570 strlcpy(id3->path, trackname, sizeof (id3->path));
572} 571}
573#endif /* CONFIG_CODEC == SWCODEC */ 572#endif /* CONFIG_CODEC == SWCODEC */
574
575#ifndef __PCTOOL__
576#ifdef HAVE_TAGCACHE
577#if CONFIG_CODEC == SWCODEC
578
579enum { AUTORESUMABLE_UNKNOWN = 0, AUTORESUMABLE_TRUE, AUTORESUMABLE_FALSE };
580
581bool autoresumable(struct mp3entry *id3)
582{
583 char *endp, *path;
584 size_t len;
585 bool is_resumable;
586
587 if (id3->autoresumable) /* result cached? */
588 return id3->autoresumable == AUTORESUMABLE_TRUE;
589
590 is_resumable = false;
591
592 if (id3->path)
593 {
594 for (path = global_settings.autoresume_paths;
595 *path; /* search terms left? */
596 path++)
597 {
598 if (*path == ':') /* Skip empty search patterns */
599 continue;
600
601 /* FIXME: As soon as strcspn or strchrnul are made available in
602 the core, the following can be made more efficient. */
603 endp = strchr(path, ':');
604 if (endp)
605 len = endp - path;
606 else
607 len = strlen(path);
608
609 /* Note: At this point, len is always > 0 */
610
611 if (strncasecmp(id3->path, path, len) == 0)
612 {
613 /* Full directory-name matches only. Trailing '/' in
614 search path OK. */
615 if (id3->path[len] == '/' || id3->path[len - 1] == '/')
616 {
617 is_resumable = true;
618 break;
619 }
620 }
621 path += len - 1;
622 }
623 }
624
625 /* cache result */
626 id3->autoresumable =
627 is_resumable ? AUTORESUMABLE_TRUE : AUTORESUMABLE_FALSE;
628
629 logf("autoresumable: %s is%s resumable",
630 id3->path, is_resumable ? "" : " not");
631
632 return is_resumable;
633}
634
635#endif /* SWCODEC */
636#endif /* HAVE_TAGCACHE */
637#endif /* __PCTOOL__ */
diff --git a/lib/rbcodec/metadata/metadata.h b/lib/rbcodec/metadata/metadata.h
index 5a1c17bc11..6d711aff28 100644
--- a/lib/rbcodec/metadata/metadata.h
+++ b/lib/rbcodec/metadata/metadata.h
@@ -344,10 +344,6 @@ bool rbcodec_format_is_atomic(int afmt);
344bool format_buffers_with_offset(int afmt); 344bool format_buffers_with_offset(int afmt);
345#endif 345#endif
346 346
347#ifdef HAVE_TAGCACHE
348bool autoresumable(struct mp3entry *id3);
349#endif
350
351#endif 347#endif
352 348
353 349