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/tagcache.c | |
parent | 58e32f18c8d2202adba3f2edeb0fc9d51e025b79 (diff) | |
download | rockbox-ea07cd5d7f0d1de6ee512ca247e5531c7eda8fce.tar.gz rockbox-ea07cd5d7f0d1de6ee512ca247e5531c7eda8fce.zip |
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/tagcache.c')
-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). */ | |||
49 | static long tempbuf_left; /* Buffer space left. */ | 49 | static long tempbuf_left; /* Buffer space left. */ |
50 | static long tempbuf_pos; | 50 | static long tempbuf_pos; |
51 | 51 | ||
52 | /* Tags we want to be unique (loaded to the tempbuf). */ | 52 | /* Tags we want to get sorted (loaded to the tempbuf). */ |
53 | static const int unique_tags[] = { tag_artist, tag_album, tag_genre, tag_title }; | 53 | static const int sorted_tags[] = { tag_artist, tag_album, tag_genre, tag_title }; |
54 | static const int unique_tags[] = { tag_artist, tag_album, tag_genre }; | ||
54 | 55 | ||
55 | /* Queue commands. */ | 56 | /* Queue commands. */ |
56 | #define Q_STOP_SCAN 0 | 57 | #define Q_STOP_SCAN 0 |
@@ -63,7 +64,7 @@ static const int unique_tags[] = { tag_artist, tag_album, tag_genre, tag_title } | |||
63 | #define TAGCACHE_FILE_INDEX ROCKBOX_DIR "/tagcache_%d.tcd" | 64 | #define TAGCACHE_FILE_INDEX ROCKBOX_DIR "/tagcache_%d.tcd" |
64 | 65 | ||
65 | /* Tag database structures. */ | 66 | /* Tag database structures. */ |
66 | #define TAGCACHE_MAGIC 0x01020316 | 67 | #define TAGCACHE_MAGIC 0x01020317 |
67 | 68 | ||
68 | /* Variable-length tag entry in tag files. */ | 69 | /* Variable-length tag entry in tag files. */ |
69 | struct tagfile_entry { | 70 | struct tagfile_entry { |
@@ -906,6 +907,19 @@ static bool is_unique_tag(int type) | |||
906 | return false; | 907 | return false; |
907 | } | 908 | } |
908 | 909 | ||
910 | static bool is_sorted_tag(int type) | ||
911 | { | ||
912 | int i; | ||
913 | |||
914 | for (i = 0; i < (int)(sizeof(sorted_tags)/sizeof(sorted_tags[0])); i++) | ||
915 | { | ||
916 | if (type == sorted_tags[i]) | ||
917 | return true; | ||
918 | } | ||
919 | |||
920 | return false; | ||
921 | } | ||
922 | |||
909 | static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) | 923 | static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) |
910 | { | 924 | { |
911 | int i; | 925 | int i; |
@@ -948,7 +962,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
948 | * it entirely into memory so we can resort it later for use with | 962 | * it entirely into memory so we can resort it later for use with |
949 | * chunked browsing. | 963 | * chunked browsing. |
950 | */ | 964 | */ |
951 | if (is_unique_tag(index_type)) | 965 | if (is_sorted_tag(index_type)) |
952 | { | 966 | { |
953 | for (i = 0; i < tch.entry_count; i++) | 967 | for (i = 0; i < tch.entry_count; i++) |
954 | { | 968 | { |
@@ -1075,7 +1089,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1075 | * Load new unique tags in memory to be sorted later and added | 1089 | * Load new unique tags in memory to be sorted later and added |
1076 | * to the master lookup file. | 1090 | * to the master lookup file. |
1077 | */ | 1091 | */ |
1078 | if (is_unique_tag(index_type)) | 1092 | if (is_sorted_tag(index_type)) |
1079 | { | 1093 | { |
1080 | lseek(tmpfd, sizeof(struct tagcache_header), SEEK_SET); | 1094 | lseek(tmpfd, sizeof(struct tagcache_header), SEEK_SET); |
1081 | /* h is the header of the temporary file containing new tags. */ | 1095 | /* 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) | |||
1107 | error = true; | 1121 | error = true; |
1108 | goto error_exit; | 1122 | goto error_exit; |
1109 | } | 1123 | } |
1110 | 1124 | ||
1111 | if (!tempbuf_unique_insert(buf, i)) | 1125 | if (is_unique_tag(index_type)) |
1126 | error = !tempbuf_unique_insert(buf, i); | ||
1127 | else | ||
1128 | error = !tempbuf_insert(buf, i); | ||
1129 | |||
1130 | if (error) | ||
1112 | { | 1131 | { |
1113 | logf("insert error"); | 1132 | logf("insert error"); |
1114 | error = true; | ||
1115 | goto error_exit; | 1133 | goto error_exit; |
1116 | } | 1134 | } |
1117 | 1135 | ||
@@ -1189,7 +1207,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1189 | } | 1207 | } |
1190 | 1208 | ||
1191 | /* Read entry headers. */ | 1209 | /* Read entry headers. */ |
1192 | if (!is_unique_tag(index_type)) | 1210 | if (!is_sorted_tag(index_type)) |
1193 | { | 1211 | { |
1194 | struct temp_file_entry entry; | 1212 | struct temp_file_entry entry; |
1195 | struct tagfile_entry fe; | 1213 | struct tagfile_entry fe; |
@@ -1259,7 +1277,7 @@ static bool build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1259 | } | 1277 | } |
1260 | 1278 | ||
1261 | /* Finally write the uniqued tag index file. */ | 1279 | /* Finally write the uniqued tag index file. */ |
1262 | if (is_unique_tag(index_type)) | 1280 | if (is_sorted_tag(index_type)) |
1263 | { | 1281 | { |
1264 | tch.magic = TAGCACHE_MAGIC; | 1282 | tch.magic = TAGCACHE_MAGIC; |
1265 | tch.entry_count = tempbufidx; | 1283 | tch.entry_count = tempbufidx; |