summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-08-06 13:10:51 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-08-06 13:10:51 +0000
commit4a4f17f416f245fa4eaf394b945b823d33615dfb (patch)
tree8b406d6dbaf4500dd10b03375a2c4eea46dbebc2
parent517ea2fa186b4fb694f0710a5cec8405ade1b5fe (diff)
downloadrockbox-4a4f17f416f245fa4eaf394b945b823d33615dfb.zip
rockbox-4a4f17f416f245fa4eaf394b945b823d33615dfb.tar.gz
rockbox-4a4f17f416f245fa4eaf394b945b823d33615dfb.tar.bz2
rockbox-4a4f17f416f245fa4eaf394b945b823d33615dfb.tar.xz
Now builds a RAM-based playlist when playing a directory
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1561 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/tree.c62
1 files changed, 19 insertions, 43 deletions
diff --git a/apps/tree.c b/apps/tree.c
index 0c46f86..308ea9c 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -109,6 +109,21 @@ extern unsigned char bitmap_icons_6x8[LastIcon][6];
#define TREE_ATTR_M3U 0x80 /* unused by FAT attributes */
#define TREE_ATTR_MP3 0x40 /* unused by FAT attributes */
+static void build_playlist(int start_index)
+{
+ int i;
+
+ playlist_clear();
+ for(i = start_index;i < filesindir;i++)
+ {
+ if(dircacheptr[i]->attr & TREE_ATTR_MP3)
+ {
+ DEBUGF("Adding %s\n", dircacheptr[i]->name);
+ playlist_add(dircacheptr[i]->name);
+ }
+ }
+}
+
static int compare(const void* p1, const void* p2)
{
struct entry* e1 = *(struct entry**)p1;
@@ -242,47 +257,7 @@ static char currdir[MAX_PATH];
/* QUICK HACK! this should be handled by the playlist code later */
char* peek_next_track(int steps)
{
- static char buf[MAX_PATH];
-
- switch(play_mode) {
- case 1:
- /* play-full-dir mode */
-
- /* get next track in dir */
- if ( steps == 1 ) {
- while (dircursor + start + 1 < numentries ) {
- if(dircursor+1 < TREE_MAX_ON_SCREEN)
- dircursor++;
- else
- start++;
- if ( dircacheptr[dircursor+start]->attr & TREE_ATTR_MP3 ) {
- snprintf(buf,sizeof buf,"%s/%s",
- currdir, dircacheptr[dircursor+start]->name );
- return buf;
- }
- }
- }
- else {
- while (dircursor + start > 0) {
- if (dircursor > 0)
- dircursor--;
- else
- start--;
- if ( dircacheptr[dircursor+start]->attr & TREE_ATTR_MP3 ) {
- snprintf(buf, sizeof(buf), "%s/%s",
- currdir, dircacheptr[dircursor+start]->name);
- return buf;
- }
- }
- }
- break;
-
- case 2:
- /* playlist mode */
- return playlist_next(steps, currdir);
- }
-
- return NULL;
+ return playlist_next(steps);
}
bool dirbrowse(char *root)
@@ -390,8 +365,9 @@ bool dirbrowse(char *root)
status_set_playmode(STATUS_PLAY);
}
else {
- play_mode = 1;
- mpeg_play(buf);
+ build_playlist(dircursor+start);
+ play_mode = 2;
+ play_list(currdir, NULL);
status_set_playmode(STATUS_PLAY);
}
status_draw();