From 8102f3da270ce5a442523a1738318493906bb86a Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sat, 2 Jul 2005 10:50:42 +0000 Subject: 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 --- apps/database.c | 10 ++++++++++ apps/database.h | 1 + apps/lang/deutsch.lang | 8 +++++++- apps/lang/english.lang | 6 ++++++ apps/main.c | 1 - apps/settings.c | 1 + apps/settings.h | 1 + apps/settings_menu.c | 20 ++++++++++++++++++++ apps/tree.c | 5 ++++- 9 files changed, 50 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/database.c b/apps/database.c index bce1fb44cd..ad97b55ee7 100644 --- a/apps/database.c +++ b/apps/database.c @@ -315,6 +315,9 @@ int rundb_init(void) #endif 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) { @@ -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); diff --git a/apps/database.h b/apps/database.h index c1e2097f6a..a0e029072c 100644 --- a/apps/database.h +++ b/apps/database.h @@ -101,4 +101,5 @@ void loadruntimeinfo(char *filename); void increaseplaycount(void); void setrating(int rating); int rundb_init(void); +void rundb_shutdown(void); #endif diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang index 221c00732f..515b9135ab 100644 --- a/apps/lang/deutsch.lang +++ b/apps/lang/deutsch.lang @@ -3140,4 +3140,10 @@ id: LANG_NEXT_FOLDER 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" +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)" diff --git a/apps/lang/english.lang b/apps/lang/english.lang index abb7ca5fd6..fb0da889cd 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -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: diff --git a/apps/main.c b/apps/main.c index 71fabf2b87..513cda1fcb 100644 --- a/apps/main.c +++ b/apps/main.c @@ -289,7 +289,6 @@ void init(void) pcm_init_recording(); #endif talk_init(); - rundb_init(); #ifdef AUTOROCK { diff --git a/apps/settings.c b/apps/settings.c index 3bce8c7929..50a309d8da 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -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 */ diff --git a/apps/settings.h b/apps/settings.h index 78860fa700..46f410a2f4 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -322,6 +322,7 @@ struct user_settings #endif bool next_folder; /* move to next folder */ + bool runtimedb; /* runtime database active? */ }; enum optiontype { INT, BOOL }; diff --git a/apps/settings_menu.c b/apps/settings_menu.c index d7bf96aaff..3de8fa4b70 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -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; diff --git a/apps/tree.c b/apps/tree.c index 73bb3b77f2..8a2e661264 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -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,7 +1476,8 @@ 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); -- cgit v1.2.3