diff options
-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 0052672e25..3dbbc9ea2d 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -64,7 +64,19 @@ int playlist_add(char *filename) | |||
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | 66 | ||
67 | char* playlist_next(int steps, int* index) | 67 | int playlist_next(int steps) |
68 | { | ||
69 | playlist.index = (playlist.index+steps) % playlist.amount; | ||
70 | while ( playlist.index < 0 ) { | ||
71 | if ( global_settings.loop_playlist ) | ||
72 | playlist.index += playlist.amount; | ||
73 | else | ||
74 | playlist.index = 0; | ||
75 | } | ||
76 | return playlist.index; | ||
77 | } | ||
78 | |||
79 | char* playlist_peek(int steps) | ||
68 | { | 80 | { |
69 | int seek; | 81 | int seek; |
70 | int max; | 82 | int max; |
@@ -73,19 +85,20 @@ char* playlist_next(int steps, int* index) | |||
73 | char *buf; | 85 | char *buf; |
74 | char dir_buf[MAX_PATH+1]; | 86 | char dir_buf[MAX_PATH+1]; |
75 | char *dir_end; | 87 | char *dir_end; |
88 | int index; | ||
76 | 89 | ||
77 | if(abs(steps) > playlist.amount) | 90 | if(abs(steps) > playlist.amount) |
78 | /* prevent madness when all files are empty/bad */ | 91 | /* prevent madness when all files are empty/bad */ |
79 | return NULL; | 92 | return NULL; |
80 | 93 | ||
81 | playlist.index = (playlist.index+steps) % playlist.amount; | 94 | index = (playlist.index+steps) % playlist.amount; |
82 | while ( playlist.index < 0 ) { | 95 | while ( index < 0 ) { |
83 | if ( global_settings.loop_playlist ) | 96 | if ( global_settings.loop_playlist ) |
84 | playlist.index += playlist.amount; | 97 | index += playlist.amount; |
85 | else | 98 | else |
86 | playlist.index = 0; | 99 | index = 0; |
87 | } | 100 | } |
88 | seek = playlist.indices[playlist.index]; | 101 | seek = playlist.indices[index]; |
89 | 102 | ||
90 | if(playlist.in_ram) | 103 | if(playlist.in_ram) |
91 | { | 104 | { |
@@ -106,9 +119,6 @@ char* playlist_next(int steps, int* index) | |||
106 | return NULL; | 119 | return NULL; |
107 | } | 120 | } |
108 | 121 | ||
109 | if (index) | ||
110 | *index = playlist.index; | ||
111 | |||
112 | /* Zero-terminate the file name */ | 122 | /* Zero-terminate the file name */ |
113 | seek=0; | 123 | seek=0; |
114 | while((buf[seek] != '\n') && | 124 | 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; | |||
42 | 42 | ||
43 | int play_list(char *dir, char *file, int start_index, | 43 | int play_list(char *dir, char *file, int start_index, |
44 | bool shuffled_index, int start_offset, int random_seed ); | 44 | bool shuffled_index, int start_offset, int random_seed ); |
45 | char* playlist_next(int steps, int* id); | 45 | char* playlist_peek(int steps); |
46 | int playlist_next(int steps); | ||
46 | void randomise_playlist( unsigned int seed ); | 47 | void randomise_playlist( unsigned int seed ); |
47 | void sort_playlist(bool start_current); | 48 | void sort_playlist(bool start_current); |
48 | void empty_playlist(void); | 49 | void empty_playlist(void); |