[rcp] bug fix - speaker unselection upon restart / obey volume (#1459)

This commit is contained in:
whatdoineed2do 2022-05-08 13:09:59 +01:00 committed by GitHub
parent c90a1c17e3
commit 670ac7745d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,7 +110,7 @@ enum rcp_state
RCP_STATE_SETUP_SERVER_CONNECT_TRANS_END,
RCP_STATE_SETUP_SERVER_CONNECT, // 15
RCP_STATE_SETUP_VOL_GET,
RCP_STATE_SETUP_VOL_SET,
RCP_STATE_QUEUING_CLEAR,
RCP_STATE_QUEUING_SET_TITLE,
@ -168,7 +168,7 @@ static const struct rcp_state_map rcp_state_send_map[] =
{ RCP_STATE_SETUP_SERVER_CONNECT_TRANS_END, NULL },
{ RCP_STATE_SETUP_SERVER_CONNECT, NULL },
{ RCP_STATE_SETUP_VOL_GET, "GetVolume" },
{ RCP_STATE_SETUP_VOL_SET, "SetVolume", true },
{ RCP_STATE_QUEUING_CLEAR, "ClearWorkingSong" },
{ RCP_STATE_QUEUING_SET_TITLE, "SetWorkingSongInfo title", true },
@ -420,7 +420,6 @@ rcp_state_verify(struct rcp_session *s, const char *resp)
return 0;
goto resp_err;
case RCP_STATE_SETUP_VOL_GET:
case RCP_STATE_VOL_GET:
if (strncmp(resp, "GetVolume: ", strlen("GetVolume: ")) == 0)
{
@ -433,6 +432,7 @@ rcp_state_verify(struct rcp_session *s, const char *resp)
}
goto resp_err;
case RCP_STATE_SETUP_VOL_SET:
case RCP_STATE_VOL_SET:
if (strcmp(resp, "SetVolume: OK\r\n") == 0 ||
strcmp(resp, "SetVolume: ParameterError\r\n") == 0)
@ -464,6 +464,7 @@ rcp_session_shutdown(struct rcp_session* s, enum rcp_state state);
static int
rcp_state_transition(struct rcp_session *s)
{
char buf[128];
switch (s->state)
{
case RCP_STATE_SETUP:
@ -582,10 +583,11 @@ rcp_state_transition(struct rcp_session *s)
break;
case RCP_STATE_SETUP_SERVER_CONNECT:
rcp_send(s, RCP_STATE_SETUP_VOL_GET, NULL);
snprintf(buf, sizeof(buf), "%d", s->device->volume);
rcp_send(s, RCP_STATE_SETUP_VOL_SET, buf);
break;
case RCP_STATE_SETUP_VOL_GET:
case RCP_STATE_SETUP_VOL_SET:
rcp_send(s, RCP_STATE_QUEUING_CLEAR, NULL);
break;
@ -807,8 +809,6 @@ rcp_session_shutdown(struct rcp_session* s, enum rcp_state state)
event_del(s->ev);
event_del(s->reply_timeout);
s->device->prevent_playback = 1;
rcp_disconnect(s->sock);
s->sock = -1;
@ -949,7 +949,6 @@ rcp_listen_cb(int fd, short what, void *arg)
// Downgrade state to make rcp_session_shutdown perform an exit which is
// quick and won't require a reponse from remote
s->state = RCP_STATE_FAILED;
s->device->prevent_playback = 1;
rcp_session_shutdown(s, RCP_STATE_FAILED);
}
@ -964,7 +963,6 @@ rcp_reply_timeout_cb(int fd, short what, void *arg)
DPRINTF(E_LOG, L_RCP, "Slow response from '%s' (state %d), shutting down\n", s->devname, s->state);
s->state = RCP_STATE_FAILED;
s->device->prevent_playback = 1;
rcp_session_shutdown(s, RCP_STATE_FAILED);
event_del(s->reply_timeout);
@ -1052,7 +1050,7 @@ rcp_session_make(struct output_device *device, int callback_id)
s->devname = strdup(device->name);
s->address = strdup(device->v4_address);
s->volume = 0;
s->volume = device->volume;
s->next = rcp_sessions;
rcp_sessions = s;
@ -1145,7 +1143,7 @@ rcp_status(struct rcp_session *s)
state = OUTPUT_STATE_STARTUP;
break;
case RCP_STATE_SETUP_GET_CONNECTED_SERVER ... RCP_STATE_SETUP_VOL_GET:
case RCP_STATE_SETUP_GET_CONNECTED_SERVER ... RCP_STATE_SETUP_VOL_SET:
case RCP_STATE_QUEUING_CLEAR ... RCP_STATE_QUEUING_PLAY:
case RCP_STATE_VOL_GET:
case RCP_STATE_VOL_SET:
@ -1198,7 +1196,6 @@ rcp_device_stop(struct output_device *device, int callback_id)
* these need use to select (and cause the device probe to start connection to
* remote side
*/
device->prevent_playback = 0;
s->callback_id = callback_id;
// tear this session down, incl free'ing it
@ -1213,7 +1210,6 @@ rcp_device_flush(struct output_device *device, int callback_id)
struct rcp_session *s = device->session;
s->callback_id = callback_id;
s->state = OUTPUT_STATE_STOPPED;
rcp_status(s);
@ -1246,7 +1242,6 @@ rcp_device_volume_set(struct output_device *device, int callback_id)
s->callback_id = callback_id;
ret = snprintf(cmd, sizeof(cmd), "%d", device->volume);
if (ret < 0) {
return 0;