From f2659d995b40f3c71769c6759019747cab86e45f Mon Sep 17 00:00:00 2001 From: chme Date: Wed, 7 Feb 2018 21:04:47 +0100 Subject: [PATCH] [player] Refactor speaker_set/speaker_deactivate --- src/player.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/player.c b/src/player.c index d9c3fb0e..2979a183 100644 --- a/src/player.c +++ b/src/player.c @@ -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); + if (device->selected) + speaker_deselect_output(device); + + if (!device->session) + return 0; + outputs_status_cb(device->session, device_shutdown_cb); outputs_device_stop(device->session); - - return 0; + return 1; } static enum command_state @@ -2546,22 +2551,9 @@ speaker_set(void *arg, int *retval) { 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); - 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)++; - } + ret = speaker_deactivate(device); + if (ret > 0) + (*retval)++; } }