summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-08-30 07:52:36 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-08-30 07:52:36 +0000
commit196376c3c2b74a1f0f6f3040f833491d1b45e5f6 (patch)
tree928f9c50cf2413dfbd102c18d57585a1ee811466 /apps
parentd565269cfa71b23deae19c17494354855ab096d9 (diff)
Added ID3 database support for individual tracks in the context menu
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7421 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/dbtree.c16
-rw-r--r--apps/dbtree.h3
-rw-r--r--apps/onplay.c5
-rw-r--r--apps/tree.c20
4 files changed, 34 insertions, 10 deletions
diff --git a/apps/dbtree.c b/apps/dbtree.c
index 1121ea4070..e3704ac381 100644
--- a/apps/dbtree.c
+++ b/apps/dbtree.c
@@ -478,6 +478,22 @@ void db_exit(struct tree_context* c)
c->firstpos = c->pos_history[c->dirlevel];
}
+int db_get_filename(struct tree_context* c, char *buf, int buflen)
+{
+ int rc;
+ int filenum = c->dircursor + c->dirstart;
+ int pathoffset = ((int*)c->dircache)[filenum * c->dentry_size + 1];
+
+ lseek(tagdb_fd, pathoffset, SEEK_SET);
+ rc = read(tagdb_fd, buf, buflen);
+
+ if (rc < tagdbheader.songlen) {
+ DEBUGF("short path read(%ld) = %d\n", sizeof(buf), rc);
+ return -2;
+ }
+ return 0;
+}
+
static int db_play_folder(struct tree_context* c)
{
char buf[MAX_PATH];
diff --git a/apps/dbtree.h b/apps/dbtree.h
index 1e26f5d521..50d34b2a82 100644
--- a/apps/dbtree.h
+++ b/apps/dbtree.h
@@ -34,8 +34,7 @@ const char* db_get_icon(struct tree_context* c);
#else
int db_get_icon(struct tree_context* c);
#endif
-
-
+int db_get_filename(struct tree_context* c, char *buf, int buflen);
#endif
diff --git a/apps/onplay.c b/apps/onplay.c
index 89a236bb11..76bc72a048 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -278,7 +278,7 @@ static bool playlist_options(void)
pstart++;
}
- if (context == CONTEXT_TREE)
+ if (context == CONTEXT_TREE || context == CONTEXT_ID3DB)
{
if (audio_status() & AUDIO_STATUS_PLAY)
{
@@ -536,7 +536,8 @@ int onplay(char* file, int attr, int from)
if (context == CONTEXT_WPS ||
context == CONTEXT_TREE ||
- context == CONTEXT_ID3DB)
+ ((context == CONTEXT_ID3DB) &&
+ (attr & TREE_ATTR_MASK) == TREE_ATTR_MPA))
{
items[i].desc = ID2P(LANG_PLAYLIST);
items[i].function = playlist_options;
diff --git a/apps/tree.c b/apps/tree.c
index 8746145154..e56c7a76de 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -1041,13 +1041,8 @@ static bool dirbrowse(void)
if(!numentries)
onplay_result = onplay(NULL, 0, curr_context);
else {
- if (currdir[1])
- snprintf(buf, sizeof buf, "%s/%s",
- currdir, dircache[tc.dircursor+tc.dirstart].name);
- else
- snprintf(buf, sizeof buf, "/%s",
- dircache[tc.dircursor+tc.dirstart].name);
if (id3db)
+ {
switch (tc.currtable)
{
case allsongs:
@@ -1055,10 +1050,23 @@ static bool dirbrowse(void)
case songs4artist:
case searchsongs:
attr=TREE_ATTR_MPA;
+ db_get_filename(&tc, buf, sizeof(buf));
break;
}
+ }
else
+ {
attr = dircache[tc.dircursor+tc.dirstart].attr;
+
+ if (currdir[1])
+ snprintf(buf, sizeof buf, "%s/%s",
+ currdir,
+ dircache[tc.dircursor+tc.dirstart].name);
+ else
+ snprintf(buf, sizeof buf, "/%s",
+ dircache[tc.dircursor+tc.dirstart].name);
+ }
+
onplay_result = onplay(buf, attr, curr_context);
}