diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-08-06 13:10:51 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-08-06 13:10:51 +0000 |
commit | 4a4f17f416f245fa4eaf394b945b823d33615dfb (patch) | |
tree | 8b406d6dbaf4500dd10b03375a2c4eea46dbebc2 /apps | |
parent | 517ea2fa186b4fb694f0710a5cec8405ade1b5fe (diff) | |
download | rockbox-4a4f17f416f245fa4eaf394b945b823d33615dfb.tar.gz rockbox-4a4f17f416f245fa4eaf394b945b823d33615dfb.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tree.c | 62 |
1 files changed, 19 insertions, 43 deletions
diff --git a/apps/tree.c b/apps/tree.c index 0c46f86f11..308ea9c649 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -109,6 +109,21 @@ extern unsigned char bitmap_icons_6x8[LastIcon][6]; | |||
109 | #define TREE_ATTR_M3U 0x80 /* unused by FAT attributes */ | 109 | #define TREE_ATTR_M3U 0x80 /* unused by FAT attributes */ |
110 | #define TREE_ATTR_MP3 0x40 /* unused by FAT attributes */ | 110 | #define TREE_ATTR_MP3 0x40 /* unused by FAT attributes */ |
111 | 111 | ||
112 | static void build_playlist(int start_index) | ||
113 | { | ||
114 | int i; | ||
115 | |||
116 | playlist_clear(); | ||
117 | for(i = start_index;i < filesindir;i++) | ||
118 | { | ||
119 | if(dircacheptr[i]->attr & TREE_ATTR_MP3) | ||
120 | { | ||
121 | DEBUGF("Adding %s\n", dircacheptr[i]->name); | ||
122 | playlist_add(dircacheptr[i]->name); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
112 | static int compare(const void* p1, const void* p2) | 127 | static int compare(const void* p1, const void* p2) |
113 | { | 128 | { |
114 | struct entry* e1 = *(struct entry**)p1; | 129 | struct entry* e1 = *(struct entry**)p1; |
@@ -242,47 +257,7 @@ static char currdir[MAX_PATH]; | |||
242 | /* QUICK HACK! this should be handled by the playlist code later */ | 257 | /* QUICK HACK! this should be handled by the playlist code later */ |
243 | char* peek_next_track(int steps) | 258 | char* peek_next_track(int steps) |
244 | { | 259 | { |
245 | static char buf[MAX_PATH]; | 260 | return playlist_next(steps); |
246 | |||
247 | switch(play_mode) { | ||
248 | case 1: | ||
249 | /* play-full-dir mode */ | ||
250 | |||
251 | /* get next track in dir */ | ||
252 | if ( steps == 1 ) { | ||
253 | while (dircursor + start + 1 < numentries ) { | ||
254 | if(dircursor+1 < TREE_MAX_ON_SCREEN) | ||
255 | dircursor++; | ||
256 | else | ||
257 | start++; | ||
258 | if ( dircacheptr[dircursor+start]->attr & TREE_ATTR_MP3 ) { | ||
259 | snprintf(buf,sizeof buf,"%s/%s", | ||
260 | currdir, dircacheptr[dircursor+start]->name ); | ||
261 | return buf; | ||
262 | } | ||
263 | } | ||
264 | } | ||
265 | else { | ||
266 | while (dircursor + start > 0) { | ||
267 | if (dircursor > 0) | ||
268 | dircursor--; | ||
269 | else | ||
270 | start--; | ||
271 | if ( dircacheptr[dircursor+start]->attr & TREE_ATTR_MP3 ) { | ||
272 | snprintf(buf, sizeof(buf), "%s/%s", | ||
273 | currdir, dircacheptr[dircursor+start]->name); | ||
274 | return buf; | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | break; | ||
279 | |||
280 | case 2: | ||
281 | /* playlist mode */ | ||
282 | return playlist_next(steps, currdir); | ||
283 | } | ||
284 | |||
285 | return NULL; | ||
286 | } | 261 | } |
287 | 262 | ||
288 | bool dirbrowse(char *root) | 263 | bool dirbrowse(char *root) |
@@ -390,8 +365,9 @@ bool dirbrowse(char *root) | |||
390 | status_set_playmode(STATUS_PLAY); | 365 | status_set_playmode(STATUS_PLAY); |
391 | } | 366 | } |
392 | else { | 367 | else { |
393 | play_mode = 1; | 368 | build_playlist(dircursor+start); |
394 | mpeg_play(buf); | 369 | play_mode = 2; |
370 | play_list(currdir, NULL); | ||
395 | status_set_playmode(STATUS_PLAY); | 371 | status_set_playmode(STATUS_PLAY); |
396 | } | 372 | } |
397 | status_draw(); | 373 | status_draw(); |