[player/db] Increment queue version if shuffle mode is turned off

This fixes showing the wrong queue in the player web interface after
turing shuffle mode off.
This commit is contained in:
chme 2018-11-05 21:35:17 +01:00
parent 4cf71bafcc
commit 05141480e2
3 changed files with 35 additions and 16 deletions

View File

@ -5963,6 +5963,20 @@ db_queue_reshuffle(uint32_t item_id)
return ret;
}
/*
* Increment queue version (triggers queue change event)
*/
int
db_queue_inc_version()
{
int queue_version;
queue_version = queue_transaction_begin();
queue_transaction_end(0, queue_version);
return 0;
}
int
db_queue_get_count()
{

View File

@ -853,6 +853,9 @@ db_queue_move_byposrelativetoitem(uint32_t from_pos, uint32_t to_offset, uint32_
int
db_queue_reshuffle(uint32_t item_id);
int
db_queue_inc_version(void);
int
db_queue_get_count();

View File

@ -2852,29 +2852,31 @@ static enum command_state
shuffle_set(void *arg, int *retval)
{
union player_arg *cmdarg = arg;
char new_shuffle;
uint32_t cur_id;
switch (cmdarg->intval)
{
case 1:
if (!shuffle)
new_shuffle = (cmdarg->intval == 0) ? 0 : 1;
// Ignore unchanged shuffle mode requests
if (new_shuffle == shuffle)
goto out;
// Update queue and notify listeners
if (new_shuffle)
{
cur_id = cur_streaming ? cur_streaming->item_id : 0;
db_queue_reshuffle(cur_id);
}
/* FALLTHROUGH */
case 0:
shuffle = cmdarg->intval;
break;
default:
DPRINTF(E_LOG, L_PLAYER, "Invalid shuffle mode: %d\n", cmdarg->intval);
*retval = -1;
return COMMAND_END;
else
{
db_queue_inc_version();
}
// Update shuffle mode and notify listeners
shuffle = new_shuffle;
listener_notify(LISTENER_OPTIONS);
out:
*retval = 0;
return COMMAND_END;
}