summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/pictureflow/pictureflow.c9
-rw-r--r--apps/tagcache.c77
-rw-r--r--apps/tagnavi.config9
-rw-r--r--apps/tagtree.c65
4 files changed, 90 insertions, 70 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 65446a1565..45c4e0fcda 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -1934,17 +1934,10 @@ static int pf_tcs_retrieve_track_title(int string_index, int disc_num, int track
1934 if (rb->strcmp(UNTAGGED, tcs.result) == 0) 1934 if (rb->strcmp(UNTAGGED, tcs.result) == 0)
1935 { 1935 {
1936 /* show filename instead of <untaggged> */ 1936 /* show filename instead of <untaggged> */
1937 if (!rb->tagcache_retrieve(&tcs, tcs.idx_id, tag_filename, 1937 if (!rb->tagcache_retrieve(&tcs, tcs.idx_id, tag_virt_basename,
1938 file_name, MAX_PATH)) 1938 file_name, MAX_PATH))
1939 return 0; 1939 return 0;
1940 track_title = file_name; 1940 track_title = file_name;
1941 if (track_title)
1942 {
1943 /* if filename remove the '/' */
1944 track_title = rb->strrchr(track_title, PATH_SEPCH);
1945 if (track_title)
1946 track_title++;
1947 }
1948 } 1941 }
1949 1942
1950 if (!track_title) 1943 if (!track_title)
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 60d82d002b..0e07c4804b 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -930,9 +930,17 @@ static bool open_files(struct tagcache_search *tcs, int tag)
930static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,) 930static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
931 struct index_entry *idx, int tag, char *buf, long bufsz) 931 struct index_entry *idx, int tag, char *buf, long bufsz)
932{ 932{
933 bool success = false;
934 bool is_basename = false;
933 struct tagfile_entry tfe; 935 struct tagfile_entry tfe;
934 long seek; 936 long seek;
935 937
938 if (tag == tag_virt_basename)
939 {
940 tag = tag_filename;
941 is_basename = true;
942 }
943
936 if (TAGCACHE_IS_NUMERIC(tag)) 944 if (TAGCACHE_IS_NUMERIC(tag))
937 goto failure; 945 goto failure;
938 946
@@ -950,7 +958,7 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
950 if (tag == tag_filename && (idx->flag & FLAG_DIRCACHE)) 958 if (tag == tag_filename && (idx->flag & FLAG_DIRCACHE))
951 { 959 {
952 if (dircache_get_fileref_path(&tcrc_dcfrefs[idx_id], buf, bufsz) >= 0) 960 if (dircache_get_fileref_path(&tcrc_dcfrefs[idx_id], buf, bufsz) >= 0)
953 return true; 961 success = true;
954 } 962 }
955 else 963 else
956#endif /* HAVE_DIRCACHE */ 964#endif /* HAVE_DIRCACHE */
@@ -959,13 +967,12 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
959 struct tagfile_entry *ep = 967 struct tagfile_entry *ep =
960 (struct tagfile_entry *)&tcramcache.hdr->tags[tag][seek]; 968 (struct tagfile_entry *)&tcramcache.hdr->tags[tag][seek];
961 strmemccpy(buf, ep->tag_data, bufsz); 969 strmemccpy(buf, ep->tag_data, bufsz);
962 970 success = true;
963 return true;
964 } 971 }
965 } 972 }
966#endif /* HAVE_TC_RAMCACHE */ 973#endif /* HAVE_TC_RAMCACHE */
967 974
968 if (open_files(tcs, tag)) 975 if (!success && open_files(tcs, tag))
969 { 976 {
970 lseek(tcs->idxfd[tag], seek, SEEK_SET); 977 lseek(tcs->idxfd[tag], seek, SEEK_SET);
971 switch (ecread_tagfile_entry_and_tag(tcs->idxfd[tag], &tfe, buf, bufsz)) 978 switch (ecread_tagfile_entry_and_tag(tcs->idxfd[tag], &tfe, buf, bufsz))
@@ -984,10 +991,22 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
984 break; 991 break;
985 case e_SUCCESS_LEN_ZERO: 992 case e_SUCCESS_LEN_ZERO:
986 case e_SUCCESS: 993 case e_SUCCESS:
987 return true; 994 success = true;
995 break;
988 } 996 }
989 } 997 }
990 998
999 if (success)
1000 {
1001 if (is_basename)
1002 {
1003 char* basename = strrchr(buf, '/');
1004 if (basename != NULL)
1005 memmove(buf, basename + 1, strlen(basename)); /* includes NULL */
1006 }
1007 return true;
1008 }
1009
991failure: 1010failure:
992 str_setlen(buf, 0); 1011 str_setlen(buf, 0);
993 return false; 1012 return false;
@@ -1284,7 +1303,7 @@ static bool check_clauses(struct tagcache_search *tcs,
1284 if (clause->tag == tag_filename 1303 if (clause->tag == tag_filename
1285 || clause->tag == tag_virt_basename) 1304 || clause->tag == tag_virt_basename)
1286 { 1305 {
1287 retrieve(tcs, IF_DIRCACHE(tcs->idx_id,) idx, tag_filename, 1306 retrieve(tcs, IF_DIRCACHE(tcs->idx_id,) idx, clause->tag,
1288 buf, bufsz); 1307 buf, bufsz);
1289 } 1308 }
1290 else 1309 else
@@ -1316,7 +1335,13 @@ static bool check_clauses(struct tagcache_search *tcs,
1316 case e_SUCCESS_LEN_ZERO: /* Check if entry has been deleted. */ 1335 case e_SUCCESS_LEN_ZERO: /* Check if entry has been deleted. */
1317 return false; 1336 return false;
1318 case e_SUCCESS: 1337 case e_SUCCESS:
1319 break; 1338 if (clause->tag == tag_virt_basename)
1339 {
1340 char *basename = strrchr(str, '/');
1341 if (basename)
1342 str = basename + 1;
1343 }
1344 break;
1320 case e_ENTRY_SIZEMISMATCH: 1345 case e_ENTRY_SIZEMISMATCH:
1321 logf("read error #15"); 1346 logf("read error #15");
1322 return false; 1347 return false;
@@ -1333,13 +1358,6 @@ static bool check_clauses(struct tagcache_search *tcs,
1333 } 1358 }
1334 } 1359 }
1335 1360
1336 if (clause->tag == tag_virt_basename)
1337 {
1338 char *basename = strrchr(str, '/');
1339 if (basename)
1340 str = basename + 1;
1341 }
1342
1343 if (!check_against_clause(seek, str, clause)) 1361 if (!check_against_clause(seek, str, clause))
1344 { 1362 {
1345 /* Clause failed -- try finding a logical-or clause */ 1363 /* Clause failed -- try finding a logical-or clause */
@@ -1709,7 +1727,7 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs,
1709 return true; 1727 return true;
1710} 1728}
1711 1729
1712static bool get_next(struct tagcache_search *tcs) 1730static bool get_next(struct tagcache_search *tcs, bool is_numeric)
1713{ 1731{
1714 /* WARNING pointers into buf are used in outside functions */ 1732 /* WARNING pointers into buf are used in outside functions */
1715 static char buf[TAGCACHE_BUFSZ]; 1733 static char buf[TAGCACHE_BUFSZ];
@@ -1719,11 +1737,6 @@ static bool get_next(struct tagcache_search *tcs)
1719 long flag = 0; 1737 long flag = 0;
1720#endif 1738#endif
1721 1739
1722 if (!tcs->valid || !tc_stat.ready)
1723 return false;
1724
1725 bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type);
1726
1727 if (tcs->idxfd[tcs->type] < 0 && !is_numeric 1740 if (tcs->idxfd[tcs->type] < 0 && !is_numeric
1728#ifdef HAVE_TC_RAMCACHE 1741#ifdef HAVE_TC_RAMCACHE
1729 && !tcs->ramsearch 1742 && !tcs->ramsearch
@@ -1849,9 +1862,6 @@ static bool get_next(struct tagcache_search *tcs)
1849 tcs->valid = false; 1862 tcs->valid = false;
1850 logf("read error #4"); 1863 logf("read error #4");
1851 return false; 1864 return false;
1852 default:
1853 logf("unknown_error");
1854 break;;
1855 } 1865 }
1856 1866
1857 /** 1867 /**
@@ -1871,12 +1881,15 @@ static bool get_next(struct tagcache_search *tcs)
1871 1881
1872bool tagcache_get_next(struct tagcache_search *tcs) 1882bool tagcache_get_next(struct tagcache_search *tcs)
1873{ 1883{
1874 while (get_next(tcs)) 1884 if (tcs->valid && tagcache_is_usable())
1875 { 1885 {
1876 if (tcs->result_len > 1) 1886 bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type);
1877 return true; 1887 while (get_next(tcs, is_numeric))
1888 {
1889 if (tcs->result_len > 1)
1890 return true;
1891 }
1878 } 1892 }
1879
1880#ifdef LOGF_ENABLE 1893#ifdef LOGF_ENABLE
1881 if (tcs->unique_list_count > 0) 1894 if (tcs->unique_list_count > 0)
1882 logf(" uniqbuf: %d used / %d avail", tcs->unique_list_count, tcs->unique_list_capacity); 1895 logf(" uniqbuf: %d used / %d avail", tcs->unique_list_count, tcs->unique_list_capacity);
@@ -2817,9 +2830,6 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
2817 logf("read error #8"); 2830 logf("read error #8");
2818 close(fd); 2831 close(fd);
2819 return -2; 2832 return -2;
2820 default:
2821 logf("unknown_error");
2822 break;;
2823 } 2833 }
2824 2834
2825 /** 2835 /**
@@ -3994,9 +4004,6 @@ static bool delete_entry(long idx_id)
3994 case e_TAG_SIZEMISMATCH: 4004 case e_TAG_SIZEMISMATCH:
3995 logf("delete_entry(): read error #3"); 4005 logf("delete_entry(): read error #3");
3996 goto cleanup; 4006 goto cleanup;
3997 default:
3998 logf("unknown_error");
3999 break;;
4000 } 4007 }
4001 4008
4002 myidx.tag_seek[tag] = crc_32(buf, strlen(buf), 0xffffffff); 4009 myidx.tag_seek[tag] = crc_32(buf, strlen(buf), 0xffffffff);
@@ -4519,10 +4526,6 @@ static bool check_file_refs(bool auto_update)
4519 4526
4520 switch (res) 4527 switch (res)
4521 { 4528 {
4522 default:
4523 logf("read error");
4524 ret = false;
4525 goto wend_finished;
4526 case e_ENTRY_SIZEMISMATCH: 4529 case e_ENTRY_SIZEMISMATCH:
4527 logf("size mismatch entry EOF?"); /* likely EOF */ 4530 logf("size mismatch entry EOF?"); /* likely EOF */
4528 ret = false; 4531 ret = false;
diff --git a/apps/tagnavi.config b/apps/tagnavi.config
index 74dfb1d1d9..6eda05ec44 100644
--- a/apps/tagnavi.config
+++ b/apps/tagnavi.config
@@ -14,7 +14,6 @@
14%format "fmt_title" "%d.%02d. %s - %02d:%02d" discnum tracknum title Lm Ls ? discnum > "0" 14%format "fmt_title" "%d.%02d. %s - %02d:%02d" discnum tracknum title Lm Ls ? discnum > "0"
15%format "fmt_title" "%02d. %s - %02d:%02d" tracknum title Lm Ls ? tracknum > "0" 15%format "fmt_title" "%02d. %s - %02d:%02d" tracknum title Lm Ls ? tracknum > "0"
16%format "fmt_title" "%s - %02d:%02d" title Lm Ls 16%format "fmt_title" "%s - %02d:%02d" title Lm Ls
17%format "fmt_alphanum_title" "%s - %02d:%02d (%s)" basename Lm Ls filename ? title == "<Untagged>"
18%format "fmt_alphanum_title" "%s - %02d:%02d" title Lm Ls 17%format "fmt_alphanum_title" "%s - %02d:%02d" title Lm Ls
19%format "fmt_mostplayed" "%2d|%3d %s (%s)" playcount autoscore title canonicalartist %sort = "inverse" %limit = "100" 18%format "fmt_mostplayed" "%2d|%3d %s (%s)" playcount autoscore title canonicalartist %sort = "inverse" %limit = "100"
20%format "fmt_lastplayed" "%06d%s - %s" lastplayed canonicalartist title %sort = "inverse" %limit = "99" %strip = "6" 19%format "fmt_lastplayed" "%06d%s - %s" lastplayed canonicalartist title %sort = "inverse" %limit = "99" %strip = "6"
@@ -165,6 +164,12 @@
165"New favourites" -> canonicalartist ? playcount <= "3" & autoscore > "85" -> album -> title = "fmt_best_tracks" 164"New favourites" -> canonicalartist ? playcount <= "3" & autoscore > "85" -> album -> title = "fmt_best_tracks"
166"Forgotten favourites" -> title = "fmt_forgotten" ? playcount > "3" & autoscore > "85" 165"Forgotten favourites" -> title = "fmt_forgotten" ? playcount > "3" & autoscore > "85"
167 166
167# Define track submenu
168%menu_start "track" "Tracks by"
169"Filename" -> basename
170"Title" -> title
171"Title mm:ss" -> title = "fmt_alphanum_title"
172
168# 173#
169# === Begin of main menu 174# === Begin of main menu
170# 175#
@@ -176,7 +181,7 @@
176"Album" -> album -> title = "fmt_title" 181"Album" -> album -> title = "fmt_title"
177"Genre" -> genre -> canonicalartist -> album -> title = "fmt_title" 182"Genre" -> genre -> canonicalartist -> album -> title = "fmt_title"
178"Composer" -> composer -> album -> title = "fmt_title" 183"Composer" -> composer -> album -> title = "fmt_title"
179"Track" -> title = "fmt_alphanum_title" 184"Track" ==> "track"
180"Year" -> year ? year > "0" -> canonicalartist -> album -> title = "fmt_title" 185"Year" -> year ? year > "0" -> canonicalartist -> album -> title = "fmt_title"
181"User Rating" -> rating -> title = "fmt_title" 186"User Rating" -> rating -> title = "fmt_title"
182"Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title" 187"Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title"
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 36126fd05e..ea7d0746b7 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -1328,7 +1328,7 @@ static int format_str(struct tagcache_search *tcs, struct display_format *fmt,
1328 int buf_pos = 0; 1328 int buf_pos = 0;
1329 int i; 1329 int i;
1330 1330
1331 memset(buf, 0, buf_size); 1331 /* memset(buf, 0, buf_size); probably uneeded */
1332 for (i = 0; fmt->formatstr[i] != '\0'; i++) 1332 for (i = 0; fmt->formatstr[i] != '\0'; i++)
1333 { 1333 {
1334 if (fmt->formatstr[i] == '%') 1334 if (fmt->formatstr[i] == '%')
@@ -1375,21 +1375,13 @@ static int format_str(struct tagcache_search *tcs, struct display_format *fmt,
1375 int tag = fmt->tags[parpos]; 1375 int tag = fmt->tags[parpos];
1376 1376
1377 if (!tagcache_retrieve(tcs, tcs->idx_id, 1377 if (!tagcache_retrieve(tcs, tcs->idx_id,
1378 (tag == tag_virt_basename ? 1378 tag, tmpbuf, sizeof tmpbuf))
1379 tag_filename : tag),
1380 tmpbuf, sizeof tmpbuf))
1381 { 1379 {
1382 logf("retrieve failed"); 1380 logf("retrieve failed");
1383 return -3; 1381 return -3;
1384 } 1382 }
1385 1383
1386 if (tag == tag_virt_basename 1384 result = tmpbuf;
1387 && (result = strrchr(tmpbuf, '/')) != NULL)
1388 {
1389 result++;
1390 }
1391 else
1392 result = tmpbuf;
1393 } 1385 }
1394 buf_pos += 1386 buf_pos +=
1395 snprintf(&buf[buf_pos], space_left, fmtbuf, result); 1387 snprintf(&buf[buf_pos], space_left, fmtbuf, result);
@@ -1424,6 +1416,19 @@ static struct tagentry* get_entries(struct tree_context *tc)
1424 return core_get_data(tc->cache.entries_handle); 1416 return core_get_data(tc->cache.entries_handle);
1425} 1417}
1426 1418
1419static void tcs_get_basename(struct tagcache_search *tcs, bool is_basename)
1420{
1421 if (is_basename)
1422 {
1423 char* basename = strrchr(tcs->result, '/');
1424 if (basename != NULL)
1425 {
1426 tcs->result = basename + 1;
1427 tcs->result_len = strlen(tcs->result) + 1;
1428 }
1429 }
1430}
1431
1427static int retrieve_entries(struct tree_context *c, int offset, bool init) 1432static int retrieve_entries(struct tree_context *c, int offset, bool init)
1428{ 1433{
1429 struct tagcache_search tcs; 1434 struct tagcache_search tcs;
@@ -1436,6 +1441,7 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
1436 int tag; 1441 int tag;
1437 bool sort = false; 1442 bool sort = false;
1438 bool sort_inverse; 1443 bool sort_inverse;
1444 bool is_basename = false;
1439 int sort_limit; 1445 int sort_limit;
1440 int strip; 1446 int strip;
1441 1447
@@ -1463,13 +1469,19 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
1463 if (tag == menu_reload) 1469 if (tag == menu_reload)
1464 return RELOAD_TAGTREE; 1470 return RELOAD_TAGTREE;
1465 1471
1472 if (tag == tag_virt_basename) /* basename shortcut */
1473 {
1474 is_basename = true;
1475 tag = tag_filename;
1476 }
1477
1466 if (!tagcache_search(&tcs, tag)) 1478 if (!tagcache_search(&tcs, tag))
1467 return -1; 1479 return -1;
1468 1480
1469 /* Prevent duplicate entries in the search list. */ 1481 /* Prevent duplicate entries in the search list. */
1470 tagcache_search_set_uniqbuf(&tcs, uniqbuf, UNIQBUF_SIZE); 1482 tagcache_search_set_uniqbuf(&tcs, uniqbuf, UNIQBUF_SIZE);
1471 1483
1472 if (level || csi->clause_count[0] || TAGCACHE_IS_NUMERIC(tag)) 1484 if (level || is_basename|| csi->clause_count[0] || TAGCACHE_IS_NUMERIC(tag))
1473 sort = true; 1485 sort = true;
1474 1486
1475 for (i = 0; i < level; i++) 1487 for (i = 0; i < level; i++)
@@ -1589,10 +1601,10 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
1589 if (strcmp(tcs.result, UNTAGGED) == 0) 1601 if (strcmp(tcs.result, UNTAGGED) == 0)
1590 { 1602 {
1591 if (tag == tag_title && tcs.type == tag_title && tcs.filter_count <= 1) 1603 if (tag == tag_title && tcs.type == tag_title && tcs.filter_count <= 1)
1592 { /* Fallback to filename */ 1604 { /* Fallback to basename */
1593 char *lastname = dptr->name; 1605 char *lastname = dptr->name;
1594 dptr->name = core_get_data(c->cache.name_buffer_handle)+namebufused; 1606 dptr->name = core_get_data(c->cache.name_buffer_handle)+namebufused;
1595 if (tagcache_retrieve(&tcs, tcs.idx_id, tag_filename, dptr->name, 1607 if (tagcache_retrieve(&tcs, tcs.idx_id, tag_virt_basename, dptr->name,
1596 c->cache.name_buffer_size - namebufused)) 1608 c->cache.name_buffer_size - namebufused))
1597 { 1609 {
1598 namebufused += strlen(dptr->name)+1; 1610 namebufused += strlen(dptr->name)+1;
@@ -1614,26 +1626,31 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
1614 { 1626 {
1615 int ret = format_str(&tcs, fmt, dptr->name, 1627 int ret = format_str(&tcs, fmt, dptr->name,
1616 c->cache.name_buffer_size - namebufused); 1628 c->cache.name_buffer_size - namebufused);
1617 if (ret == -4) /* buffer full */ 1629 if (ret >= 0)
1618 { 1630 {
1619 logf("chunk mode #2: %d", current_entry_count); 1631 namebufused += strlen(dptr->name)+1; /* include NULL */
1620 c->dirfull = true;
1621 sort = false;
1622 break ;
1623 } 1632 }
1624 else if (ret < 0) 1633 else
1625 { 1634 {
1635 dptr->name[0] = '\0';
1636 if (ret == -4) /* buffer full */
1637 {
1638 logf("chunk mode #2: %d", current_entry_count);
1639 c->dirfull = true;
1640 sort = false;
1641 break ;
1642 }
1643
1626 logf("format_str() failed"); 1644 logf("format_str() failed");
1627 tagcache_search_finish(&tcs); 1645 tagcache_search_finish(&tcs);
1628 tree_unlock_cache(c); 1646 tree_unlock_cache(c);
1629 core_unpin(tagtree_handle); 1647 core_unpin(tagtree_handle);
1630 return 0; 1648 return 0;
1631 } 1649 }
1632 else
1633 namebufused += strlen(dptr->name)+1;
1634 } 1650 }
1635 else 1651 else
1636 { 1652 {
1653 tcs_get_basename(&tcs, is_basename);
1637 namebufused += tcs.result_len; 1654 namebufused += tcs.result_len;
1638 if (namebufused < c->cache.name_buffer_size) 1655 if (namebufused < c->cache.name_buffer_size)
1639 strcpy(dptr->name, tcs.result); 1656 strcpy(dptr->name, tcs.result);
@@ -1647,8 +1664,10 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
1647 } 1664 }
1648 } 1665 }
1649 else 1666 else
1667 {
1668 tcs_get_basename(&tcs, is_basename);
1650 dptr->name = tcs.result; 1669 dptr->name = tcs.result;
1651 1670 }
1652entry_skip_formatter: 1671entry_skip_formatter:
1653 dptr++; 1672 dptr++;
1654 current_entry_count++; 1673 current_entry_count++;