forked from len0rd/rockbox
Autorating should work now. at least. it would. but there is no runtime data to work with (yet)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6455 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f5eae08361
commit
f34e4ff6a4
3 changed files with 50 additions and 22 deletions
|
@ -33,7 +33,7 @@
|
||||||
#define FILERECORD2OFFSET(_x_) (rb->tagdbheader->filestart + _x_ * FILEENTRY_SIZE)
|
#define FILERECORD2OFFSET(_x_) (rb->tagdbheader->filestart + _x_ * FILEENTRY_SIZE)
|
||||||
|
|
||||||
struct entry *currententry;
|
struct entry *currententry;
|
||||||
|
struct dbglobals dbglobal;
|
||||||
static struct entry *entryarray;
|
static struct entry *entryarray;
|
||||||
|
|
||||||
int database_init() {
|
int database_init() {
|
||||||
|
@ -51,6 +51,9 @@ int database_init() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dbglobal.playcountmin=0;
|
||||||
|
dbglobal.playcountmax=0;
|
||||||
|
dbglobal.gotplaycountlimits=0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +87,7 @@ void loadentry(int filerecord) {
|
||||||
entryarray[filerecord].loadedfiledata=1;
|
entryarray[filerecord].loadedfiledata=1;
|
||||||
}
|
}
|
||||||
currententry=&entryarray[filerecord];
|
currententry=&entryarray[filerecord];
|
||||||
|
dbglobal.currententryindex=filerecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadsongdata() {
|
void loadsongdata() {
|
||||||
|
|
|
@ -16,6 +16,13 @@
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
struct dbglobals {
|
||||||
|
int playcountmin;
|
||||||
|
int playcountmax;
|
||||||
|
int gotplaycountlimits;
|
||||||
|
int currententryindex;
|
||||||
|
};
|
||||||
|
|
||||||
struct entry {
|
struct entry {
|
||||||
int loadedfiledata,
|
int loadedfiledata,
|
||||||
loadedsongdata,
|
loadedsongdata,
|
||||||
|
@ -40,6 +47,7 @@ struct entry {
|
||||||
|
|
||||||
extern struct entry *currententry;
|
extern struct entry *currententry;
|
||||||
extern struct entry *entryarray;
|
extern struct entry *entryarray;
|
||||||
|
extern struct dbglobals dbglobal;
|
||||||
|
|
||||||
int database_init(void);
|
int database_init(void);
|
||||||
void loadentry(int filerecord);
|
void loadentry(int filerecord);
|
||||||
|
|
|
@ -57,6 +57,7 @@ char *getstring(struct token *token) {
|
||||||
|
|
||||||
int getvalue(struct token *token) {
|
int getvalue(struct token *token) {
|
||||||
char buf[200];
|
char buf[200];
|
||||||
|
int index,i;
|
||||||
switch(token->kind) {
|
switch(token->kind) {
|
||||||
case TOKEN_NUM:
|
case TOKEN_NUM:
|
||||||
return token->intvalue;
|
return token->intvalue;
|
||||||
|
@ -72,8 +73,23 @@ int getvalue(struct token *token) {
|
||||||
loadrundbdata();
|
loadrundbdata();
|
||||||
return currententry->playcount;
|
return currententry->playcount;
|
||||||
case INTVALUE_AUTORATING:
|
case INTVALUE_AUTORATING:
|
||||||
// todo.
|
if(!dbglobal.gotplaycountlimits) {
|
||||||
return 0;
|
index=dbglobal.currententryindex;
|
||||||
|
dbglobal.playcountmax=0;
|
||||||
|
dbglobal.playcountmin=0xFFFFFFFF;
|
||||||
|
for(i=0;i<rb->tagdbheader->filecount;i++) {
|
||||||
|
loadentry(i);
|
||||||
|
loadrundbdata();
|
||||||
|
if(currententry->playcount>dbglobal.playcountmax)
|
||||||
|
dbglobal.playcountmax=currententry->playcount;
|
||||||
|
if(currententry->playcount<dbglobal.playcountmin)
|
||||||
|
dbglobal.playcountmin=currententry->playcount;
|
||||||
|
}
|
||||||
|
dbglobal.gotplaycountlimits=1;
|
||||||
|
loadentry(index);
|
||||||
|
}
|
||||||
|
loadrundbdata();
|
||||||
|
return (currententry->playcount-dbglobal.playcountmin)*10/(dbglobal.playcountmax-dbglobal.playcountmin);
|
||||||
default:
|
default:
|
||||||
rb->snprintf(buf,199,"unknown numid intvalue %d",token->intvalue);
|
rb->snprintf(buf,199,"unknown numid intvalue %d",token->intvalue);
|
||||||
rb->splash(HZ*2,true,buf);
|
rb->splash(HZ*2,true,buf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue