]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mixer.c
mixer: sleep: Add --initial-mood and --initial-delay.
[paraslash.git] / mixer.c
diff --git a/mixer.c b/mixer.c
index eae8929164770053c5c18843f4cf4e4e8bc5e616..013f35fe3e37c60db0404bfe0e80eeee95cfc5a0 100644 (file)
--- a/mixer.c
+++ b/mixer.c
@@ -270,6 +270,7 @@ static int com_sleep(const struct mixer *m)
        struct tm *tm;
        int ret;
        const char *wake_time = OPT_STRING_VAL(SLEEP, WAKE_TIME);
+       const char *initial_mood = OPT_STRING_VAL(SLEEP, INITIAL_MOOD);
        const char *fo_mood = OPT_STRING_VAL(SLEEP, FO_MOOD);
        const char *fi_mood = OPT_STRING_VAL(SLEEP, FI_MOOD);
        const char *sleep_mood = OPT_STRING_VAL(SLEEP, SLEEP_MOOD);
@@ -318,15 +319,26 @@ static int com_sleep(const struct mixer *m)
        PARA_INFO_LOG("waketime: %d:%02d\n", tm->tm_hour, tm->tm_min);
        client_cmd("stop");
        sleep(1);
+       ret = set_initial_volume(m, h);
+       if (ret < 0)
+               goto close_mixer;
+       /*
+        * Setting the volume invalidates the current channel setting, so we
+        * have to set it again.
+        */
+       ret = set_channel(m, h, OPT_STRING_VAL(PARA_MIXER, MIXER_CHANNEL));
+       if (ret < 0)
+               goto close_mixer;
+       delay = OPT_UINT32_VAL(SLEEP, INITIAL_DELAY);
+       if (delay > 0 && initial_mood && *initial_mood) {
+               change_afs_mode(initial_mood);
+               client_cmd("play");
+               sleep(delay);
+               client_cmd("stop");
+       }
        if (fot && fo_mood && *fo_mood) {
-               ret = set_initial_volume(m, h);
-               if (ret < 0)
-                       goto close_mixer;
                change_afs_mode(fo_mood);
                client_cmd("play");
-               ret = set_channel(m, h, OPT_STRING_VAL(PARA_MIXER, MIXER_CHANNEL));
-               if (ret < 0)
-                       goto close_mixer;
                ret = fade(m, h, fov, fot);
                if (ret < 0)
                        goto close_mixer;