From 71a07bebe6b633a364424ed779a7d6bbfa0fa520 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 28 Aug 2002 09:22:44 +0000 Subject: modified the playlist system slightly: playlist_peek() returns info relative the current index playlist_next() advances the index back or forth (this breaks the build, mpeg fixes are pending) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2022 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 28 +++++++++++++++++++--------- apps/playlist.h | 3 ++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/playlist.c b/apps/playlist.c index 0052672e25..3dbbc9ea2d 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -64,7 +64,19 @@ int playlist_add(char *filename) return 0; } -char* playlist_next(int steps, int* index) +int playlist_next(int steps) +{ + playlist.index = (playlist.index+steps) % playlist.amount; + while ( playlist.index < 0 ) { + if ( global_settings.loop_playlist ) + playlist.index += playlist.amount; + else + playlist.index = 0; + } + return playlist.index; +} + +char* playlist_peek(int steps) { int seek; int max; @@ -73,19 +85,20 @@ char* playlist_next(int steps, int* index) char *buf; char dir_buf[MAX_PATH+1]; char *dir_end; + int index; if(abs(steps) > playlist.amount) /* prevent madness when all files are empty/bad */ return NULL; - playlist.index = (playlist.index+steps) % playlist.amount; - while ( playlist.index < 0 ) { + index = (playlist.index+steps) % playlist.amount; + while ( index < 0 ) { if ( global_settings.loop_playlist ) - playlist.index += playlist.amount; + index += playlist.amount; else - playlist.index = 0; + index = 0; } - seek = playlist.indices[playlist.index]; + seek = playlist.indices[index]; if(playlist.in_ram) { @@ -106,9 +119,6 @@ char* playlist_next(int steps, int* index) return NULL; } - if (index) - *index = playlist.index; - /* Zero-terminate the file name */ seek=0; while((buf[seek] != '\n') && diff --git a/apps/playlist.h b/apps/playlist.h index 5abeec3176..a18240db7f 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -42,7 +42,8 @@ extern bool playlist_shuffle; int play_list(char *dir, char *file, int start_index, bool shuffled_index, int start_offset, int random_seed ); -char* playlist_next(int steps, int* id); +char* playlist_peek(int steps); +int playlist_next(int steps); void randomise_playlist( unsigned int seed ); void sort_playlist(bool start_current); void empty_playlist(void); -- cgit v1.2.3