mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 07:05:57 -05:00
refactor for background updates
This commit is contained in:
parent
f09a7ae7d1
commit
625729613b
@ -218,11 +218,6 @@ int db_init(void) {
|
||||
MP3FILE mp3file;
|
||||
datum tmp_key,tmp_nextkey,song_data;
|
||||
|
||||
if((db_removed=rbinit(db_compare_rb_nodes,NULL)) == NULL) {
|
||||
errno=ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pl_register();
|
||||
|
||||
db_version_no=1;
|
||||
@ -236,12 +231,6 @@ int db_init(void) {
|
||||
MEMNOTIFY(tmp_key.dptr);
|
||||
|
||||
while(tmp_key.dptr) {
|
||||
/* Add it to the rbtree */
|
||||
if(!rbsearch((void*)tmp_key.dptr,db_removed)) {
|
||||
errno=ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Fetch that key */
|
||||
song_data=gdbm_fetch(db_songs,tmp_key);
|
||||
MEMNOTIFY(song_data.dptr);
|
||||
@ -256,7 +245,7 @@ int db_init(void) {
|
||||
|
||||
tmp_nextkey=gdbm_nextkey(db_songs,tmp_key);
|
||||
MEMNOTIFY(tmp_nextkey.dptr);
|
||||
// free(tmp_key.dptr); /* we'll free it in update mode */
|
||||
free(tmp_key.dptr);
|
||||
tmp_key=tmp_nextkey;
|
||||
db_song_count++;
|
||||
}
|
||||
@ -309,7 +298,34 @@ int db_version(void) {
|
||||
* Set the db to bulk import mode
|
||||
*/
|
||||
int db_start_initial_update(void) {
|
||||
datum tmp_key,tmp_nextkey;
|
||||
|
||||
if((db_removed=rbinit(db_compare_rb_nodes,NULL)) == NULL) {
|
||||
errno=ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* load up the red-black tree with all the current songs in the db */
|
||||
|
||||
tmp_key=gdbm_firstkey(db_songs);
|
||||
|
||||
MEMNOTIFY(tmp_key.dptr);
|
||||
|
||||
while(tmp_key.dptr) {
|
||||
/* Add it to the rbtree */
|
||||
if(!rbsearch((void*)tmp_key.dptr,db_removed)) {
|
||||
errno=ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tmp_nextkey=gdbm_nextkey(db_songs,tmp_key);
|
||||
MEMNOTIFY(tmp_nextkey.dptr);
|
||||
// free(tmp_key.dptr); /* we'll free it in update mode */
|
||||
tmp_key=tmp_nextkey;
|
||||
}
|
||||
|
||||
db_update_mode=1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,6 @@ void log_err(int quit, char *fmt, ...)
|
||||
****************************************************/
|
||||
void log_setdest(char *app, int destination) {
|
||||
switch(destination) {
|
||||
|
||||
case LOGDEST_SYSLOG:
|
||||
if(err_logdestination != LOGDEST_SYSLOG) {
|
||||
openlog(app,LOG_PID,LOG_DAEMON);
|
||||
@ -104,6 +103,8 @@ void log_setdest(char *app, int destination) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
err_logdestination=destination;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
|
@ -82,9 +82,9 @@ int scan_br_table[5][16] = {
|
||||
};
|
||||
|
||||
int scan_sample_table[3][4] = {
|
||||
{ 44100, 48000, 32000, 0 },
|
||||
{ 22050, 24000, 16000, 0 },
|
||||
{ 11025, 12000, 8000, 0 }
|
||||
{ 44100, 48000, 32000, 0 }, /* MPEG 1 */
|
||||
{ 22050, 24000, 16000, 0 }, /* MPEG 2 */
|
||||
{ 11025, 12000, 8000, 0 } /* MPEG 2.5 */
|
||||
};
|
||||
|
||||
|
||||
@ -879,7 +879,10 @@ int scan_get_aacfileinfo(char *file, MP3FILE *pmp3) {
|
||||
fseek(infile,16,SEEK_CUR);
|
||||
fread((void*)&temp_int,1,sizeof(int),infile);
|
||||
temp_int=ntohl(temp_int);
|
||||
pmp3->song_length=temp_int/600;
|
||||
if(temp_int > 720000)
|
||||
pmp3->song_length=temp_int / 90000; /* PlayFair? */
|
||||
else
|
||||
pmp3->song_length=temp_int/600;
|
||||
DPRINTF(ERR_DEBUG,"Song length: %d seconds\n",temp_int/600);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user