]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
fade: Switch to the fade-in mood *before* sleeping.
authorAndre Noll <maan@systemlinux.org>
Sun, 6 Oct 2013 09:54:55 +0000 (11:54 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 25 Jan 2014 20:12:26 +0000 (21:12 +0100)
This way the fade-in mood is active when para_fade is interrupted
during the sleep.

Currently sweet_dreams() calls change_afs_mode_and_play(),
which switches to a different mood and changes the mood directly
thereafter. For the new sematics we need to separate the two
actions though. Hence change_afs_mode_and_play() is renamed to
change_afs_mode(), and it now performs the mood switching part
only. Its two callers are modified to call client_cmd("play")
themselves.

This allows to call change_afs_mode() before we go to sleep and
client_cmd("play") on wake up.

fade.c

diff --git a/fade.c b/fade.c
index ed543d192c7e9f852265061bc1b93dfe687f282d..d7f28d6666faa121021ab4927ff354ddbc581242 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -130,7 +130,7 @@ fail:
        exit(EXIT_FAILURE);
 }
 
        exit(EXIT_FAILURE);
 }
 
-static void change_afs_mode_and_play(char *afs_mode)
+static void change_afs_mode(char *afs_mode)
 {
        char *cmd;
 
 {
        char *cmd;
 
@@ -140,7 +140,6 @@ static void change_afs_mode_and_play(char *afs_mode)
        cmd = make_message("select %s", afs_mode);
        client_cmd(cmd);
        free(cmd);
        cmd = make_message("select %s", afs_mode);
        client_cmd(cmd);
        free(cmd);
-       client_cmd("play");
 }
 
 static int set_initial_volume(struct mixer *m, struct mixer_handle *h)
 }
 
 static int set_initial_volume(struct mixer *m, struct mixer_handle *h)
@@ -220,7 +219,8 @@ static int sweet_dreams(struct mixer *m, struct mixer_handle *h)
                ret = set_initial_volume(m, h);
                if (ret < 0)
                        return ret;
                ret = set_initial_volume(m, h);
                if (ret < 0)
                        return ret;
-               change_afs_mode_and_play(fo_mood);
+               change_afs_mode(fo_mood);
+               client_cmd("play");
                ret = set_channel(m, h, conf.mixer_channel_arg);
                if (ret < 0)
                        return ret;
                ret = set_channel(m, h, conf.mixer_channel_arg);
                if (ret < 0)
                        return ret;
@@ -232,12 +232,14 @@ static int sweet_dreams(struct mixer *m, struct mixer_handle *h)
                if (ret < 0)
                        return ret;
        }
                if (ret < 0)
                        return ret;
        }
-       if (conf.sleep_mood_given)
-               change_afs_mode_and_play(sleep_mood);
-       else
+       if (conf.sleep_mood_given) {
+               change_afs_mode(sleep_mood);
+               client_cmd("play");
+       } else
                client_cmd("stop");
        if (!fit)
                return 1;
                client_cmd("stop");
        if (!fit)
                return 1;
+       change_afs_mode(fi_mood);
        for (;;) {
                time(&t1);
                if (wake_time_epoch <= t1 + fit)
        for (;;) {
                time(&t1);
                if (wake_time_epoch <= t1 + fit)
@@ -248,7 +250,7 @@ static int sweet_dreams(struct mixer *m, struct mixer_handle *h)
                        (delay % 3600) / 60);
                sleep(delay);
        }
                        (delay % 3600) / 60);
                sleep(delay);
        }
-       change_afs_mode_and_play(fi_mood);
+       client_cmd("play");
        ret = fade(m, h, fiv, fit);
        PARA_INFO_LOG("fade complete, returning\n");
        return ret;
        ret = fade(m, h, fiv, fit);
        PARA_INFO_LOG("fade complete, returning\n");
        return ret;