diff options
| author | Daniel Stenberg <daniel@haxx.se> | 2002-08-28 09:22:44 +0000 |
|---|---|---|
| committer | Daniel Stenberg <daniel@haxx.se> | 2002-08-28 09:22:44 +0000 |
| commit | 71a07bebe6b633a364424ed779a7d6bbfa0fa520 (patch) | |
| tree | bd1c4ea93710f1ca6115d6c952daf879f3aec409 | |
| parent | 728f5a7626d6672445fae31996c16b294de8ee5f (diff) | |
| download | rockbox-71a07bebe6b633a364424ed779a7d6bbfa0fa520.zip rockbox-71a07bebe6b633a364424ed779a7d6bbfa0fa520.tar.gz rockbox-71a07bebe6b633a364424ed779a7d6bbfa0fa520.tar.bz2 rockbox-71a07bebe6b633a364424ed779a7d6bbfa0fa520.tar.xz | |
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
| -rw-r--r-- | apps/playlist.c | 28 | ||||
| -rw-r--r-- | apps/playlist.h | 3 |
2 files changed, 21 insertions, 10 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 0052672..3dbbc9e 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 5abeec3..a18240d 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); |