From c735ed79142a0260fc05d58cb0672e5d1720a26a Mon Sep 17 00:00:00 2001 From: Michiel Van Der Kolk Date: Fri, 1 Jul 2005 17:29:44 +0000 Subject: First runtime database support, self repairing, only playcount works for now, which is still rather crude; playcount gets increased even if the song started playback but was skipped... track rating should be trivial to add, autorating also works since its based on playcount. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6969 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/searchengine/dbinterface.c | 15 +++++++++++++-- apps/plugins/searchengine/dbinterface.h | 8 +++++--- apps/plugins/searchengine/token.h | 9 ++++----- 3 files changed, 22 insertions(+), 10 deletions(-) (limited to 'apps/plugins/searchengine') diff --git a/apps/plugins/searchengine/dbinterface.c b/apps/plugins/searchengine/dbinterface.c index c098079e35..e10510604d 100644 --- a/apps/plugins/searchengine/dbinterface.c +++ b/apps/plugins/searchengine/dbinterface.c @@ -29,6 +29,7 @@ #define FILEENTRY_SIZE (rb->tagdbheader->filelen+12) #define ALBUMENTRY_SIZE (rb->tagdbheader->albumlen+4+rb->tagdbheader->songarraylen*4) #define ARTISTENTRY_SIZE (rb->tagdbheader->artistlen+rb->tagdbheader->albumarraylen*4) +#define RUNDBENTRY_SIZE 20 #define FILERECORD2OFFSET(_x_) (rb->tagdbheader->filestart + _x_ * FILEENTRY_SIZE) @@ -45,7 +46,7 @@ int database_init() { // zero all entries. for(i=0;itagdbheader->filecount;i++) *(p++)=0; - if(*rb->tagdb_initialized!=1) { + if(!*rb->tagdb_initialized) { if(!rb->tagdb_init()) { // failed loading db return -1; @@ -110,8 +111,18 @@ void loadsongdata() { } void loadrundbdata() { - // we don't do this yet. currententry->loadedrundbdata=1; + if(!*rb->rundb_initialized) + return; + if(currententry->rundbentry==-1) + return; + rb->lseek(*rb->rundb_fd,currententry->rundbentry,SEEK_SET); + currententry->rundbfe=readlong(*rb->rundb_fd); + currententry->rundbhash=readlong(*rb->rundb_fd); + currententry->rating=readshort(*rb->rundb_fd); + currententry->voladj=readshort(*rb->rundb_fd); + currententry->playcount=readlong(*rb->rundb_fd); + currententry->lastplayed=readlong(*rb->rundb_fd); } void loadartistname() { diff --git a/apps/plugins/searchengine/dbinterface.h b/apps/plugins/searchengine/dbinterface.h index 98596aed2f..b168456b85 100644 --- a/apps/plugins/searchengine/dbinterface.h +++ b/apps/plugins/searchengine/dbinterface.h @@ -30,13 +30,15 @@ struct entry { loadedalbumname, loadedartistname; char *filename; - long hash; - long songentry; + long hash,rundbhash; + long songentry,rundbfe; long rundbentry; short year; short bitrate; - long rating; + short rating; long playcount; + long lastplayed; + short voladj; char *title; char *genre; long artistoffset; diff --git a/apps/plugins/searchengine/token.h b/apps/plugins/searchengine/token.h index cd337690bb..6deecd81a5 100644 --- a/apps/plugins/searchengine/token.h +++ b/apps/plugins/searchengine/token.h @@ -54,13 +54,12 @@ #define INTVALUE_GENRE 17 #define INTVALUE_FILENAME 18 -/* static char *spelling[] = { "not", "and", "or",">",">=","<", "<=","==","!=", - "contains","(",")" }; */ +#define SPELLING_LENGTH 100 struct token { - unsigned char kind; - char spelling[255]; // 255 should make it aligned again.. - long intvalue; + char kind; + char spelling[SPELLING_LENGTH + 3]; + long intvalue; }; char *getstring(struct token *token); -- cgit v1.2.3