diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2006-03-27 07:44:32 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-03-27 07:44:32 +0000 |
commit | ea07cd5d7f0d1de6ee512ca247e5531c7eda8fce (patch) | |
tree | 6e992b900bc95358c67e832a02a36b0152885d16 /apps | |
parent | 58e32f18c8d2202adba3f2edeb0fc9d51e025b79 (diff) |
Allow multiple tracks with the same title.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9276 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tagcache.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 0c8a6aaa1d..3e1647018c 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -49,8 +49,9 @@ static long tempbuf_size; /* Buffer size (TEMPBUF_SIZE). */ static long tempbuf_left; /* Buffer space left. */ static long tempbuf_pos; -/* Tags we want to be unique (loaded to the tempbuf). */ -static const int unique_tags[] = { tag_artist, tag_album, tag_genre, tag_title }; +/* Tags we want to get sorted (loaded to the tempbuf). */ +static const int sorted_tags[] = { tag_artist, tag_album, tag_genre, tag_title }; +static const int unique_tags[] = { tag_artist, tag_album, tag_genre }; /* Queue commands. */ #define Q_STOP_SCAN 0 @@ -63,7 +64,7 @@ static const int unique_tags[] = { tag_artist, tag_album, tag_genre, tag_title } #define TAGCACHE_FILE_INDEX ROCKBOX_DIR "/tagcache_%d.tcd" /* Tag database structures. */ -#define TAGCACHE_MAGIC 0x01020316 +#define TAGCACHE_MAGIC 0x01020317 /* Variable-length tag entry in tag files. */ struct tagfile_entry { @@ -906,6 +907,19 @@ static bool is_unique_tag(int type) return false; } +static bool is_sorted_tag(int type) +{ + int i; + + for (i = 0; i < (int)(sizeof(sorted_tags)/sizeof(sorted_tags[0])); i++) + { + if (type == sorted_tags[i]) + return true; + } + + return false; +} + static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) { int i; @@ -948,7 +962,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) * it entirely into memory so we can resort it later for use with * chunked browsing. */ - if (is_unique_tag(index_type)) + if (is_sorted_tag(index_type)) { for (i = 0; i < tch.entry_count; i++) { @@ -1075,7 +1089,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) * Load new unique tags in memory to be sorted later and added * to the master lookup file. */ - if (is_unique_tag(index_type)) + if (is_sorted_tag(index_type)) { lseek(tmpfd, sizeof(struct tagcache_header), SEEK_SET); /* h is the header of the temporary file containing new tags. */ @@ -1107,11 +1121,15 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) error = true; goto error_exit; } - - if (!tempbuf_unique_insert(buf, i)) + + if (is_unique_tag(index_type)) + error = !tempbuf_unique_insert(buf, i); + else + error = !tempbuf_insert(buf, i); + + if (error) { logf("insert error"); - error = true; goto error_exit; } @@ -1189,7 +1207,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) } /* Read entry headers. */ - if (!is_unique_tag(index_type)) + if (!is_sorted_tag(index_type)) { struct temp_file_entry entry; struct tagfile_entry fe; @@ -1259,7 +1277,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) } /* Finally write the uniqued tag index file. */ - if (is_unique_tag(index_type)) + if (is_sorted_tag(index_type)) { tch.magic = TAGCACHE_MAGIC; tch.entry_count = tempbufidx; |