From 5bd68d32e37386c6a75b597a0fa1a940cd6876a7 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 5 Jan 2018 16:11:36 +0100 Subject: [PATCH] mixer: Improve sleep subcommand. This avoids a pointless exec of "para_client stop" in case no fade-out mood is given, and another pointless "para_client play" exec which was executed when already playing. Other than that behaviour should be identical. --- mixer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mixer.c b/mixer.c index 00af08a4..52af25f9 100644 --- a/mixer.c +++ b/mixer.c @@ -192,9 +192,6 @@ static void change_afs_mode(const char *afs_mode) { char *cmd; - client_cmd("stop"); - if (!afs_mode) - return; cmd = make_message("select %s", afs_mode); client_cmd(cmd); free(cmd); @@ -290,7 +287,7 @@ static int com_sleep(const struct mixer *m, struct mixer_handle *h) PARA_INFO_LOG("waketime: %d:%02d\n", tm->tm_hour, tm->tm_min); client_cmd("stop"); sleep(1); - if (fot) { + if (fot && fo_mood) { ret = set_initial_volume(m, h); if (ret < 0) return ret; @@ -307,12 +304,13 @@ static int com_sleep(const struct mixer *m, struct mixer_handle *h) if (ret < 0) return ret; } - if (OPT_GIVEN(SLEEP, SLEEP_MOOD)) { + if (sleep_mood) { change_afs_mode(sleep_mood); - client_cmd("play"); - } else + if (!fot || !fo_mood) /* currently stopped */ + client_cmd("play"); + } else if (fot && fo_mood) /* currently playing */ client_cmd("stop"); - if (!fit) + if (!fit || !fi_mood) /* nothing to do */ return 1; change_afs_mode(fi_mood); for (;;) { -- 2.30.2