summaryrefslogtreecommitdiffstats
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-f96f7cd941.tar.gz
rockbox-f96f7cd941.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 @@
#define PLAYLIST_SKIPPED 0x10000000
static struct playlist_info current_playlist;
+/* REPEAT_ONE support functions */
+static long last_manual_skip_tick = 0;
+static inline bool is_manual_skip(void)
+{
+ return (last_manual_skip_tick + HZ/2 > current_tick);
+}
+
+static void track_change_callback(unsigned short id, void *param)
+{
+ (void)id;
+ unsigned int flags = ((struct track_event *)param)->flags;
+ if ((flags & TEF_AUTO_SKIP) != TEF_AUTO_SKIP)
+ {
+ last_manual_skip_tick = current_tick;
+ }
+}
+
+/* Directory Cache*/
static void dc_init_filerefs(struct playlist_info *playlist,
int start, int count)
{
@@ -1691,8 +1709,11 @@ static int get_next_index(const struct playlist_info* playlist, int steps,
if (repeat_mode == -1)
repeat_mode = global_settings.repeat_mode;
- if (repeat_mode == REPEAT_SHUFFLE && playlist->amount <= 1)
+ if ((repeat_mode == REPEAT_SHUFFLE && playlist->amount <= 1) ||
+ (repeat_mode == REPEAT_ONE && is_manual_skip()))
+ {
repeat_mode = REPEAT_ALL;
+ }
steps = calculate_step_count(playlist, steps);
switch (repeat_mode)
@@ -1964,6 +1985,7 @@ void playlist_init(void)
dc_thread_start(&current_playlist, false);
#endif /* HAVE_DIRCACHE */
+ add_event(PLAYBACK_EVENT_TRACK_CHANGE, track_change_callback);
}
/*
@@ -2823,35 +2845,40 @@ int playlist_next(int steps)
playlist_write_lock(playlist);
int index;
+ int repeat = global_settings.repeat_mode;
- if ( (steps > 0)
+ if (steps > 0)
+ {
+ if (repeat == REPEAT_ONE && is_manual_skip())
+ {
+ repeat = REPEAT_ALL;
+ }
#ifdef AB_REPEAT_ENABLE
- && (global_settings.repeat_mode != REPEAT_AB)
+ else if (repeat != REPEAT_ONE && repeat != REPEAT_AB)
+#else
+ else if (repeat != REPEAT_ONE)
#endif
- && (global_settings.repeat_mode != REPEAT_ONE) )
- {
- int i, j;
-
- /* We need to delete all the queued songs */
- for (i=0, j=steps; i<j; i++)
{
- index = get_next_index(playlist, i, -1);
-
- if (index >= 0 && playlist->indices[index] & PLAYLIST_QUEUE_MASK)
+ int i, j;
+ /* We need to delete all the queued songs */
+ for (i=0, j=steps; i<j; i++)
{
- remove_track_unlocked(playlist, index, true);
- steps--; /* one less track */
+ index = get_next_index(playlist, i, repeat);
+
+ if (index >= 0 && playlist->indices[index] & PLAYLIST_QUEUE_MASK)
+ {
+ remove_track_unlocked(playlist, index, true);
+ steps--; /* one less track */
+ }
}
}
- }
-
- index = get_next_index(playlist, steps, -1);
+ } /*steps > 0*/
+ index = get_next_index(playlist, steps, repeat);
if (index < 0)
{
/* end of playlist... or is it */
- if (global_settings.repeat_mode == REPEAT_SHUFFLE &&
- playlist->amount > 1)
+ if (repeat == REPEAT_SHUFFLE && playlist->amount > 1)
{
/* Repeat shuffle mode. Re-shuffle playlist and resume play */
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.
\item[All.] The current playlist will repeat when it is finished.
%
- \item[One. ]Repeat one track over and over.
+ \item[One. ]Repeat one track over and over unless track is manually skipped.
%
\item[Shuffle.] When the current playlist has finished playing, it will
be shuffled and then repeated.
@@ -324,4 +324,4 @@ you to configure settings related to audio playback.
To prefer loading album art that is stored in a separate image file, set to
\setting{Prefer Image File}. The default behavior is to
\setting{Prefer Embedded} album art.
-} \ No newline at end of file
+}