summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-04-26 19:23:47 +0000
committerJens Arnold <amiconn@rockbox.org>2005-04-26 19:23:47 +0000
commit04ed408de9ea576a3b22ee44bac9483ca27124c6 (patch)
treea77c0bdbfe1fd236f589954723d908676ff73007
parente4e3bce3b0c5fff972f1b9068e16d0fee204571e (diff)
downloadrockbox-04ed408de9ea576a3b22ee44bac9483ca27124c6.tar.gz
rockbox-04ed408de9ea576a3b22ee44bac9483ca27124c6.tar.bz2
rockbox-04ed408de9ea576a3b22ee44bac9483ca27124c6.zip
ID3DB: Reload database when returning from USB mode. Fixed reload_root issue in id3db browse mode. The database is now properly closed before entering USB mode.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6358 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/dbtree.c11
-rw-r--r--apps/dbtree.h1
-rw-r--r--apps/tree.c14
3 files changed, 23 insertions, 3 deletions
diff --git a/apps/dbtree.c b/apps/dbtree.c
index 480564d39f..5b0d325213 100644
--- a/apps/dbtree.c
+++ b/apps/dbtree.c
@@ -64,14 +64,14 @@
#define ID3DB_VERSION 2
-static int fd;
+static int fd = -1;
static int
songstart, albumstart, artiststart, filestart,
songcount, albumcount, artistcount, filecount,
songlen, songarraylen, genrelen, filelen,
albumlen, albumarraylen,
- artistlen, rundbdirty,initialized = 0;
+ artistlen, rundbdirty, initialized = 0;
static int db_play_folder(struct tree_context* c);
static int db_search(struct tree_context* c, char* string);
@@ -137,6 +137,13 @@ int db_init(void)
return 0;
}
+void db_shutdown(void)
+{
+ if (fd >= 0)
+ close(fd);
+ initialized = 0;
+}
+
int db_load(struct tree_context* c)
{
int i, offset, rc;
diff --git a/apps/dbtree.h b/apps/dbtree.h
index 2c51b34a32..94453c59af 100644
--- a/apps/dbtree.h
+++ b/apps/dbtree.h
@@ -26,6 +26,7 @@ enum table { invalid, root, allsongs, allalbums, allartists,
search, searchartists, searchalbums, searchsongs };
int db_init(void);
+void db_shutdown(void);
int db_enter(struct tree_context* c);
void db_exit(struct tree_context* c);
int db_load(struct tree_context* c);
diff --git a/apps/tree.c b/apps/tree.c
index bd4fe37180..bcb96a8995 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -625,6 +625,12 @@ static bool check_changed_id3mode(bool currmode)
return currmode;
}
+static void tree_prepare_usb(void *parameter)
+{
+ (void) parameter;
+ db_shutdown();
+}
+
static bool dirbrowse(void)
{
int numentries=0;
@@ -1121,8 +1127,10 @@ static bool dirbrowse(void)
#endif
default:
- if(default_event_handler(button) == SYS_USB_CONNECTED)
+ if (default_event_handler_ex(button, tree_prepare_usb, NULL)
+ == SYS_USB_CONNECTED)
{
+ db_init(); /* re-init database */
if(*tc.dirfilter > NUM_FILTER_MODES)
/* leave sub-browsers after usb, doing otherwise
might be confusing to the user */
@@ -1160,6 +1168,10 @@ static bool dirbrowse(void)
if ( reload_root ) {
strcpy(currdir, "/");
tc.dirlevel = 0;
+ tc.currtable = 0;
+ tc.currextra = 0;
+ lasttable = -1;
+ lastextra = -1;
reload_root = false;
}
if (! reload_dir )