mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
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
This commit is contained in:
parent
a32653c80d
commit
f2a5439cea
3 changed files with 51 additions and 20 deletions
|
|
@ -130,7 +130,7 @@ int db_load(struct tree_context* c)
|
||||||
{
|
{
|
||||||
int i, offset, rc;
|
int i, offset, rc;
|
||||||
int dcachesize = global_settings.max_files_in_dir * sizeof(struct entry);
|
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* nptr = (void*) c->name_buffer;
|
||||||
unsigned int* dptr = c->dircache;
|
unsigned int* dptr = c->dircache;
|
||||||
unsigned int* safeplace = NULL;
|
unsigned int* safeplace = NULL;
|
||||||
|
|
@ -269,33 +269,30 @@ int db_load(struct tree_context* c)
|
||||||
stringlen = songlen;
|
stringlen = songlen;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case songs4artist:
|
||||||
|
/* 'extra' is offset to the artist, used as filter */
|
||||||
|
offset = songstart;
|
||||||
|
itemcount = songcount;
|
||||||
|
stringlen = songlen;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUGF("Unsupported table %d\n", table);
|
DEBUGF("Unsupported table %d\n", table);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
max_items = dcachesize / (c->dentry_size * sizeof(int));
|
|
||||||
end_of_nbuf -= safeplacelen;
|
end_of_nbuf -= safeplacelen;
|
||||||
|
|
||||||
c->dirlength = itemcount;
|
c->dirlength = itemcount;
|
||||||
itemcount -= c->firstpos;
|
itemcount -= c->firstpos;
|
||||||
|
|
||||||
if (!safeplace) {
|
if (!safeplace)
|
||||||
//DEBUGF("Seeking to %x\n", offset);
|
|
||||||
lseek(fd, offset, SEEK_SET);
|
lseek(fd, offset, SEEK_SET);
|
||||||
}
|
|
||||||
|
|
||||||
/* name_buffer (nptr) contains only names, null terminated.
|
/* name_buffer (nptr) contains only names, null terminated.
|
||||||
the first word of dcache (dptr) is a pointer to the name,
|
the first word of dcache (dptr) is a pointer to the name,
|
||||||
the rest is table specific. see below. */
|
the rest is table specific. see below. */
|
||||||
|
|
||||||
if (itemcount > max_items)
|
for ( i=0; i < itemcount; i++ ) {
|
||||||
c->dirfull = true;
|
|
||||||
|
|
||||||
if (max_items > itemcount) {
|
|
||||||
max_items = itemcount;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( i=0; i < max_items; i++ ) {
|
|
||||||
int rc, skip=0;
|
int rc, skip=0;
|
||||||
int intbuf[4];
|
int intbuf[4];
|
||||||
|
|
||||||
|
|
@ -316,17 +313,19 @@ int db_load(struct tree_context* c)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store name pointer in dir cache */
|
|
||||||
dptr[0] = (unsigned int)nptr;
|
|
||||||
|
|
||||||
switch (table) {
|
switch (table) {
|
||||||
case allsongs:
|
case allsongs:
|
||||||
case songs4album:
|
case songs4album:
|
||||||
|
case songs4artist:
|
||||||
rc = read(fd, intbuf, 12);
|
rc = read(fd, intbuf, 12);
|
||||||
if (rc < 12) {
|
if (rc < 12) {
|
||||||
DEBUGF("%d read(%d) returned %d\n", i, 12, rc);
|
DEBUGF("%d read(%d) returned %d\n", i, 12, rc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
/* continue to next song if wrong artist */
|
||||||
|
if (table == songs4artist && (int)BE32(intbuf[0]) != extra)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* save offset of filename */
|
/* save offset of filename */
|
||||||
dptr[1] = BE32(intbuf[2]);
|
dptr[1] = BE32(intbuf[2]);
|
||||||
break;
|
break;
|
||||||
|
|
@ -345,8 +344,13 @@ int db_load(struct tree_context* c)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* store name pointer in dir cache */
|
||||||
|
dptr[0] = (unsigned int)nptr;
|
||||||
|
|
||||||
if (skip)
|
if (skip)
|
||||||
lseek(fd, skip, SEEK_CUR);
|
lseek(fd, skip, SEEK_CUR);
|
||||||
|
|
||||||
|
hits++;
|
||||||
|
|
||||||
/* next name is stored immediately after this */
|
/* next name is stored immediately after this */
|
||||||
nptr = (void*)nptr + strlen((char*)nptr) + 1;
|
nptr = (void*)nptr + strlen((char*)nptr) + 1;
|
||||||
|
|
@ -354,15 +358,30 @@ int db_load(struct tree_context* c)
|
||||||
c->dirfull = true;
|
c->dirfull = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* limit dir buffer */
|
||||||
dptr = (void*)dptr + c->dentry_size * sizeof(int);
|
dptr = (void*)dptr + c->dentry_size * sizeof(int);
|
||||||
|
if ((void*)(dptr + c->dentry_size) >
|
||||||
|
(void*)(c->dircache + dcachesize))
|
||||||
|
{
|
||||||
|
c->dirfull = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!safeplace)
|
if (!safeplace)
|
||||||
offset += stringlen + skip;
|
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)
|
static int db_search(struct tree_context* c, char* string)
|
||||||
|
|
@ -476,7 +495,13 @@ int db_enter(struct tree_context* c)
|
||||||
case allalbums:
|
case allalbums:
|
||||||
case albums4artist:
|
case albums4artist:
|
||||||
case searchalbums:
|
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;
|
c->currextra = newextra;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -563,6 +588,7 @@ int db_get_icon(struct tree_context* c)
|
||||||
{
|
{
|
||||||
case allsongs:
|
case allsongs:
|
||||||
case songs4album:
|
case songs4album:
|
||||||
|
case songs4artist:
|
||||||
case searchsongs:
|
case searchsongs:
|
||||||
icon = File;
|
icon = File;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
|
||||||
enum table { invalid, root, allsongs, allalbums, allartists,
|
enum table { invalid, root, allsongs, allalbums, allartists,
|
||||||
albums4artist, songs4album,
|
albums4artist, songs4album, songs4artist,
|
||||||
search, searchartists, searchalbums, searchsongs };
|
search, searchartists, searchalbums, searchsongs };
|
||||||
|
|
||||||
int db_init(void);
|
int db_init(void);
|
||||||
|
|
|
||||||
|
|
@ -2986,3 +2986,8 @@ eng: "Free:"
|
||||||
voice: "Free diskspace:"
|
voice: "Free diskspace:"
|
||||||
new:
|
new:
|
||||||
|
|
||||||
|
id: LANG_ID3DB_ALL_SONGS
|
||||||
|
desc: ID3 virtual folder name
|
||||||
|
eng: "<All songs>"
|
||||||
|
voice: ""
|
||||||
|
new:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue