New option to enable/disable the runtime database. Moved the runtimedb init to a more appropriate place and added proper USB handling.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6984 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-07-02 10:50:42 +00:00
parent a077b9ef12
commit 8102f3da27
9 changed files with 50 additions and 3 deletions

View file

@ -316,6 +316,9 @@ int rundb_init(void)
if(!tagdb_initialized) /* forget it.*/
return -1;
if(!global_settings.runtimedb) /* user doesn't care */
return -1;
rundb_fd = open(ROCKBOX_DIR "/rockbox.rundb", O_CREAT|O_RDWR);
if (rundb_fd < 0) {
DEBUGF("Failed opening database\n");
@ -358,6 +361,13 @@ int rundb_init(void)
#endif
}
void rundb_shutdown(void)
{
if (rundb_fd >= 0)
close(rundb_fd);
rundb_initialized = 0;
}
void writerundbheader(void)
{
lseek(rundb_fd,0,SEEK_SET);

View file

@ -101,4 +101,5 @@ void loadruntimeinfo(char *filename);
void increaseplaycount(void);
void setrating(int rating);
int rundb_init(void);
void rundb_shutdown(void);
#endif

View file

@ -3141,3 +3141,9 @@ desc: in settings_menu. Should we move to next folder when current one ends
eng: "Move to Next Folder"
voice: "In nächstes Verzeichnis wechseln"
new: "In nächstes Verzeichnis wechseln"
id: LANG_RUNTIMEDB_ACTIVE
desc: in settings_menu.
eng: "Gather runtime data (experimental)"
voice: "Spielzeitdaten sammeln"
new: "Spielzeitdaten sammeln (experimentell)"

View file

@ -3148,3 +3148,9 @@ desc: in settings_menu. Should we move to next folder when current one ends
eng: "Move to Next Folder"
voice: "Move to Next Folder"
new:
id: LANG_RUNTIMEDB_ACTIVE
desc: in settings_menu.
eng: "Gather runtime data (experimental)"
voice: "Gather runtime data"
new:

View file

@ -289,7 +289,6 @@ void init(void)
pcm_init_recording();
#endif
talk_init();
rundb_init();
#ifdef AUTOROCK
{

View file

@ -406,6 +406,7 @@ static const struct bit_entry hd_bits[] =
#endif
{1, S_O(next_folder), false, "move to next folder", off_on },
{1, S_O(runtimedb), false, "gather runtime data", off_on },
/* new stuff to be added at the end */

View file

@ -322,6 +322,7 @@ struct user_settings
#endif
bool next_folder; /* move to next folder */
bool runtimedb; /* runtime database active? */
};
enum optiontype { INT, BOOL };

View file

@ -46,6 +46,7 @@
#include "timefuncs.h"
#include "misc.h"
#include "power.h"
#include "database.h"
#ifdef HAVE_LCD_BITMAP
#include "peakmeter.h"
@ -1124,6 +1125,24 @@ static bool next_folder(void)
return set_bool( str(LANG_NEXT_FOLDER), &global_settings.next_folder );
}
static bool runtimedb(void)
{
bool rc;
bool old = global_settings.runtimedb;
rc = set_bool_options( str(LANG_RUNTIMEDB_ACTIVE),
&global_settings.runtimedb,
STR(LANG_SET_BOOL_YES),
STR(LANG_SET_BOOL_NO),
NULL);
if (old && !global_settings.runtimedb)
rundb_shutdown();
if (!old && global_settings.runtimedb)
rundb_init();
return rc;
}
static bool playback_settings_menu(void)
{
int m;
@ -1145,6 +1164,7 @@ static bool playback_settings_menu(void)
#endif
{ ID2P(LANG_ID3_ORDER), id3_order },
{ ID2P(LANG_NEXT_FOLDER), next_folder },
{ ID2P(LANG_RUNTIMEDB_ACTIVE), runtimedb },
};
bool old_shuffle = global_settings.playlist_shuffle;

View file

@ -569,6 +569,7 @@ static bool check_changed_id3mode(bool currmode)
static void tree_prepare_usb(void *parameter)
{
(void) parameter;
rundb_shutdown();
tagdb_shutdown();
}
@ -1120,6 +1121,7 @@ static bool dirbrowse(void)
== SYS_USB_CONNECTED)
{
tagdb_init(); /* re-init database */
rundb_init();
if(*tc.dirfilter > NUM_FILTER_MODES)
/* leave sub-browsers after usb, doing otherwise
might be confusing to the user */
@ -1474,6 +1476,7 @@ void tree_init(void)
tc.dirfilter = &global_settings.dirfilter;
tagdb_init();
rundb_init();
tc.name_buffer_size = AVERAGE_FILENAME_LENGTH * max_files;
tc.name_buffer = buffer_alloc(tc.name_buffer_size);