diff options
-rw-r--r-- | apps/tagcache.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index d09ddf486a..12d8776da2 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -56,7 +56,7 @@ | |||
56 | */ | 56 | */ |
57 | 57 | ||
58 | /*#define LOGF_ENABLE*/ | 58 | /*#define LOGF_ENABLE*/ |
59 | 59 | /*#define LOGF_CLAUSES define to enable logf clause matching (LOGF_ENABLE req'd) */ | |
60 | #include <stdio.h> | 60 | #include <stdio.h> |
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | #include <ctype.h> | 62 | #include <ctype.h> |
@@ -140,7 +140,31 @@ static const char *tags_str[] = { "artist", "album", "genre", "title", | |||
140 | "filename", "composer", "comment", "albumartist", "grouping", "year", | 140 | "filename", "composer", "comment", "albumartist", "grouping", "year", |
141 | "discnumber", "tracknumber", "canonicalartist", "bitrate", "length", | 141 | "discnumber", "tracknumber", "canonicalartist", "bitrate", "length", |
142 | "playcount", "rating", "playtime", "lastplayed", "commitid", "mtime", | 142 | "playcount", "rating", "playtime", "lastplayed", "commitid", "mtime", |
143 | "lastelapsed", "lastoffset" }; | 143 | "lastelapsed", "lastoffset" |
144 | #if !defined(LOGF_ENABLE) | ||
145 | }; | ||
146 | #define logf(...) do { } while(0) | ||
147 | #elif defined(LOGF_CLAUSES) /* strings for logf debugging */ | ||
148 | "tag_virt_basename", "tag_virt_length_min", "tag_virt_length_sec", | ||
149 | "tag_virt_playtime_min", "tag_virt_playtime_sec", | ||
150 | "tag_virt_entryage", "tag_virt_autoscore" | ||
151 | }; | ||
152 | /* more debug strings */ | ||
153 | static const char *tag_type_str[] = { | ||
154 | [clause_none] = "clause_none", [clause_is] = "clause_is", | ||
155 | [clause_is_not] = "clause_is_not", [clause_gt] = "clause_gt", | ||
156 | [clause_gteq] = "clause_gteq", [clause_lt] = "clause_lt", | ||
157 | [clause_lteq] = "clause_lteq", [clause_contains] = "clause_contains", | ||
158 | [clause_not_contains] = "clause_not_contains", | ||
159 | [clause_begins_with] = "clause_begins_with", | ||
160 | [clause_not_begins_with] = "clause_not_begins_with", | ||
161 | [clause_ends_with] = "clause_ends_with", | ||
162 | [clause_not_ends_with] = "clause_not_ends_with", | ||
163 | [clause_oneof] = "clause_oneof", | ||
164 | [clause_logical_or] = "clause_logical_or" | ||
165 | }; | ||
166 | #define logf_clause logf | ||
167 | #endif /* ndef LOGF_ENABLE */ | ||
144 | 168 | ||
145 | /* Status information of the tagcache. */ | 169 | /* Status information of the tagcache. */ |
146 | static struct tagcache_stat tc_stat; | 170 | static struct tagcache_stat tc_stat; |
@@ -999,6 +1023,7 @@ long tagcache_get_numeric(const struct tagcache_search *tcs, int tag) | |||
999 | 1023 | ||
1000 | inline static bool str_ends_with(const char *str1, const char *str2) | 1024 | inline static bool str_ends_with(const char *str1, const char *str2) |
1001 | { | 1025 | { |
1026 | logf_clauses("%s %s %s", str1, __func__, str2); | ||
1002 | int str_len = strlen(str1); | 1027 | int str_len = strlen(str1); |
1003 | int clause_len = strlen(str2); | 1028 | int clause_len = strlen(str2); |
1004 | 1029 | ||
@@ -1010,6 +1035,7 @@ inline static bool str_ends_with(const char *str1, const char *str2) | |||
1010 | 1035 | ||
1011 | inline static bool str_oneof(const char *str, const char *list) | 1036 | inline static bool str_oneof(const char *str, const char *list) |
1012 | { | 1037 | { |
1038 | logf_clauses("%s %s %s", str, __func__, list); | ||
1013 | const char *sep; | 1039 | const char *sep; |
1014 | int l, len = strlen(str); | 1040 | int l, len = strlen(str); |
1015 | 1041 | ||
@@ -1078,7 +1104,6 @@ static bool check_against_clause(long numeric, const char *str, | |||
1078 | return !str_ends_with(str, clause->str); | 1104 | return !str_ends_with(str, clause->str); |
1079 | case clause_oneof: | 1105 | case clause_oneof: |
1080 | return str_oneof(str, clause->str); | 1106 | return str_oneof(str, clause->str); |
1081 | |||
1082 | default: | 1107 | default: |
1083 | logf("Incorrect tag: %d", clause->type); | 1108 | logf("Incorrect tag: %d", clause->type); |
1084 | } | 1109 | } |
@@ -1102,10 +1127,17 @@ static bool check_clauses(struct tagcache_search *tcs, | |||
1102 | char *str = buf; | 1127 | char *str = buf; |
1103 | struct tagcache_search_clause *clause = clauses[i]; | 1128 | struct tagcache_search_clause *clause = clauses[i]; |
1104 | 1129 | ||
1130 | logf_clauses("%s clause %d %s %s [%ld] %s", | ||
1131 | "Checking", i, tag_type_str[clause->type], | ||
1132 | tags_str[clause->tag], clause->numeric_data, | ||
1133 | (clause->numeric || clause->str == NULL) ? "[NUMERIC?]" : clause->str); | ||
1134 | |||
1105 | if (clause->type == clause_logical_or) | 1135 | if (clause->type == clause_logical_or) |
1136 | { | ||
1137 | logf_clauses("Bailing"); | ||
1106 | break; /* all conditions before logical-or satisfied -- | 1138 | break; /* all conditions before logical-or satisfied -- |
1107 | stop processing clauses */ | 1139 | stop processing clauses */ |
1108 | 1140 | } | |
1109 | seek = check_virtual_tags(clause->tag, tcs->idx_id, idx); | 1141 | seek = check_virtual_tags(clause->tag, tcs->idx_id, idx); |
1110 | 1142 | ||
1111 | #ifdef HAVE_TC_RAMCACHE | 1143 | #ifdef HAVE_TC_RAMCACHE |
@@ -1190,6 +1222,11 @@ static bool check_clauses(struct tagcache_search *tcs, | |||
1190 | 1222 | ||
1191 | return false; | 1223 | return false; |
1192 | } | 1224 | } |
1225 | |||
1226 | logf_clauses("%s clause %d %s %s [%ld] %s", | ||
1227 | "Found", i, tag_type_str[clause->type], | ||
1228 | tags_str[clause->tag], clause->numeric_data, | ||
1229 | (clause->numeric || clause->str == NULL) ? "[NUMERIC?]" : clause->str); | ||
1193 | } | 1230 | } |
1194 | 1231 | ||
1195 | return true; | 1232 | return true; |
@@ -1238,7 +1275,7 @@ static bool add_uniqbuf(struct tagcache_search *tcs, uint32_t id) | |||
1238 | /* Return false if entry is found. */ | 1275 | /* Return false if entry is found. */ |
1239 | if (entry->u16[0] == id || entry->u16[1] == id) | 1276 | if (entry->u16[0] == id || entry->u16[1] == id) |
1240 | { | 1277 | { |
1241 | logf("%d Exists (16) @ %d", id, i); | 1278 | //logf("%d Exists (16) @ %d", id, i); |
1242 | return false; | 1279 | return false; |
1243 | } | 1280 | } |
1244 | 1281 | ||
@@ -1263,7 +1300,7 @@ static bool add_uniqbuf(struct tagcache_search *tcs, uint32_t id) | |||
1263 | /* Return false if entry is found. */ | 1300 | /* Return false if entry is found. */ |
1264 | if (tcs->unique_list[i] == id) | 1301 | if (tcs->unique_list[i] == id) |
1265 | { | 1302 | { |
1266 | logf("%d Exists (32)@ %d", id, i); | 1303 | //logf("%d Exists (32)@ %d", id, i); |
1267 | return false; | 1304 | return false; |
1268 | } | 1305 | } |
1269 | } | 1306 | } |