summaryrefslogtreecommitdiff
path: root/apps/plugins/searchengine/dbinterface.c
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-07-01 17:29:44 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-07-01 17:29:44 +0000
commitc735ed79142a0260fc05d58cb0672e5d1720a26a (patch)
tree3fd67eb9fb598e9b8bc0c3003ec3bf037379ebb4 /apps/plugins/searchengine/dbinterface.c
parent4ec80704d5f34a167d45db7539f47b12cc23c59e (diff)
downloadrockbox-c735ed79142a0260fc05d58cb0672e5d1720a26a.zip
rockbox-c735ed79142a0260fc05d58cb0672e5d1720a26a.tar.gz
rockbox-c735ed79142a0260fc05d58cb0672e5d1720a26a.tar.bz2
rockbox-c735ed79142a0260fc05d58cb0672e5d1720a26a.tar.xz
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
Diffstat (limited to 'apps/plugins/searchengine/dbinterface.c')
-rw-r--r--apps/plugins/searchengine/dbinterface.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/apps/plugins/searchengine/dbinterface.c b/apps/plugins/searchengine/dbinterface.c
index c098079..e105106 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;i<sizeof(struct entry)*rb->tagdbheader->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() {