1
0
Fork 0
forked from len0rd/rockbox

[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
This commit is contained in:
William Wilgus 2023-09-17 14:56:25 -04:00 committed by William Wilgus
parent 9242e4cadb
commit f96f7cd941
2 changed files with 49 additions and 22 deletions

View file

@ -167,7 +167,25 @@
#define PLAYLIST_SKIPPED 0x10000000 #define PLAYLIST_SKIPPED 0x10000000
static struct playlist_info current_playlist; 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, static void dc_init_filerefs(struct playlist_info *playlist,
int start, int count) int start, int count)
{ {
@ -1691,8 +1709,11 @@ static int get_next_index(const struct playlist_info* playlist, int steps,
if (repeat_mode == -1) if (repeat_mode == -1)
repeat_mode = global_settings.repeat_mode; 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; repeat_mode = REPEAT_ALL;
}
steps = calculate_step_count(playlist, steps); steps = calculate_step_count(playlist, steps);
switch (repeat_mode) switch (repeat_mode)
@ -1964,6 +1985,7 @@ void playlist_init(void)
dc_thread_start(&current_playlist, false); dc_thread_start(&current_playlist, false);
#endif /* HAVE_DIRCACHE */ #endif /* HAVE_DIRCACHE */
add_event(PLAYBACK_EVENT_TRACK_CHANGE, track_change_callback);
} }
/* /*
@ -2823,19 +2845,25 @@ int playlist_next(int steps)
playlist_write_lock(playlist); playlist_write_lock(playlist);
int index; 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 #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 #endif
&& (global_settings.repeat_mode != REPEAT_ONE) )
{ {
int i, j; int i, j;
/* We need to delete all the queued songs */ /* We need to delete all the queued songs */
for (i=0, j=steps; i<j; i++) for (i=0, j=steps; i<j; i++)
{ {
index = get_next_index(playlist, i, -1); index = get_next_index(playlist, i, repeat);
if (index >= 0 && playlist->indices[index] & PLAYLIST_QUEUE_MASK) if (index >= 0 && playlist->indices[index] & PLAYLIST_QUEUE_MASK)
{ {
@ -2844,14 +2872,13 @@ int playlist_next(int steps)
} }
} }
} }
} /*steps > 0*/
index = get_next_index(playlist, steps, -1); index = get_next_index(playlist, steps, repeat);
if (index < 0) if (index < 0)
{ {
/* end of playlist... or is it */ /* end of playlist... or is it */
if (global_settings.repeat_mode == REPEAT_SHUFFLE && if (repeat == REPEAT_SHUFFLE && playlist->amount > 1)
playlist->amount > 1)
{ {
/* Repeat shuffle mode. Re-shuffle playlist and resume play */ /* Repeat shuffle mode. Re-shuffle playlist and resume play */
playlist->first_index = 0; playlist->first_index = 0;

View file

@ -26,7 +26,7 @@ you to configure settings related to audio playback.
\item[All.] The current playlist will repeat when it is finished. \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 \item[Shuffle.] When the current playlist has finished playing, it will
be shuffled and then repeated. be shuffled and then repeated.