Merge branch 'refs/heads/t/invalid-ids'
[paraslash.git] / fade.c
diff --git a/fade.c b/fade.c
index d7f28d6666faa121021ab4927ff354ddbc581242..2a001ebacde964eb1f710413540cc23f2bc85699 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1998-2013 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1998 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -46,19 +46,10 @@ __printf_2_3 void (*para_log)(int, const char*, ...) = date_log;
 
 static int set_channel(struct mixer *m, struct mixer_handle *h, const char *channel)
 {
-       char *channels;
-       int ret;
 
-       ret = m->set_channel(h, channel);
-       if (ret >= 0) {
-               PARA_NOTICE_LOG("using %s mixer channel\n",
-                       channel? channel : "default");
-               return ret;
-       }
-       channels = m->get_channels(h);
-       printf("Available channels: %s\n", channels);
-       free(channels);
-       return ret;
+       PARA_NOTICE_LOG("using %s mixer channel\n", channel?
+               channel : "default");
+       return m->set_channel(h, channel);
 }
 
 /* Fade to new volume in fade_time seconds. */
@@ -76,7 +67,7 @@ static int fade(struct mixer *m, struct mixer_handle *h, int new_vol, int fade_t
        if (ret < 0)
                goto out;
        vol = ret;
-       PARA_NOTICE_LOG("fading %s from %d to %d in %d seconds\n",
+       PARA_NOTICE_LOG("fading %s from %d to %d in %u seconds\n",
                conf.mixer_channel_arg, vol, new_vol, secs);
        diff = new_vol - vol;
        if (!diff) {
@@ -212,7 +203,7 @@ static int sweet_dreams(struct mixer *m, struct mixer_handle *h)
                tm = localtime(&t1);
        }
        wake_time_epoch = mktime(tm);
-       PARA_INFO_LOG("waketime: %s", asctime(tm));
+       PARA_INFO_LOG("waketime: %d:%02d\n", tm->tm_hour, tm->tm_min);
        client_cmd("stop");
        sleep(1);
        if (fot) {
@@ -342,6 +333,17 @@ __noreturn static void print_help_and_die(void)
        exit(0);
 }
 
+/**
+ * The main function of para_fade.
+ *
+ * The executable is linked with the alsa or the oss mixer API, or both. It has
+ * a custom log function which prefixes log messages with the current date.
+ *
+ * \param argc Argument counter.
+ * \param argv Argument vector.
+ *
+ * \return EXIT_SUCCESS or EXIT_FAILURE.
+ */
 int main(int argc, char *argv[])
 {
        int ret;
@@ -377,6 +379,11 @@ int main(int argc, char *argv[])
        if (ret < 0)
                goto out;
        ret = set_channel(m, h, conf.mixer_channel_arg);
+       if (ret == -E_BAD_CHANNEL) {
+               char *channels = m->get_channels(h);
+               printf("Available channels: %s\n", channels);
+               free(channels);
+       }
        if (ret < 0)
                goto out;
        switch (conf.mode_arg) {