Commit ceebb712 authored by Romain Vimont's avatar Romain Vimont Committed by Jean-Baptiste Kempf

randomizer: fix history cursor on insertion

New items must always be added _before_ the 'history' cursor, so they
will always move it to the right.

The confusion came from an earlier implementation, where "history == 0"
was synonymous with "no history" (and it was not possible to consider
the whole array as history).

Fixes #22305Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent f729a6b9
......@@ -423,18 +423,13 @@ randomizer_Next(struct randomizer *r)
bool
randomizer_Add(struct randomizer *r, vlc_playlist_item_t *items[], size_t count)
{
if (r->history)
{
if (!vlc_vector_insert_all(&r->items, r->history, items, count))
return false;
/* the insertion shifted history (and possibly next) */
if (r->next > r->history)
r->next += count;
r->history += count;
return true;
}
return vlc_vector_push_all(&r->items, items, count);
if (!vlc_vector_insert_all(&r->items, r->history, items, count))
return false;
/* the insertion shifted history (and possibly next) */
if (r->next > r->history)
r->next += count;
r->history += count;
return true;
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment