From 1f10c6a9283f6eb74ee1f2d705befe69bb4dba12 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sat, 30 Apr 2016 23:55:45 +0200 Subject: [PATCH] [player] Always reselect output devices when they return online Consider this use case: 1. Playback stops, device switched off 2. Device switched back on, playback started by user Before this commit, the device would be unselected when it came back on. I don't think that is desirable, so with this commit the selection will stay (except if the device comes back on during playback). --- src/player.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/player.c b/src/player.c index 38bd509e..8db0a89c 100644 --- a/src/player.c +++ b/src/player.c @@ -279,7 +279,6 @@ static uint64_t pb_pos; static uint64_t last_rtptime; /* Output devices */ -static int dev_autoselect; //TODO [player] Is this still necessary? static struct output_device *dev_list; /* Output status */ @@ -343,9 +342,6 @@ status_update(enum play_status status) player_state = status; listener_notify(LISTENER_PLAYER); - - if (status == PLAY_PLAYING) - dev_autoselect = 0; } @@ -1641,17 +1637,17 @@ device_remove(struct output_device *remove) if (!device) return; + /* Save device volume */ + ret = db_speaker_save(remove->id, remove->selected, remove->volume, remove->name); + if (ret < 0) + DPRINTF(E_LOG, L_PLAYER, "Could not save state for %s device '%s'\n", remove->type_name, remove->name); + DPRINTF(E_DBG, L_PLAYER, "Removing %s device '%s'; stopped advertising\n", remove->type_name, remove->name); /* Make sure device isn't selected anymore */ - if (device->selected) + if (remove->selected) speaker_deselect_output(remove); - /* Save device volume */ - ret = db_speaker_save(remove->id, 0, remove->volume, remove->name); - if (ret < 0) - DPRINTF(E_LOG, L_PLAYER, "Could not save state for %s device '%s'\n", remove->type_name, remove->name); - if (!prev) dev_list = remove->next; else @@ -1702,7 +1698,7 @@ device_add(struct player_command *cmd) device->volume = (master_volume >= 0) ? master_volume : PLAYER_DEFAULT_VOLUME; } - if (dev_autoselect && selected) + if (selected && (player_state != PLAY_PLAYING)) speaker_select_output(device); device->next = dev_list; @@ -4335,7 +4331,6 @@ player_init(void) clear_queue_on_stop_disabled = cfg_getbool(cfg_getsec(cfg, "mpd"), "clear_queue_on_stop_disable"); - dev_autoselect = 1; dev_list = NULL; master_volume = -1;