summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-09-17 14:56:25 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2023-09-18 22:48:21 -0400
commitf96f7cd9419c5140bd00c85c9d3b81e1e07a1105 (patch)
treedac2f517634b66bb1252ad44cb7af3758d8ee9c2
parent9242e4cadbbcc6a5101030ef4fd978b277427ab8 (diff)
downloadrockbox-f96f7cd9419c5140bd00c85c9d3b81e1e07a1105.tar.gz
rockbox-f96f7cd9419c5140bd00c85c9d3b81e1e07a1105.zip
[Feature] Skip to next file even if loop one is set.
repeat one till manually skipped https://forums.rockbox.org/index.php/topic,54218.0.html Change-Id: If2ea1cd892531c735c30c428dea3678806283a3b
-rw-r--r--apps/playlist.c65
-rw-r--r--manual/configure_rockbox/playback_options.tex4
2 files changed, 48 insertions, 21 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 69634fb96d..673b46c950 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -167,7 +167,25 @@
167#define PLAYLIST_SKIPPED 0x10000000 167#define PLAYLIST_SKIPPED 0x10000000
168 168
169static struct playlist_info current_playlist; 169static struct playlist_info current_playlist;
170/* REPEAT_ONE support functions */
171static long last_manual_skip_tick = 0;
170 172
173static inline bool is_manual_skip(void)
174{
175 return (last_manual_skip_tick + HZ/2 > current_tick);
176}
177
178static void track_change_callback(unsigned short id, void *param)
179{
180 (void)id;
181 unsigned int flags = ((struct track_event *)param)->flags;
182 if ((flags & TEF_AUTO_SKIP) != TEF_AUTO_SKIP)
183 {
184 last_manual_skip_tick = current_tick;
185 }
186}
187
188/* Directory Cache*/
171static void dc_init_filerefs(struct playlist_info *playlist, 189static void dc_init_filerefs(struct playlist_info *playlist,
172 int start, int count) 190 int start, int count)
173{ 191{
@@ -1691,8 +1709,11 @@ static int get_next_index(const struct playlist_info* playlist, int steps,
1691 if (repeat_mode == -1) 1709 if (repeat_mode == -1)
1692 repeat_mode = global_settings.repeat_mode; 1710 repeat_mode = global_settings.repeat_mode;
1693 1711
1694 if (repeat_mode == REPEAT_SHUFFLE && playlist->amount <= 1) 1712 if ((repeat_mode == REPEAT_SHUFFLE && playlist->amount <= 1) ||
1713 (repeat_mode == REPEAT_ONE && is_manual_skip()))
1714 {
1695 repeat_mode = REPEAT_ALL; 1715 repeat_mode = REPEAT_ALL;
1716 }
1696 1717
1697 steps = calculate_step_count(playlist, steps); 1718 steps = calculate_step_count(playlist, steps);
1698 switch (repeat_mode) 1719 switch (repeat_mode)
@@ -1964,6 +1985,7 @@ void playlist_init(void)
1964 1985
1965 dc_thread_start(&current_playlist, false); 1986 dc_thread_start(&current_playlist, false);
1966#endif /* HAVE_DIRCACHE */ 1987#endif /* HAVE_DIRCACHE */
1988 add_event(PLAYBACK_EVENT_TRACK_CHANGE, track_change_callback);
1967} 1989}
1968 1990
1969/* 1991/*
@@ -2823,35 +2845,40 @@ int playlist_next(int steps)
2823 playlist_write_lock(playlist); 2845 playlist_write_lock(playlist);
2824 2846
2825 int index; 2847 int index;
2848 int repeat = global_settings.repeat_mode;
2826 2849
2827 if ( (steps > 0) 2850 if (steps > 0)
2851 {
2852 if (repeat == REPEAT_ONE && is_manual_skip())
2853 {
2854 repeat = REPEAT_ALL;
2855 }
2828#ifdef AB_REPEAT_ENABLE 2856#ifdef AB_REPEAT_ENABLE
2829 && (global_settings.repeat_mode != REPEAT_AB) 2857 else if (repeat != REPEAT_ONE && repeat != REPEAT_AB)
2858#else
2859 else if (repeat != REPEAT_ONE)
2830#endif 2860#endif
2831 && (global_settings.repeat_mode != REPEAT_ONE) )
2832 {
2833 int i, j;
2834
2835 /* We need to delete all the queued songs */
2836 for (i=0, j=steps; i<j; i++)
2837 { 2861 {
2838 index = get_next_index(playlist, i, -1); 2862 int i, j;
2839 2863 /* We need to delete all the queued songs */
2840 if (index >= 0 && playlist->indices[index] & PLAYLIST_QUEUE_MASK) 2864 for (i=0, j=steps; i<j; i++)
2841 { 2865 {
2842 remove_track_unlocked(playlist, index, true); 2866 index = get_next_index(playlist, i, repeat);
2843 steps--; /* one less track */ 2867
2868 if (index >= 0 && playlist->indices[index] & PLAYLIST_QUEUE_MASK)
2869 {
2870 remove_track_unlocked(playlist, index, true);
2871 steps--; /* one less track */
2872 }
2844 } 2873 }
2845 } 2874 }
2846 } 2875 } /*steps > 0*/
2847 2876 index = get_next_index(playlist, steps, repeat);
2848 index = get_next_index(playlist, steps, -1);
2849 2877
2850 if (index < 0) 2878 if (index < 0)
2851 { 2879 {
2852 /* end of playlist... or is it */ 2880 /* end of playlist... or is it */
2853 if (global_settings.repeat_mode == REPEAT_SHUFFLE && 2881 if (repeat == REPEAT_SHUFFLE && playlist->amount > 1)
2854 playlist->amount > 1)
2855 { 2882 {
2856 /* Repeat shuffle mode. Re-shuffle playlist and resume play */ 2883 /* Repeat shuffle mode. Re-shuffle playlist and resume play */
2857 playlist->first_index = 0; 2884 playlist->first_index = 0;
diff --git a/manual/configure_rockbox/playback_options.tex b/manual/configure_rockbox/playback_options.tex
index efcaa5a181..68ad7042a0 100644
--- a/manual/configure_rockbox/playback_options.tex
+++ b/manual/configure_rockbox/playback_options.tex
@@ -26,7 +26,7 @@ you to configure settings related to audio playback.
26 \item[All.] The current playlist will repeat when it is finished. 26 \item[All.] The current playlist will repeat when it is finished.
27 27
28 % 28 %
29 \item[One. ]Repeat one track over and over. 29 \item[One. ]Repeat one track over and over unless track is manually skipped.
30 % 30 %
31 \item[Shuffle.] When the current playlist has finished playing, it will 31 \item[Shuffle.] When the current playlist has finished playing, it will
32 be shuffled and then repeated. 32 be shuffled and then repeated.
@@ -324,4 +324,4 @@ you to configure settings related to audio playback.
324 To prefer loading album art that is stored in a separate image file, set to 324 To prefer loading album art that is stored in a separate image file, set to
325 \setting{Prefer Image File}. The default behavior is to 325 \setting{Prefer Image File}. The default behavior is to
326 \setting{Prefer Embedded} album art. 326 \setting{Prefer Embedded} album art.
327} \ No newline at end of file 327}