diff options
author | Björn Stenberg <bjorn@haxx.se> | 2005-02-01 14:22:27 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2005-02-01 14:22:27 +0000 |
commit | f2a5439cea0a783421b4e32241a7ed29a0cdb837 (patch) | |
tree | 266f7603a93c5e5ab86b77cec11a85c4a9f1e297 /apps | |
parent | a32653c80dfdf4b0a392c2f9691d42c773d2cddd (diff) | |
download | rockbox-f2a5439cea0a783421b4e32241a7ed29a0cdb837.tar.gz rockbox-f2a5439cea0a783421b4e32241a7ed29a0cdb837.zip |
Added an <All songs> virtual folder to artist album list
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5733 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dbtree.c | 64 | ||||
-rw-r--r-- | apps/dbtree.h | 2 | ||||
-rw-r--r-- | apps/lang/english.lang | 5 |
3 files changed, 51 insertions, 20 deletions
diff --git a/apps/dbtree.c b/apps/dbtree.c index ef8d2e5628..58f70e2d2b 100644 --- a/apps/dbtree.c +++ b/apps/dbtree.c | |||
@@ -130,7 +130,7 @@ int db_load(struct tree_context* c) | |||
130 | { | 130 | { |
131 | int i, offset, rc; | 131 | int i, offset, rc; |
132 | int dcachesize = global_settings.max_files_in_dir * sizeof(struct entry); | 132 | int dcachesize = global_settings.max_files_in_dir * sizeof(struct entry); |
133 | int max_items, itemcount, stringlen; | 133 | int itemcount, stringlen, hits=0; |
134 | unsigned int* nptr = (void*) c->name_buffer; | 134 | unsigned int* nptr = (void*) c->name_buffer; |
135 | unsigned int* dptr = c->dircache; | 135 | unsigned int* dptr = c->dircache; |
136 | unsigned int* safeplace = NULL; | 136 | unsigned int* safeplace = NULL; |
@@ -269,33 +269,30 @@ int db_load(struct tree_context* c) | |||
269 | stringlen = songlen; | 269 | stringlen = songlen; |
270 | break; | 270 | break; |
271 | 271 | ||
272 | case songs4artist: | ||
273 | /* 'extra' is offset to the artist, used as filter */ | ||
274 | offset = songstart; | ||
275 | itemcount = songcount; | ||
276 | stringlen = songlen; | ||
277 | break; | ||
278 | |||
272 | default: | 279 | default: |
273 | DEBUGF("Unsupported table %d\n", table); | 280 | DEBUGF("Unsupported table %d\n", table); |
274 | return -1; | 281 | return -1; |
275 | } | 282 | } |
276 | max_items = dcachesize / (c->dentry_size * sizeof(int)); | ||
277 | end_of_nbuf -= safeplacelen; | 283 | end_of_nbuf -= safeplacelen; |
278 | 284 | ||
279 | c->dirlength = itemcount; | 285 | c->dirlength = itemcount; |
280 | itemcount -= c->firstpos; | 286 | itemcount -= c->firstpos; |
281 | 287 | ||
282 | if (!safeplace) { | 288 | if (!safeplace) |
283 | //DEBUGF("Seeking to %x\n", offset); | ||
284 | lseek(fd, offset, SEEK_SET); | 289 | lseek(fd, offset, SEEK_SET); |
285 | } | ||
286 | 290 | ||
287 | /* name_buffer (nptr) contains only names, null terminated. | 291 | /* name_buffer (nptr) contains only names, null terminated. |
288 | the first word of dcache (dptr) is a pointer to the name, | 292 | the first word of dcache (dptr) is a pointer to the name, |
289 | the rest is table specific. see below. */ | 293 | the rest is table specific. see below. */ |
290 | 294 | ||
291 | if (itemcount > max_items) | 295 | for ( i=0; i < itemcount; i++ ) { |
292 | c->dirfull = true; | ||
293 | |||
294 | if (max_items > itemcount) { | ||
295 | max_items = itemcount; | ||
296 | } | ||
297 | |||
298 | for ( i=0; i < max_items; i++ ) { | ||
299 | int rc, skip=0; | 296 | int rc, skip=0; |
300 | int intbuf[4]; | 297 | int intbuf[4]; |
301 | 298 | ||
@@ -316,17 +313,19 @@ int db_load(struct tree_context* c) | |||
316 | return -1; | 313 | return -1; |
317 | } | 314 | } |
318 | 315 | ||
319 | /* store name pointer in dir cache */ | ||
320 | dptr[0] = (unsigned int)nptr; | ||
321 | |||
322 | switch (table) { | 316 | switch (table) { |
323 | case allsongs: | 317 | case allsongs: |
324 | case songs4album: | 318 | case songs4album: |
319 | case songs4artist: | ||
325 | rc = read(fd, intbuf, 12); | 320 | rc = read(fd, intbuf, 12); |
326 | if (rc < 12) { | 321 | if (rc < 12) { |
327 | DEBUGF("%d read(%d) returned %d\n", i, 12, rc); | 322 | DEBUGF("%d read(%d) returned %d\n", i, 12, rc); |
328 | return -1; | 323 | return -1; |
329 | } | 324 | } |
325 | /* continue to next song if wrong artist */ | ||
326 | if (table == songs4artist && (int)BE32(intbuf[0]) != extra) | ||
327 | continue; | ||
328 | |||
330 | /* save offset of filename */ | 329 | /* save offset of filename */ |
331 | dptr[1] = BE32(intbuf[2]); | 330 | dptr[1] = BE32(intbuf[2]); |
332 | break; | 331 | break; |
@@ -345,8 +344,13 @@ int db_load(struct tree_context* c) | |||
345 | break; | 344 | break; |
346 | } | 345 | } |
347 | 346 | ||
347 | /* store name pointer in dir cache */ | ||
348 | dptr[0] = (unsigned int)nptr; | ||
349 | |||
348 | if (skip) | 350 | if (skip) |
349 | lseek(fd, skip, SEEK_CUR); | 351 | lseek(fd, skip, SEEK_CUR); |
352 | |||
353 | hits++; | ||
350 | 354 | ||
351 | /* next name is stored immediately after this */ | 355 | /* next name is stored immediately after this */ |
352 | nptr = (void*)nptr + strlen((char*)nptr) + 1; | 356 | nptr = (void*)nptr + strlen((char*)nptr) + 1; |
@@ -354,15 +358,30 @@ int db_load(struct tree_context* c) | |||
354 | c->dirfull = true; | 358 | c->dirfull = true; |
355 | break; | 359 | break; |
356 | } | 360 | } |
361 | |||
362 | /* limit dir buffer */ | ||
357 | dptr = (void*)dptr + c->dentry_size * sizeof(int); | 363 | dptr = (void*)dptr + c->dentry_size * sizeof(int); |
364 | if ((void*)(dptr + c->dentry_size) > | ||
365 | (void*)(c->dircache + dcachesize)) | ||
366 | { | ||
367 | c->dirfull = true; | ||
368 | break; | ||
369 | } | ||
358 | 370 | ||
359 | if (!safeplace) | 371 | if (!safeplace) |
360 | offset += stringlen + skip; | 372 | offset += stringlen + skip; |
361 | } | 373 | } |
362 | 374 | ||
363 | c->filesindir = i; | 375 | if (c->currtable == albums4artist && !c->dirfull) { |
376 | strcpy((char*)nptr, str(LANG_ID3DB_ALL_SONGS)); | ||
377 | dptr[0] = (unsigned int)nptr; | ||
378 | dptr[1] = extra; /* offset to artist */ | ||
379 | hits++; | ||
380 | } | ||
381 | |||
382 | c->filesindir = hits; | ||
364 | 383 | ||
365 | return i; | 384 | return hits; |
366 | } | 385 | } |
367 | 386 | ||
368 | static int db_search(struct tree_context* c, char* string) | 387 | static int db_search(struct tree_context* c, char* string) |
@@ -476,7 +495,13 @@ int db_enter(struct tree_context* c) | |||
476 | case allalbums: | 495 | case allalbums: |
477 | case albums4artist: | 496 | case albums4artist: |
478 | case searchalbums: | 497 | case searchalbums: |
479 | c->currtable = songs4album; | 498 | /* virtual <all albums> entry points to the artist, |
499 | all normal entries point to the album */ | ||
500 | if (newextra >= artiststart) | ||
501 | c->currtable = songs4artist; | ||
502 | else | ||
503 | c->currtable = songs4album; | ||
504 | |||
480 | c->currextra = newextra; | 505 | c->currextra = newextra; |
481 | break; | 506 | break; |
482 | 507 | ||
@@ -563,6 +588,7 @@ int db_get_icon(struct tree_context* c) | |||
563 | { | 588 | { |
564 | case allsongs: | 589 | case allsongs: |
565 | case songs4album: | 590 | case songs4album: |
591 | case songs4artist: | ||
566 | case searchsongs: | 592 | case searchsongs: |
567 | icon = File; | 593 | icon = File; |
568 | break; | 594 | break; |
diff --git a/apps/dbtree.h b/apps/dbtree.h index 5cf2e4feed..2c51b34a32 100644 --- a/apps/dbtree.h +++ b/apps/dbtree.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #include "tree.h" | 22 | #include "tree.h" |
23 | 23 | ||
24 | enum table { invalid, root, allsongs, allalbums, allartists, | 24 | enum table { invalid, root, allsongs, allalbums, allartists, |
25 | albums4artist, songs4album, | 25 | albums4artist, songs4album, songs4artist, |
26 | search, searchartists, searchalbums, searchsongs }; | 26 | search, searchartists, searchalbums, searchsongs }; |
27 | 27 | ||
28 | int db_init(void); | 28 | int db_init(void); |
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 5323fa0625..50bba13fdd 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -2986,3 +2986,8 @@ eng: "Free:" | |||
2986 | voice: "Free diskspace:" | 2986 | voice: "Free diskspace:" |
2987 | new: | 2987 | new: |
2988 | 2988 | ||
2989 | id: LANG_ID3DB_ALL_SONGS | ||
2990 | desc: ID3 virtual folder name | ||
2991 | eng: "<All songs>" | ||
2992 | voice: "" | ||
2993 | new: | ||