summaryrefslogtreecommitdiffstats
path: root/apps/tagcache.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagcache.h')
-rw-r--r--apps/tagcache.h94
1 files changed, 26 insertions, 68 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h
index b64571de40..a20a13900a 100644
--- a/apps/tagcache.h
+++ b/apps/tagcache.h
@@ -25,6 +25,7 @@
#include "config.h"
#include "system.h"
#include "metadata.h"
+#include "settings.h"
/**
Note: When adding new tags, make sure to update index_entry_ec and tags_str in
@@ -38,70 +39,24 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
/* Real tags end here, count them. */
TAG_COUNT,
/* Virtual tags */
- tag_virt_basename, tag_virt_length_min, tag_virt_length_sec,
+ tag_virt_basename=TAG_COUNT,
+ tag_virt_length_min, tag_virt_length_sec,
tag_virt_playtime_min, tag_virt_playtime_sec,
- tag_virt_entryage, tag_virt_autoscore };
-
-/* Maximum length of a single tag. */
-#define TAG_MAXLEN (MAX_PATH*2)
-
-/* Allow a little drift to the filename ordering (should not be too high/low). */
-#define POS_HISTORY_COUNT 4
-
-/* How much to pre-load entries while committing to prevent seeking. */
-#define IDX_BUF_DEPTH 64
-
-/* Tag Cache Header version 'TCHxx'. Increment when changing internal structures. */
-#define TAGCACHE_MAGIC 0x54434810
-
-/* Dump store/restore header version 'TCSxx'. */
-#define TAGCACHE_STATEFILE_MAGIC 0x54435301
-
-/* How much to allocate extra space for ramcache. */
-#define TAGCACHE_RESERVE 32768
-
-/**
- * Define how long one entry must be at least (longer -> less memory at commit).
- * Must be at least 4 bytes in length for correct alignment.
- */
-#define TAGFILE_ENTRY_CHUNK_LENGTH 8
-
-/* Used to guess the necessary buffer size at commit. */
-#define TAGFILE_ENTRY_AVG_LENGTH 16
+ tag_virt_entryage, tag_virt_autoscore,
+ TAG_COUNT_ALL};
/* How many entries to fetch to the seek table at once while searching. */
#define SEEK_LIST_SIZE 32
-/* Always strict align entries for best performance and binary compatibility. */
-#define TAGCACHE_STRICT_ALIGN 1
-
-/* Max events in the internal tagcache command queue. */
-#define TAGCACHE_COMMAND_QUEUE_LENGTH 32
-/* Idle time before committing events in the command queue. */
-#define TAGCACHE_COMMAND_QUEUE_COMMIT_DELAY HZ*2
-
#define TAGCACHE_MAX_FILTERS 4
#define TAGCACHE_MAX_CLAUSES 32
-/* Tag database files. */
-
-/* Temporary database containing new tags to be committed to the main db. */
-#define TAGCACHE_FILE_TEMP ROCKBOX_DIR "/database_tmp.tcd"
-
-/* The main database master index and numeric data. */
-#define TAGCACHE_FILE_MASTER ROCKBOX_DIR "/database_idx.tcd"
-
-/* The main database string data. */
-#define TAGCACHE_FILE_INDEX ROCKBOX_DIR "/database_%d.tcd"
-
-/* ASCII dumpfile of the DB contents. */
-#define TAGCACHE_FILE_CHANGELOG ROCKBOX_DIR "/database_changelog.txt"
-
-/* Serialized DB. */
-#define TAGCACHE_STATEFILE ROCKBOX_DIR "/database_state.tcd"
-
/* Tag to be used on untagged files. */
#define UNTAGGED "<Untagged>"
+/* Maximum length of a single tag. */
+#define TAG_MAXLEN (MAX_PATH*2)
+/* buffer size for all the (stack allocated & static) buffers handling tc data */
+#define TAGCACHE_BUFSZ (TAG_MAXLEN+32)
/* Numeric tags (we can use these tags with conditional clauses). */
#define TAGCACHE_NUMERIC_TAGS ((1LU << tag_year) | (1LU << tag_discnumber) | \
@@ -115,35 +70,35 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
#define TAGCACHE_IS_NUMERIC(tag) (BIT_N(tag) & TAGCACHE_NUMERIC_TAGS)
-/* Flags */
-#define FLAG_DELETED 0x0001 /* Entry has been removed from db */
-#define FLAG_DIRCACHE 0x0002 /* Filename is a dircache pointer */
-#define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */
-#define FLAG_TRKNUMGEN 0x0008 /* Track number has been generated */
-#define FLAG_RESURRECTED 0x0010 /* Statistics data has been resurrected */
-
enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq,
clause_lt, clause_lteq, clause_contains, clause_not_contains,
clause_begins_with, clause_not_begins_with, clause_ends_with,
- clause_not_ends_with, clause_oneof, clause_logical_or };
+ clause_not_ends_with, clause_oneof,
+ clause_begins_oneof, clause_ends_oneof,
+ clause_logical_or };
struct tagcache_stat {
+ char db_path[MAX_PATHNAME+1]; /* Path to DB root directory */
+
bool initialized; /* Is tagcache currently busy? */
bool readyvalid; /* Has tagcache ready status been ascertained */
bool ready; /* Is tagcache ready to be used? */
bool ramcache; /* Is tagcache loaded in ram? */
bool commit_delayed; /* Has commit been delayed until next reboot? */
bool econ; /* Is endianess correction enabled? */
+ volatile bool syncscreen;/* Synchronous operation with debug screen? */
+ volatile const char
+ *curentry; /* Path of the current entry being scanned. */
+
int commit_step; /* Commit progress */
int ramcache_allocated; /* Has ram been allocated for ramcache? */
int ramcache_used; /* How much ram has been really used */
int progress; /* Current progress of disk scan */
int processed_entries; /* Scanned disk entries so far */
+ int total_entries; /* Total entries in tagcache */
int queue_length; /* Command queue length */
- volatile const char
- *curentry; /* Path of the current entry being scanned. */
- volatile bool syncscreen;/* Synchronous operation with debug screen? */
- // const char *uimessage; /* Pending error message. Implement soon. */
+
+ //const char *uimessage; /* Pending error message. Implement soon. */
};
enum source_type {source_constant,
@@ -186,7 +141,7 @@ struct tagcache_search {
int entry_count;
bool valid;
bool initialized;
- unsigned long *unique_list;
+ uint32_t *unique_list;
int unique_list_capacity;
int unique_list_count;
@@ -221,7 +176,7 @@ bool tagcache_search_add_filter(struct tagcache_search *tcs,
int tag, int seek);
bool tagcache_search_add_clause(struct tagcache_search *tcs,
struct tagcache_search_clause *clause);
-bool tagcache_get_next(struct tagcache_search *tcs);
+bool tagcache_get_next(struct tagcache_search *tcs, char *buf, long size);
bool tagcache_retrieve(struct tagcache_search *tcs, int idxid,
int tag, char *buf, long size);
void tagcache_search_finish(struct tagcache_search *tcs);
@@ -237,16 +192,19 @@ struct tagcache_stat* tagcache_get_stat(void);
int tagcache_get_commit_step(void);
bool tagcache_prepare_shutdown(void);
void tagcache_shutdown(void);
+void tagcache_remove_statefile(void);
void tagcache_screensync_event(void);
void tagcache_screensync_enable(bool state);
#ifdef HAVE_TC_RAMCACHE
+bool tagcache_is_in_ram(void);
#ifdef HAVE_DIRCACHE
bool tagcache_fill_tags(struct mp3entry *id3, const char *filename);
#endif
void tagcache_unload_ramcache(void);
#endif
+void tagcache_commit_finalize(void);
void tagcache_init(void) INIT_ATTR;
bool tagcache_is_initialized(void);
bool tagcache_is_fully_initialized(void);