diff options
-rw-r--r-- | apps/tagtree.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c index 126fb04678..1a49936f45 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -66,6 +66,10 @@ | |||
66 | 66 | ||
67 | static int tagtree_play_folder(struct tree_context* c); | 67 | static int tagtree_play_folder(struct tree_context* c); |
68 | 68 | ||
69 | /* reuse of tagtree data after tagtree_play_folder() */ | ||
70 | static uint32_t loaded_entries_crc = 0; | ||
71 | |||
72 | |||
69 | /* this needs to be same size as struct entry (tree.h) and name needs to be | 73 | /* this needs to be same size as struct entry (tree.h) and name needs to be |
70 | * the first; so that they're compatible enough to walk arrays of both | 74 | * the first; so that they're compatible enough to walk arrays of both |
71 | * derefencing the name member*/ | 75 | * derefencing the name member*/ |
@@ -280,6 +284,20 @@ static struct buflib_callbacks ops = { | |||
280 | .shrink_callback = NULL, | 284 | .shrink_callback = NULL, |
281 | }; | 285 | }; |
282 | 286 | ||
287 | static uint32_t tagtree_data_crc(struct tree_context* c) | ||
288 | { | ||
289 | char* buf; | ||
290 | uint32_t crc; | ||
291 | buf = core_get_data(tagtree_handle); /* data for the search clauses etc */ | ||
292 | crc = crc_32(buf, tagtree_buf_used, c->dirlength); | ||
293 | buf = core_get_data(c->cache.name_buffer_handle); /* names */ | ||
294 | crc = crc_32(buf, c->cache.name_buffer_size, crc); | ||
295 | buf = core_get_data(c->cache.entries_handle); /* tagentries */ | ||
296 | crc = crc_32(buf, c->cache.max_entries * sizeof(struct tagentry), crc); | ||
297 | logf("%s 0x%x", __func__, crc); | ||
298 | return crc; | ||
299 | } | ||
300 | |||
283 | static void* tagtree_alloc(size_t size) | 301 | static void* tagtree_alloc(size_t size) |
284 | { | 302 | { |
285 | size = ALIGN_UP(size, sizeof(void*)); | 303 | size = ALIGN_UP(size, sizeof(void*)); |
@@ -1813,6 +1831,8 @@ static int load_root(struct tree_context *c) | |||
1813 | 1831 | ||
1814 | int tagtree_load(struct tree_context* c) | 1832 | int tagtree_load(struct tree_context* c) |
1815 | { | 1833 | { |
1834 | logf( "%s", __func__); | ||
1835 | |||
1816 | int count; | 1836 | int count; |
1817 | int table = c->currtable; | 1837 | int table = c->currtable; |
1818 | 1838 | ||
@@ -1829,12 +1849,24 @@ int tagtree_load(struct tree_context* c) | |||
1829 | switch (table) | 1849 | switch (table) |
1830 | { | 1850 | { |
1831 | case TABLE_ROOT: | 1851 | case TABLE_ROOT: |
1852 | logf( "root..."); | ||
1832 | count = load_root(c); | 1853 | count = load_root(c); |
1833 | break; | 1854 | break; |
1834 | 1855 | ||
1835 | case TABLE_ALLSUBENTRIES: | 1856 | case TABLE_ALLSUBENTRIES: |
1836 | case TABLE_NAVIBROWSE: | 1857 | case TABLE_NAVIBROWSE: |
1837 | logf("navibrowse..."); | 1858 | logf("navibrowse..."); |
1859 | |||
1860 | if (loaded_entries_crc != 0) | ||
1861 | { | ||
1862 | if (loaded_entries_crc == tagtree_data_crc(c)) | ||
1863 | { | ||
1864 | count = c->dirlength; | ||
1865 | logf("Reusing %d entries", count); | ||
1866 | break; | ||
1867 | } | ||
1868 | } | ||
1869 | |||
1838 | cpu_boost(true); | 1870 | cpu_boost(true); |
1839 | count = retrieve_entries(c, 0, true); | 1871 | count = retrieve_entries(c, 0, true); |
1840 | cpu_boost(false); | 1872 | cpu_boost(false); |
@@ -1845,6 +1877,8 @@ int tagtree_load(struct tree_context* c) | |||
1845 | return -1; | 1877 | return -1; |
1846 | } | 1878 | } |
1847 | 1879 | ||
1880 | loaded_entries_crc = 0; | ||
1881 | |||
1848 | if (count < 0) | 1882 | if (count < 0) |
1849 | { | 1883 | { |
1850 | if (count != RELOAD_TAGTREE) | 1884 | if (count != RELOAD_TAGTREE) |
@@ -1877,6 +1911,8 @@ int tagtree_load(struct tree_context* c) | |||
1877 | */ | 1911 | */ |
1878 | int tagtree_enter(struct tree_context* c, bool is_visible) | 1912 | int tagtree_enter(struct tree_context* c, bool is_visible) |
1879 | { | 1913 | { |
1914 | logf( "%s", __func__); | ||
1915 | |||
1880 | int rc = 0; | 1916 | int rc = 0; |
1881 | struct tagentry *dptr; | 1917 | struct tagentry *dptr; |
1882 | struct mp3entry *id3; | 1918 | struct mp3entry *id3; |
@@ -2076,6 +2112,7 @@ int tagtree_enter(struct tree_context* c, bool is_visible) | |||
2076 | /* Exits current database menu or table */ | 2112 | /* Exits current database menu or table */ |
2077 | void tagtree_exit(struct tree_context* c, bool is_visible) | 2113 | void tagtree_exit(struct tree_context* c, bool is_visible) |
2078 | { | 2114 | { |
2115 | logf( "%s", __func__); | ||
2079 | if (is_visible) /* update selection history only for user-selected items */ | 2116 | if (is_visible) /* update selection history only for user-selected items */ |
2080 | { | 2117 | { |
2081 | if (c->selected_item != selected_item_history[c->dirlevel]) | 2118 | if (c->selected_item != selected_item_history[c->dirlevel]) |
@@ -2472,6 +2509,7 @@ int tagtree_add_to_playlist(const char* playlist, bool new_playlist) | |||
2472 | 2509 | ||
2473 | static int tagtree_play_folder(struct tree_context* c) | 2510 | static int tagtree_play_folder(struct tree_context* c) |
2474 | { | 2511 | { |
2512 | logf( "%s", __func__); | ||
2475 | int start_index = c->selected_item; | 2513 | int start_index = c->selected_item; |
2476 | 2514 | ||
2477 | if (playlist_create(NULL, NULL) < 0) | 2515 | if (playlist_create(NULL, NULL) < 0) |
@@ -2502,6 +2540,7 @@ static int tagtree_play_folder(struct tree_context* c) | |||
2502 | } | 2540 | } |
2503 | 2541 | ||
2504 | playlist_start(start_index, 0, 0); | 2542 | playlist_start(start_index, 0, 0); |
2543 | loaded_entries_crc = tagtree_data_crc(c); /* save crc in case we return */ | ||
2505 | return 0; | 2544 | return 0; |
2506 | } | 2545 | } |
2507 | 2546 | ||