diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2006-07-22 07:09:57 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-07-22 07:09:57 +0000 |
commit | a47bd73f3ee0dc31ced98565485892a27a75fc97 (patch) | |
tree | a47c39339eddf32c02574e3097495f64368ad999 /apps | |
parent | b50e8935e11881f5257e4aa31229345e48789315 (diff) | |
download | rockbox-a47bd73f3ee0dc31ced98565485892a27a75fc97.tar.gz rockbox-a47bd73f3ee0dc31ced98565485892a27a75fc97.zip |
Removed the 10000 files static commmit-time limit from tagcache.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10278 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tagcache.c | 26 | ||||
-rw-r--r-- | apps/tagcache.h | 3 |
2 files changed, 19 insertions, 10 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 8df7aef8de..47786ad787 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -141,7 +141,9 @@ struct tempbuf_searchidx { | |||
141 | struct tempbuf_id_list idlist; | 141 | struct tempbuf_id_list idlist; |
142 | }; | 142 | }; |
143 | 143 | ||
144 | #define LOOKUP_BUF_DEPTH (TAGFILE_MAX_ENTRIES*2 \ | 144 | static long commit_entry_count; |
145 | |||
146 | #define LOOKUP_BUF_DEPTH (commit_entry_count*2 \ | ||
145 | * (TAGFILE_ENTRY_AVG_LENGTH/TAGFILE_ENTRY_CHUNK_LENGTH)) | 147 | * (TAGFILE_ENTRY_AVG_LENGTH/TAGFILE_ENTRY_CHUNK_LENGTH)) |
146 | 148 | ||
147 | struct tempbuf_searchidx **lookup; | 149 | struct tempbuf_searchidx **lookup; |
@@ -1276,7 +1278,7 @@ static bool tempbuf_insert(char *str, int id, int idx_id, bool unique) | |||
1276 | 1278 | ||
1277 | /* Insert it to the buffer. */ | 1279 | /* Insert it to the buffer. */ |
1278 | tempbuf_left -= len; | 1280 | tempbuf_left -= len; |
1279 | if (tempbuf_left - 4 < 0 || tempbufidx >= TAGFILE_MAX_ENTRIES-1) | 1281 | if (tempbuf_left - 4 < 0 || tempbufidx >= commit_entry_count-1) |
1280 | return false; | 1282 | return false; |
1281 | 1283 | ||
1282 | if (id >= 0 && id < LOOKUP_BUF_DEPTH) | 1284 | if (id >= 0 && id < LOOKUP_BUF_DEPTH) |
@@ -1536,18 +1538,28 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1536 | 1538 | ||
1537 | logf("Building index: %d", index_type); | 1539 | logf("Building index: %d", index_type); |
1538 | 1540 | ||
1541 | /* Check the number of entries we need to allocate ram for. */ | ||
1542 | commit_entry_count = h->entry_count + 1; | ||
1543 | |||
1544 | masterfd = open_master_fd(&tcmh, false); | ||
1545 | if (masterfd >= 0) | ||
1546 | { | ||
1547 | commit_entry_count += tcmh.tch.entry_count; | ||
1548 | close(masterfd); | ||
1549 | } | ||
1550 | |||
1539 | tempbufidx = 0; | 1551 | tempbufidx = 0; |
1540 | tempbuf_pos = TAGFILE_MAX_ENTRIES * sizeof(struct tempbuf_searchidx); | 1552 | tempbuf_pos = commit_entry_count * sizeof(struct tempbuf_searchidx); |
1541 | tempbuf_pos += LOOKUP_BUF_DEPTH * sizeof(void **); | 1553 | tempbuf_pos += LOOKUP_BUF_DEPTH * sizeof(void **); |
1542 | tempbuf_left = tempbuf_size - tempbuf_pos - 8; | 1554 | tempbuf_left = tempbuf_size - tempbuf_pos - 8; |
1543 | if (tempbuf_left - TAGFILE_ENTRY_AVG_LENGTH * TAGFILE_MAX_ENTRIES < 0) | 1555 | if (tempbuf_left - TAGFILE_ENTRY_AVG_LENGTH * commit_entry_count < 0) |
1544 | { | 1556 | { |
1545 | logf("Buffer way too small!"); | 1557 | logf("Buffer way too small!"); |
1546 | return 0; | 1558 | return 0; |
1547 | } | 1559 | } |
1548 | 1560 | ||
1549 | lookup = (struct tempbuf_searchidx **) | 1561 | lookup = (struct tempbuf_searchidx **) |
1550 | (tempbuf + sizeof(struct tempbuf_searchidx)*TAGFILE_MAX_ENTRIES); | 1562 | (tempbuf + sizeof(struct tempbuf_searchidx)*commit_entry_count); |
1551 | memset(lookup, 0, LOOKUP_BUF_DEPTH * sizeof(void **)); | 1563 | memset(lookup, 0, LOOKUP_BUF_DEPTH * sizeof(void **)); |
1552 | 1564 | ||
1553 | /* Open the index file, which contains the tag names. */ | 1565 | /* Open the index file, which contains the tag names. */ |
@@ -1610,7 +1622,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1610 | * table when the index gets resorted. | 1622 | * table when the index gets resorted. |
1611 | */ | 1623 | */ |
1612 | tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH | 1624 | tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH |
1613 | + TAGFILE_MAX_ENTRIES, entry.idx_id, | 1625 | + commit_entry_count, entry.idx_id, |
1614 | tagcache_is_unique_tag(index_type)); | 1626 | tagcache_is_unique_tag(index_type)); |
1615 | yield(); | 1627 | yield(); |
1616 | } | 1628 | } |
@@ -1804,7 +1816,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1804 | 1816 | ||
1805 | idxbuf[j].tag_seek[index_type] = tempbuf_find_location( | 1817 | idxbuf[j].tag_seek[index_type] = tempbuf_find_location( |
1806 | idxbuf[j].tag_seek[index_type]/TAGFILE_ENTRY_CHUNK_LENGTH | 1818 | idxbuf[j].tag_seek[index_type]/TAGFILE_ENTRY_CHUNK_LENGTH |
1807 | + TAGFILE_MAX_ENTRIES); | 1819 | + commit_entry_count); |
1808 | 1820 | ||
1809 | if (idxbuf[j].tag_seek[index_type] < 0) | 1821 | if (idxbuf[j].tag_seek[index_type] < 0) |
1810 | { | 1822 | { |
diff --git a/apps/tagcache.h b/apps/tagcache.h index 387f8ab74c..1752d3ec45 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -41,9 +41,6 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, | |||
41 | /* How much to allocate extra space for ramcache. */ | 41 | /* How much to allocate extra space for ramcache. */ |
42 | #define TAGCACHE_RESERVE 32768 | 42 | #define TAGCACHE_RESERVE 32768 |
43 | 43 | ||
44 | /* How many entries we can create in one tag file (for sorting). */ | ||
45 | #define TAGFILE_MAX_ENTRIES 10000 | ||
46 | |||
47 | /** | 44 | /** |
48 | * Define how long one entry must be at least (longer -> less memory at commit). | 45 | * Define how long one entry must be at least (longer -> less memory at commit). |
49 | * Must be at least 4 bytes in length for correct alignment. | 46 | * Must be at least 4 bytes in length for correct alignment. |