[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; 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 int
db_queue_get_count() db_queue_get_count()
{ {

View File

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

View File

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