[player] Refactor speaker_set/speaker_deactivate

This commit is contained in:
chme 2018-02-07 21:04:47 +01:00
parent e70f9623db
commit f2659d995b

View File

@ -2473,10 +2473,15 @@ speaker_deactivate(struct output_device *device)
{ {
DPRINTF(E_DBG, L_PLAYER, "Deactivating %s device '%s'\n", device->type_name, device->name); DPRINTF(E_DBG, L_PLAYER, "Deactivating %s device '%s'\n", device->type_name, device->name);
if (device->selected)
speaker_deselect_output(device);
if (!device->session)
return 0;
outputs_status_cb(device->session, device_shutdown_cb); outputs_status_cb(device->session, device_shutdown_cb);
outputs_device_stop(device->session); outputs_device_stop(device->session);
return 1;
return 0;
} }
static enum command_state static enum command_state
@ -2546,24 +2551,11 @@ speaker_set(void *arg, int *retval)
{ {
DPRINTF(E_DBG, L_PLAYER, "The %s device '%s' is NOT selected\n", device->type_name, device->name); DPRINTF(E_DBG, L_PLAYER, "The %s device '%s' is NOT selected\n", device->type_name, device->name);
if (device->selected)
speaker_deselect_output(device);
if (device->session)
{
ret = speaker_deactivate(device); ret = speaker_deactivate(device);
if (ret < 0) if (ret > 0)
{
DPRINTF(E_LOG, L_PLAYER, "Could not deactivate %s device '%s'\n", device->type_name, device->name);
if (cmdarg->speaker_set_param.intval != -2)
cmdarg->speaker_set_param.intval = -1;
}
else
(*retval)++; (*retval)++;
} }
} }
}
if (*retval > 0) if (*retval > 0)
return COMMAND_PENDING; // async return COMMAND_PENDING; // async