diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-10-04 08:48:20 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-10-04 08:48:20 +0000 |
commit | a6d0abb602985189b304648532053d7e61d54171 (patch) | |
tree | eb2a935fe1c3e8c0a8cd085544cf997c3ad0ea7d /apps/playlist.c | |
parent | a31bae655e92d85708a23b79ba27ace5fc2a185a (diff) | |
download | rockbox-a6d0abb602985189b304648532053d7e61d54171.tar.gz rockbox-a6d0abb602985189b304648532053d7e61d54171.zip |
Repeat off/all/one toggle. By Hardeep Sidhu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2498 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playlist.c')
-rw-r--r-- | apps/playlist.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index b81aed8763..038e710829 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -66,15 +66,37 @@ int playlist_add(char *filename) | |||
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | int playlist_next(int steps) | 69 | static int get_next_index(int steps) |
70 | { | 70 | { |
71 | playlist.index = (playlist.index+steps) % playlist.amount; | 71 | int next_index = -1; |
72 | while ( playlist.index < 0 ) { | 72 | |
73 | if ( global_settings.loop_playlist ) | 73 | switch (global_settings.repeat_mode) |
74 | playlist.index += playlist.amount; | 74 | { |
75 | else | 75 | case REPEAT_OFF: |
76 | playlist.index = 0; | 76 | next_index = playlist.index+steps; |
77 | if ((next_index < 0) || (next_index >= playlist.amount)) | ||
78 | next_index = -1; | ||
79 | break; | ||
80 | |||
81 | case REPEAT_ONE: | ||
82 | next_index = playlist.index; | ||
83 | break; | ||
84 | |||
85 | case REPEAT_ALL: | ||
86 | default: | ||
87 | next_index = (playlist.index+steps) % playlist.amount; | ||
88 | while (next_index < 0) | ||
89 | next_index += playlist.amount; | ||
90 | break; | ||
77 | } | 91 | } |
92 | |||
93 | return next_index; | ||
94 | } | ||
95 | |||
96 | int playlist_next(int steps) | ||
97 | { | ||
98 | playlist.index = get_next_index(steps); | ||
99 | |||
78 | return playlist.index; | 100 | return playlist.index; |
79 | } | 101 | } |
80 | 102 | ||
@@ -93,14 +115,11 @@ char* playlist_peek(int steps) | |||
93 | /* prevent madness when all files are empty/bad */ | 115 | /* prevent madness when all files are empty/bad */ |
94 | return NULL; | 116 | return NULL; |
95 | 117 | ||
96 | index = (playlist.index+steps) % playlist.amount; | 118 | index = get_next_index(steps); |
97 | while ( index < 0 ) { | 119 | if (index >= 0) |
98 | if ( global_settings.loop_playlist ) | ||
99 | index += playlist.amount; | ||
100 | else | ||
101 | index = 0; | ||
102 | } | ||
103 | seek = playlist.indices[index]; | 120 | seek = playlist.indices[index]; |
121 | else | ||
122 | return NULL; | ||
104 | 123 | ||
105 | if(playlist.in_ram) | 124 | if(playlist.in_ram) |
106 | { | 125 | { |