forked from len0rd/rockbox
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
This commit is contained in:
parent
e4e3bce3b0
commit
04ed408de9
3 changed files with 23 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
14
apps/tree.c
14
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 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue