]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - fade.c
com_init(): Send error message only for non-sideband connections.
[paraslash.git] / fade.c
diff --git a/fade.c b/fade.c
index f95ef4c843588fa821c0a07fc090d24b88f220b8..52c83c4b08304a0edfb1ac316a1b4f30e6e8ac57 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1998-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1998-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -8,7 +8,6 @@
 
 #include <regex.h>
 #include <sys/types.h>
-#include <dirent.h>
 #include <sys/ioctl.h>
 #include <ctype.h>
 #include <stdlib.h> /* EXIT_SUCCESS */
 #include "fd.h"
 #include "string.h"
 #include "error.h"
+#include "version.h"
 
 INIT_FADE_ERRLISTS;
 static struct fade_args_info conf;
 
-__printf_2_3 void para_log(__a_unused int ll, const char *fmt, ...)
+__printf_2_3 void date_log(__a_unused int ll, const char *fmt, ...)
 {
        va_list argp;
        time_t t1;
@@ -40,12 +40,14 @@ __printf_2_3 void para_log(__a_unused int ll, const char *fmt, ...)
        vprintf(fmt, argp);
        va_end(argp);
 }
+__printf_2_3 void (*para_log)(int, const char*, ...) = date_log;
 
 /*
  * Open the mixer device.
  */
 static int open_mixer(void)
 {
+       PARA_INFO_LOG("opening %s\n", conf.mixer_device_arg);
        return para_open(conf.mixer_device_arg, O_RDWR, 42);
 }
 
@@ -124,6 +126,7 @@ static void fixup_mixer_channel_arg(void)
                case mixer_channel_arg_reclev: val = SOUND_MIXER_RECLEV; break;
                case mixer_channel_arg_igain: val = SOUND_MIXER_IGAIN; break;
                case mixer_channel_arg_ogain: val = SOUND_MIXER_OGAIN; break;
+               default: break;
        }
        conf.mixer_channel_arg = val;
 }
@@ -201,7 +204,7 @@ static void change_afs_mode_and_play(char *afs_mode)
        client_cmd("stop");
        if (!afs_mode)
                return;
-       cmd = make_message("select %s\n", afs_mode);
+       cmd = make_message("select %s", afs_mode);
        client_cmd(cmd);
        free(cmd);
        client_cmd("play");
@@ -285,11 +288,9 @@ static int sweet_dreams(void)
 static int snooze(void)
 {
        int ret;
-       unsigned sleep_time;
 
        if (conf.so_time_arg <= 0)
                return 1;
-       sleep_time = conf.so_time_arg;
        if (open_and_get_mixer_channel() < conf.so_vol_arg)
                ret = open_and_set_mixer_channel(conf.so_vol_arg);
        else
@@ -298,7 +299,7 @@ static int snooze(void)
                return ret;
        client_cmd("pause");
        PARA_NOTICE_LOG("%d seconds snooze time...\n", conf.snooze_time_arg);
-       sleep(sleep_time);
+       sleep(conf.snooze_time_arg);
        client_cmd("play");
        return fade(conf.si_vol_arg, conf.si_time_arg);
 }
@@ -343,15 +344,15 @@ int main(int argc, char *argv[])
        }
        fixup_mixer_channel_arg();
        switch (conf.mode_arg) {
-       case mode_arg_sleep:
-               ret = sweet_dreams();
-               break;
        case mode_arg_fade:
                ret = fade(conf.fade_vol_arg, conf.fade_time_arg);
                break;
        case mode_arg_snooze:
                ret = snooze();
                break;
+       default: /* sleep mode */
+               ret = sweet_dreams();
+               break;
        }
        if (ret < 0)
                PARA_EMERG_LOG("%s\n", para_strerror(-ret));