forked from len0rd/rockbox
Better endian functions for reading longs/shorts
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6371 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4350eec6bb
commit
9ceac0a293
1 changed files with 26 additions and 18 deletions
|
@ -54,19 +54,33 @@ int database_init() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long readlong(int fd) {
|
||||||
|
long num;
|
||||||
|
rb->read(fd,&num,4);
|
||||||
|
#ifdef ROCKBOX_LITTLE_ENDIAN
|
||||||
|
num=BE32(num);
|
||||||
|
#endif
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
short readshort(int fd) {
|
||||||
|
short num;
|
||||||
|
rb->read(fd,&num,2);
|
||||||
|
#ifdef ROCKBOX_LITTLE_ENDIAN
|
||||||
|
num=BE16(num);
|
||||||
|
#endif
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void loadentry(int filerecord) {
|
void loadentry(int filerecord) {
|
||||||
if(entryarray[filerecord].loadedfiledata==0) {
|
if(entryarray[filerecord].loadedfiledata==0) {
|
||||||
rb->lseek(*rb->tagdb_fd,FILERECORD2OFFSET(filerecord),SEEK_SET);
|
rb->lseek(*rb->tagdb_fd,FILERECORD2OFFSET(filerecord),SEEK_SET);
|
||||||
entryarray[filerecord].filename=(char *)my_malloc(rb->tagdbheader->filelen);
|
entryarray[filerecord].filename=(char *)my_malloc(rb->tagdbheader->filelen);
|
||||||
rb->read(*rb->tagdb_fd,entryarray[filerecord].filename,rb->tagdbheader->filelen);
|
rb->read(*rb->tagdb_fd,entryarray[filerecord].filename,rb->tagdbheader->filelen);
|
||||||
rb->read(*rb->tagdb_fd,&entryarray[filerecord].hash,4);
|
entryarray[filerecord].hash=readlong(*rb->tagdb_fd);
|
||||||
rb->read(*rb->tagdb_fd,&entryarray[filerecord].songentry,4);
|
entryarray[filerecord].songentry=readlong(*rb->tagdb_fd);
|
||||||
rb->read(*rb->tagdb_fd,&entryarray[filerecord].rundbentry,4);
|
entryarray[filerecord].rundbentry=readlong(*rb->tagdb_fd);
|
||||||
#ifdef ROCKBOX_LITTLE_ENDIAN
|
|
||||||
entryarray[filerecord].hash=BE32(entryarray[filerecord].hash);
|
|
||||||
entryarray[filerecord].songentry=BE32(entryarray[filerecord].songentry);
|
|
||||||
entryarray[filerecord].rundbentry=BE32(entryarray[filerecord].rundbentry);
|
|
||||||
#endif
|
|
||||||
entryarray[filerecord].loadedfiledata=1;
|
entryarray[filerecord].loadedfiledata=1;
|
||||||
}
|
}
|
||||||
currententry=&entryarray[filerecord];
|
currententry=&entryarray[filerecord];
|
||||||
|
@ -80,18 +94,12 @@ void loadsongdata() {
|
||||||
currententry->genre=(char *)my_malloc(rb->tagdbheader->genrelen);
|
currententry->genre=(char *)my_malloc(rb->tagdbheader->genrelen);
|
||||||
rb->lseek(*rb->tagdb_fd,currententry->songentry,SEEK_SET);
|
rb->lseek(*rb->tagdb_fd,currententry->songentry,SEEK_SET);
|
||||||
rb->read(*rb->tagdb_fd,currententry->title,rb->tagdbheader->songlen);
|
rb->read(*rb->tagdb_fd,currententry->title,rb->tagdbheader->songlen);
|
||||||
rb->read(*rb->tagdb_fd,¤tentry->artistoffset,4);
|
currententry->artistoffset=readlong(*rb->tagdb_fd);
|
||||||
rb->read(*rb->tagdb_fd,¤tentry->albumoffset,4);
|
currententry->albumoffset=readlong(*rb->tagdb_fd);
|
||||||
rb->lseek(*rb->tagdb_fd,4,SEEK_CUR);
|
rb->lseek(*rb->tagdb_fd,4,SEEK_CUR);
|
||||||
rb->read(*rb->tagdb_fd,currententry->genre,rb->tagdbheader->genrelen);
|
rb->read(*rb->tagdb_fd,currententry->genre,rb->tagdbheader->genrelen);
|
||||||
rb->read(*rb->tagdb_fd,¤tentry->bitrate,2);
|
currententry->bitrate=readshort(*rb->tagdb_fd);
|
||||||
rb->read(*rb->tagdb_fd,¤tentry->year,2);
|
currententry->year=readshort(*rb->tagdb_fd);
|
||||||
#ifdef ROCKBOX_LITTLE_ENDIAN
|
|
||||||
currententry->artistoffset=BE32(currententry->artistoffset);
|
|
||||||
currententry->albumoffset=BE32(currententry->albumoffset);
|
|
||||||
currententry->bitrate=BE16(currententry->bitrate);
|
|
||||||
currententry->year=BE16(currententry->year);
|
|
||||||
#endif
|
|
||||||
currententry->loadedsongdata=1;
|
currententry->loadedsongdata=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue