summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c28
1 files changed, 19 insertions, 9 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
67char* playlist_next(int steps, int* index) 67int 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
79char* 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') &&