]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Make para_fade use the new afs.
authorAndre Noll <maan@systemlinux.org>
Thu, 25 Oct 2007 23:28:55 +0000 (01:28 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 25 Oct 2007 23:28:55 +0000 (01:28 +0200)
fade.c
fade.ggo

diff --git a/fade.c b/fade.c
index 38a6517cd0dbadc47671f00b7c0b3ba2052ec02c..faf9b59a3911abffa160c87097e9b813124e281d 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -161,6 +161,19 @@ static int client_cmd(const char *cmd,...)
        return ret;
 }
 
        return ret;
 }
 
+static void change_afs_mode_and_play(char *afs_mode)
+{
+       char *cmd;
+
+       client_cmd("stop");
+       if (!afs_mode)
+               return;
+       cmd = make_message("select %s\n", afs_mode);
+       client_cmd(cmd);
+       free(cmd);
+       client_cmd("play");
+}
+
 /*
  * sleep
  */
 /*
  * sleep
  */
@@ -170,16 +183,14 @@ static void sweet_dreams(void)
        unsigned int delay;
        struct tm *tm;
        int min = conf.wake_min_arg;
        unsigned int delay;
        struct tm *tm;
        int min = conf.wake_min_arg;
-       char *fa_stream = conf.fa_stream_arg;
-       char *wake_stream = conf.wake_stream_arg;
-       //char *current_stream = stat_items[STREAM].content;
+       char *fa_mode = conf.fa_mode_arg;
+       char *wake_mode = conf.wake_mode_arg;
+       char *sleep_mode = conf.sleep_mode_arg;
        int wf = conf.wake_fade_arg;
        int sf = conf.fa_fade_arg;
        int wv = conf.wake_vol_arg;
        int sv = conf.fa_vol_arg;
        int iv = conf.sleep_ivol_arg;
        int wf = conf.wake_fade_arg;
        int sf = conf.fa_fade_arg;
        int wv = conf.wake_vol_arg;
        int sv = conf.fa_vol_arg;
        int iv = conf.sleep_ivol_arg;
-       char *cmd, *sleep_stream = conf.sleep_stream_given?
-               conf.sleep_stream_arg : NULL;
 
        /* calculate wake time */
        time(&t1);
 
        /* calculate wake time */
        time(&t1);
@@ -200,20 +211,16 @@ static void sweet_dreams(void)
        }
        wake_time_epoch = mktime(tm);
        PARA_INFO_LOG("waketime: %s", asctime(tm));
        }
        wake_time_epoch = mktime(tm);
        PARA_INFO_LOG("waketime: %s", asctime(tm));
+       client_cmd("stop");
+       sleep(1);
        if (sf) {
                PARA_INFO_LOG("initial volume: %d\n", iv);
                set_vol(iv);
        if (sf) {
                PARA_INFO_LOG("initial volume: %d\n", iv);
                set_vol(iv);
-               cmd = make_message("csp %s\n", fa_stream);
-               client_cmd(cmd);
-               free(cmd);
+               change_afs_mode_and_play(fa_mode);
                fade(sv, sf);
                fade(sv, sf);
-       }
-       if (sleep_stream) {
-               cmd = make_message("csp %s\n", sleep_stream);
-               client_cmd(cmd);
-               free(cmd);
        } else
        } else
-               client_cmd("stop");
+               set_vol(sf);
+       change_afs_mode_and_play(sleep_mode);
        if (!wf)
                return;
        for (;;) {
        if (!wf)
                return;
        for (;;) {
@@ -222,15 +229,13 @@ static void sweet_dreams(void)
                        break;
                delay = wake_time_epoch - t1 - wf;
                PARA_INFO_LOG("sleeping %u seconds (%u:%02u)\n",
                        break;
                delay = wake_time_epoch - t1 - wf;
                PARA_INFO_LOG("sleeping %u seconds (%u:%02u)\n",
-                       delay, delay / 3600, 
+                       delay, delay / 3600,
                        (delay % 3600) / 60);
                sleep(delay);
        }
                        (delay % 3600) / 60);
                sleep(delay);
        }
-       cmd = make_message("csp %s\n", wake_stream);
-       client_cmd(cmd);
-       free(cmd);
+       change_afs_mode_and_play(wake_mode);
        fade(wv, wf);
        fade(wv, wf);
-       PARA_INFO_LOG("%s", "fade complete, returning\n");
+       PARA_INFO_LOG("fade complete, returning\n");
 }
 
 static void snooze(void)
 }
 
 static void snooze(void)
index f467c1996ac9cfd68487a475cc67e34a8819a6b0..2a315e3941f21d843ae733f6c470b426c2f9cdfa 100644 (file)
--- a/fade.ggo
+++ b/fade.ggo
@@ -31,13 +31,15 @@ option "sleep_ivol" -
        default="60"
        optional
 
        default="60"
        optional
 
-option "fa_stream" -
+option "fa_mode" -
 #~~~~~~~~~~~~~~~~~~~
 #~~~~~~~~~~~~~~~~~~~
- "fall asleep stream. Change to this stream
-right after setting the volume"
+ "fall asleep afs mode. Select this mode
+right after setting the volume. Example:
+       --fa_mode m:sleep
+"
 
 
-       string typestr="streamname"
-       default="fa"
+       string typestr="afs_mode"
+       default="m:fa"
        optional
 
 option "fa_fade" -
        optional
 
 option "fa_fade" -
@@ -55,12 +57,12 @@ option "fa_vol" -
        default="20"
        optional
 
        default="20"
        optional
 
-option "sleep_stream" -
+option "sleep_mode" -
 #~~~~~~~~~~~~~~~~~~~~~~
 #~~~~~~~~~~~~~~~~~~~~~~
- "change to this stream after fading, stop
-playing if unset"
-       string typestr="streamname"
-       default="sleep"
+ "change to this afs mode after fading, stop
+playing if unset."
+       string typestr="afs_mode"
+       default="m:sleep"
        optional
 
 option "wake_hour" H
        optional
 
 option "wake_hour" H
@@ -77,11 +79,11 @@ option "wake_min" M
        default="0"
        optional
 
        default="0"
        optional
 
-option "wake_stream" -
+option "wake_mode" -
 #~~~~~~~~~~~~~~~~~~~~~
 #~~~~~~~~~~~~~~~~~~~~~
- "change to this stream on waketime"
-       string typestr="streamname"
-       default="wake"
+ "change to this afs mode on waketime"
+       string typestr="afs_mode"
+       default="m:wake"
        optional
 
 option "wake_fade" -
        optional
 
 option "wake_fade" -