summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2005-02-01 14:22:27 +0000
committerBjörn Stenberg <bjorn@haxx.se>2005-02-01 14:22:27 +0000
commitf2a5439cea0a783421b4e32241a7ed29a0cdb837 (patch)
tree266f7603a93c5e5ab86b77cec11a85c4a9f1e297
parenta32653c80dfdf4b0a392c2f9691d42c773d2cddd (diff)
downloadrockbox-f2a5439cea0a783421b4e32241a7ed29a0cdb837.tar.gz
rockbox-f2a5439cea0a783421b4e32241a7ed29a0cdb837.tar.bz2
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
-rw-r--r--apps/dbtree.c64
-rw-r--r--apps/dbtree.h2
-rw-r--r--apps/lang/english.lang5
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)
{
int i, offset, rc;
int dcachesize = global_settings.max_files_in_dir * sizeof(struct entry);
- int max_items, itemcount, stringlen;
+ int itemcount, stringlen, hits=0;
unsigned int* nptr = (void*) c->name_buffer;
unsigned int* dptr = c->dircache;
unsigned int* safeplace = NULL;
@@ -269,33 +269,30 @@ int db_load(struct tree_context* c)
stringlen = songlen;
break;
+ case songs4artist:
+ /* 'extra' is offset to the artist, used as filter */
+ offset = songstart;
+ itemcount = songcount;
+ stringlen = songlen;
+ break;
+
default:
DEBUGF("Unsupported table %d\n", table);
return -1;
}
- max_items = dcachesize / (c->dentry_size * sizeof(int));
end_of_nbuf -= safeplacelen;
c->dirlength = itemcount;
itemcount -= c->firstpos;
- if (!safeplace) {
- //DEBUGF("Seeking to %x\n", offset);
+ if (!safeplace)
lseek(fd, offset, SEEK_SET);
- }
/* name_buffer (nptr) contains only names, null terminated.
the first word of dcache (dptr) is a pointer to the name,
the rest is table specific. see below. */
- if (itemcount > max_items)
- c->dirfull = true;
-
- if (max_items > itemcount) {
- max_items = itemcount;
- }
-
- for ( i=0; i < max_items; i++ ) {
+ for ( i=0; i < itemcount; i++ ) {
int rc, skip=0;
int intbuf[4];
@@ -316,17 +313,19 @@ int db_load(struct tree_context* c)
return -1;
}
- /* store name pointer in dir cache */
- dptr[0] = (unsigned int)nptr;
-
switch (table) {
case allsongs:
case songs4album:
+ case songs4artist:
rc = read(fd, intbuf, 12);
if (rc < 12) {
DEBUGF("%d read(%d) returned %d\n", i, 12, rc);
return -1;
}
+ /* continue to next song if wrong artist */
+ if (table == songs4artist && (int)BE32(intbuf[0]) != extra)
+ continue;
+
/* save offset of filename */
dptr[1] = BE32(intbuf[2]);
break;
@@ -345,8 +344,13 @@ int db_load(struct tree_context* c)
break;
}
+ /* store name pointer in dir cache */
+ dptr[0] = (unsigned int)nptr;
+
if (skip)
lseek(fd, skip, SEEK_CUR);
+
+ hits++;
/* next name is stored immediately after this */
nptr = (void*)nptr + strlen((char*)nptr) + 1;
@@ -354,15 +358,30 @@ int db_load(struct tree_context* c)
c->dirfull = true;
break;
}
+
+ /* limit dir buffer */
dptr = (void*)dptr + c->dentry_size * sizeof(int);
+ if ((void*)(dptr + c->dentry_size) >
+ (void*)(c->dircache + dcachesize))
+ {
+ c->dirfull = true;
+ break;
+ }
if (!safeplace)
offset += stringlen + skip;
}
- c->filesindir = i;
+ if (c->currtable == albums4artist && !c->dirfull) {
+ strcpy((char*)nptr, str(LANG_ID3DB_ALL_SONGS));
+ dptr[0] = (unsigned int)nptr;
+ dptr[1] = extra; /* offset to artist */
+ hits++;
+ }
+
+ c->filesindir = hits;
- return i;
+ return hits;
}
static int db_search(struct tree_context* c, char* string)
@@ -476,7 +495,13 @@ int db_enter(struct tree_context* c)
case allalbums:
case albums4artist:
case searchalbums:
- c->currtable = songs4album;
+ /* virtual <all albums> entry points to the artist,
+ all normal entries point to the album */
+ if (newextra >= artiststart)
+ c->currtable = songs4artist;
+ else
+ c->currtable = songs4album;
+
c->currextra = newextra;
break;
@@ -563,6 +588,7 @@ int db_get_icon(struct tree_context* c)
{
case allsongs:
case songs4album:
+ case songs4artist:
case searchsongs:
icon = File;
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 @@
#include "tree.h"
enum table { invalid, root, allsongs, allalbums, allartists,
- albums4artist, songs4album,
+ albums4artist, songs4album, songs4artist,
search, searchartists, searchalbums, searchsongs };
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:"
voice: "Free diskspace:"
new:
+id: LANG_ID3DB_ALL_SONGS
+desc: ID3 virtual folder name
+eng: "<All songs>"
+voice: ""
+new: