]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'master' into my-osx
authormaan <maan@Gumbo.local>
Sat, 24 Jun 2006 22:34:47 +0000 (00:34 +0200)
committermaan <maan@Gumbo.local>
Sat, 24 Jun 2006 22:34:47 +0000 (00:34 +0200)
32 files changed:
Makefile.in
NEWS
aac_afh.c
audiod.c
audiod_command.c
client.c
client.h
client_common.c
dbadm.c
dccp_send.c
fade.c
fade.ggo
fd.c
fd.h
filter_chain.c
grab_client.c
gui.c
gui.ggo
gui_common.c
http_send.c
mp3_afh.c
net.c
net.h
ogg_afh.c
ortp_recv.c
para.h
sdl_gui.c
signal.c
stat.c
time.c
web/para.css
write.c

index 9a85952bd44533de3189bec4283c7f2b9acb6381..a451e8926021283ef7b8092e1608562ff31fe338 100644 (file)
@@ -51,6 +51,7 @@ CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
 CPPFLAGS += -Werror-implicit-function-declaration
 CPPFLAGS += -Wmissing-format-attribute
 CPPFLAGS += -Wunused-macros
+CPPFLAGS += -Wshadow
 
 BINARIES = para_server para_client para_gui para_audiod para_audioc para_recv para_filter para_write $(extra_binaries)
 
diff --git a/NEWS b/NEWS
index dd02a36a05f48ddd36a5721ba434a4e8c55856fb..9c8d2cce702e4ff5e91e3ea41d7306d7690360be 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,15 +9,17 @@ A bunch of new features and core changes.
 
        - the new paraslash scheduler, short and sweet.
        - Support for m4a files via the new aac filter/ and audio
-         format handler. (requires libfaad)
+         format handler (requires libfaad).
+       - each writer has its own command line parser, just like
+         para_recv and para_filter.
        - new writer: osxplay (thanks to Gerd Becker)
+       - para_client and para_audioc use the error subsystem
        - writers are integrated in para_audiod
        - para_client is integrated in para_audiod
-       - each writer of para_write has its own command line parser,
-         just like para_recv and para_filter.
        - random/playlist selector: improved info strings
        - new audiod commands: tasks, kill
-       - para_client/para_audioc use the error subsystem
+       - update to libortp-0.10.0
+       - para_fade: wake time defaults to 8 hours from now
 
 
 ------------------------------------------
index e6f99b4f51958b4ddced2d67d997ea2f2926f2ad..d60588b419ac7b504bd03f490dd64be513ad35ff 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -114,7 +114,6 @@ static int read_chunk_table(size_t skip)
                        PARA_DEBUG_LOG("offset #%d: %zu\n", i, chunk_table[i]);
        }
        return 1;
-
 }
 
 long unsigned aac_set_chunk_tv(mp4AudioSpecificConfig *mp4ASC)
index 032b608cbc3acb32e537350fffba2a01aa27c099..3b6111964a8012de6bbdddd4b7ec340a1173ce48 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -79,6 +79,7 @@ static struct signal_task signal_task_struct, *sig_task = &signal_task_struct;
 
 static struct status_task status_task_struct;
 struct status_task *stat_task = &status_task_struct;
+static struct timeval initial_delay_barrier;
 
 /**
  * the task for handling audiod commands
@@ -92,9 +93,15 @@ struct command_task {
        struct task task;
 };
 
+/**
+ * task for signal handling
+ */
 struct signal_task {
+       /** the signal pipe */
        int fd;
+       /** the number of the most recent signal */
        int signum;
+       /** the associated task structure */
        struct task task;
 };
 
@@ -180,20 +187,15 @@ static void close_receiver(int slot_num)
 {
        struct slot_info *s = &slot[slot_num];
        struct audio_format_info *a;
-       const struct timeval restart_delay = {0, 200 * 1000};
 
        if (s->format < 0 || !s->receiver_node)
                return;
        a = &afi[s->format];
        PARA_NOTICE_LOG("closing %s receiver in slot %d (eof = %d)\n",
                audio_formats[s->format] , slot_num, s->receiver_node->eof);
-//     if (!s->receiver_node->eof)
-//             unregister_task(&s->receiver_node->task);
        a->receiver->close(s->receiver_node);
        free(s->receiver_node);
        s->receiver_node = NULL;
-       /* set restart barrier */
-       tv_add(now, &restart_delay, &afi[s->format].restart_barrier);
 }
 
 static void kill_all_decoders(void)
@@ -240,21 +242,6 @@ static int get_empty_slot(void)
        return -E_NO_MORE_SLOTS;
 }
 
-static int decoder_running(int format)
-{
-       int i, ret = 0;
-       struct slot_info *s;
-
-       FOR_EACH_SLOT(i) {
-               s = &slot[i];
-               if (s->format == format && s->receiver_node)
-                       ret |= 1;
-               if (s->format == format && s->wng)
-                       ret |= 2;
-       }
-       return ret;
-}
-
 static void close_stat_pipe(void)
 {
        int i;
@@ -399,10 +386,18 @@ static void open_writers(int slot_num)
 static void rn_event_handler(struct task *t)
 {
        struct receiver_node *rn = t->private_data;
+       const struct timeval restart_delay = {0, 10 * 1000};
+       int i;
 
        PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
        unregister_task(t);
        rn->eof = 1;
+       /* set restart barrier */
+       FOR_EACH_SLOT(i) {
+               if (slot[i].receiver_node != rn)
+                       continue;
+               tv_add(now, &restart_delay, &afi[slot[i].format].restart_barrier);
+       }
 }
 
 static void open_receiver(int format)
@@ -439,6 +434,19 @@ static void open_receiver(int format)
        register_task(&rn->task);
 }
 
+static int receiver_running(int format)
+{
+       int i;
+
+       FOR_EACH_SLOT(i) {
+               struct slot_info *s = &slot[i];
+               if (s->format == format && s->receiver_node
+                               && !s->receiver_node->eof)
+                       return 1;
+       }
+       return 0;
+}
+
 static int open_current_receiver(struct sched *s)
 {
        int i;
@@ -449,7 +457,7 @@ static int open_current_receiver(struct sched *s)
        i = get_audio_format_num(stat_task->af_status);
        if (i < 0)
                return 0;
-       if (decoder_running(i))
+       if (receiver_running(i))
                return 0;
        if (tv_diff(now, &afi[i].restart_barrier, &diff) < 0) {
                s->timeout = diff;
@@ -533,8 +541,18 @@ static void check_stat_line(char *line)
                break;
        case SI_STREAM_START:
                if (sscanf(line + ilen + 1, "%lu.%lu", &sec, &usec) == 2) {
+                       struct timeval a_start, delay;
+                       delay.tv_sec = conf.stream_delay_arg / 1000;
+                       delay.tv_usec = (conf.stream_delay_arg % 1000) * 1000;
                        stat_task->server_stream_start.tv_sec = sec;
                        stat_task->server_stream_start.tv_usec = usec;
+                       if (stat_task->sa_time_diff_sign < 0)
+                               tv_add(&stat_task->server_stream_start,
+                                       &stat_task->sa_time_diff, &a_start);
+                       else
+                               tv_diff(&stat_task->server_stream_start,
+                                       &stat_task->sa_time_diff, &a_start);
+                       tv_add(&a_start, &delay, &initial_delay_barrier);
                }
                break;
        case SI_CURRENT_TIME:
@@ -597,6 +615,7 @@ static void audiod_pre_select(struct sched *s, __a_unused struct task *t)
        FOR_EACH_SLOT(i) {
                struct slot_info *sl = &slot[i];
                struct audio_format_info *a;
+               struct timeval diff;
 
                if (sl->format < 0)
                        continue;
@@ -615,9 +634,20 @@ static void audiod_pre_select(struct sched *s, __a_unused struct task *t)
                        s->timeout = min_delay;
                        continue;
                }
-               if (sl->fc && *sl->fc->out_loaded && !sl->wng) {
+               if (!sl->fc || !*sl->fc->out_loaded || sl->wng)
+                       continue;
+               if (tv_diff(now, &initial_delay_barrier, &diff) > 0) {
+                       PARA_INFO_LOG("barrier: %lu:%lu, now: %lu, %lu\n",
+                               initial_delay_barrier.tv_sec,
+                               initial_delay_barrier.tv_usec,
+                               now->tv_sec, now->tv_usec);
                        open_writers(i);
                        s->timeout = min_delay;
+                       continue;
+               }
+               PARA_INFO_LOG("inital delay: %lu ms left\n", tv2ms(&diff));
+               if (tv_diff(&s->timeout, &diff, NULL) > 0) {
+                       s->timeout = diff;
                }
        }
 }
@@ -723,18 +753,19 @@ static int init_receivers(void)
                PARA_INFO_LOG("initializing %s receiver\n", receivers[i].name);
                receivers[i].init(&receivers[i]);
        }
-       for (i = 0; i < conf.receiver_given; i++) {
+       for (i = conf.receiver_given - 1; i >= 0; i--) {
                char *arg = conf.receiver_arg[i];
-               char *recv = strchr(arg, ':');
+               char *recv_arg = strchr(arg, ':');
+               PARA_INFO_LOG("arg: %s\n", arg);
                ret = -E_MISSING_COLON;
-               if (!recv)
+               if (!recv_arg)
                        goto out;
-               *recv = '\0';
-               recv++;
+               *recv_arg = '\0';
+               recv_arg++;
                ret = get_audio_format_num(arg);
                if (ret < 0)
                        goto out;
-               afi[ret].receiver_conf = check_receiver_arg(recv, &receiver_num);
+               afi[ret].receiver_conf = check_receiver_arg(recv_arg, &receiver_num);
                if (!afi[ret].receiver_conf) {
                        ret = -E_RECV_SYNTAX;
                        goto out;
@@ -872,7 +903,7 @@ static int audiod_get_socket(void)
        return fd;
 }
 
-void signal_event_handler(struct task *t)
+static void signal_event_handler(struct task *t)
 {
        struct signal_task *st = t->private_data;
 
@@ -882,14 +913,14 @@ void signal_event_handler(struct task *t)
                handle_signal(st->signum);
 }
 
-void signal_pre_select(struct sched *s, struct task *t)
+static void signal_pre_select(struct sched *s, struct task *t)
 {
        struct signal_task *st = t->private_data;
        t->ret = 1;
        para_fd_set(st->fd, &s->rfds, &s->max_fileno);
 }
 
-void signal_post_select(struct sched *s, struct task *t)
+static void signal_post_select(struct sched *s, struct task *t)
 {
        struct signal_task *st = t->private_data;
        t->ret = 1;
@@ -899,7 +930,7 @@ void signal_post_select(struct sched *s, struct task *t)
        st->signum = para_next_signal();
 }
 
-void signal_setup_default(struct signal_task *st)
+static void signal_setup_default(struct signal_task *st)
 {
        st->task.pre_select = signal_pre_select;
        st->task.post_select = signal_post_select;
@@ -991,7 +1022,7 @@ static void status_post_select(__a_unused struct sched *s, struct task *t)
 
        t->ret = 1;
        if (!st->pcd || !st->pcd->loaded
-                       || st->pcd->status != CL_RECEIVING_SERVER_OUTPUT)
+                       || st->pcd->status != CL_RECEIVING)
                return;
        st->pcd->loaded = for_each_line(st->pcd->buf, st->pcd->loaded,
                &check_stat_line);
index 4d7afd2f2b37d2a4b67ec9d5d738839b13522153..fe26b663256aaa8083268bee75ac2f2c5fbb5c68 100644 (file)
@@ -261,7 +261,7 @@ static struct timeval *wstime(void)
 __malloc static char *decoder_flags(void)
 {
        int i;
-       char decoder_flags[MAX_STREAM_SLOTS + 1];
+       char flags[MAX_STREAM_SLOTS + 1];
 
        FOR_EACH_SLOT(i) {
                struct slot_info *s = &slot[i];
@@ -270,11 +270,11 @@ __malloc static char *decoder_flags(void)
                        flag += 1;
                if (s->wng)
                        flag += 2;
-               decoder_flags[i] = flag;
+               flags[i] = flag;
        }
-       decoder_flags[MAX_STREAM_SLOTS] = '\0';
+       flags[MAX_STREAM_SLOTS] = '\0';
        return make_message("%s:%s\n", status_item_list[SI_DECODER_FLAGS],
-               decoder_flags);
+               flags);
 }
 
 static int dump_commands(int fd)
index 69e0f3d3bf9c7382c3b78c012d5c1bfcd0fb6c7c..95dacd75f8a9d39c0e85f8118481b1600ecc88f8 100644 (file)
--- a/client.c
+++ b/client.c
@@ -59,7 +59,7 @@ static void client_event_handler(struct task *t)
                p->eof = 1;
                return;
        }
-       if (p->status == CL_SENDING_STDIN) {
+       if (p->status == CL_SENDING) {
                stdin_set_defaults(&sit);
                sit.buf = para_malloc(sit.bufsize),
                register_task(&sit.task);
index 8f7b9a5dc1b47d4783da5ead2274cd87607a296f..1c9a8c22ae4dabd73a20547c8ce6bc195989e218 100644 (file)
--- a/client.h
+++ b/client.h
 /** \file client.h common client functions and exported symbols from client_common.c */
 
 #include <openssl/rc4.h>
+
+/**
+ * the different states of a connection from the view of the client
+ */
 enum {
+       /** tcp connection is established */
        CL_CONNECTED,
+       /** server sends the welcome message */
        CL_RECEIVED_WELCOME,
+       /** client sends the authentification request */
        CL_SENT_AUTH,
+       /** server sends a challenge */
        CL_RECEIVED_CHALLENGE,
+       /** clientd solves the challenge and sends the result */
        CL_SENT_CH_RESPONSE,
+       /** server accepts this authentication */
        CL_RECEIVED_PROCEED,
+       /** client sends the command */
        CL_SENT_COMMAND,
-       CL_SENDING_STDIN,
-       CL_RECEIVING_SERVER_OUTPUT
+       /** server expects data */
+       CL_SENDING,
+       /** client expects data */
+       CL_RECEIVING,
 };
 
 #define CLIENT_BUFSIZE 8192
 
+/**
+ * data specific to a client task
+ */
 struct private_client_data {
+       /** the state of the connection */
        int status;
+       /** the file descriptor */
        int fd;
+       /** the configuration (including the command) */
        struct client_args_info conf;
+       /** the config file for client options */
        char *config_file;
+       /** the RSA private key */
        char *key_file;
+       /** paraslash user name */
        char *user;
+       /** session key for receiving data */
        RC4_KEY rc4_recv_key;
+       /** session key for sending data */
        RC4_KEY rc4_send_key;
+       /** the client task structure */
        struct task task;
+       /** non-zero if task is unregistered */
        int eof;
+       /** the buffer used for handshake and receiving */
        char buf[CLIENT_BUFSIZE];
+       /** number of bytes loaded in \p buf */
        size_t loaded;
+       /** non-zero if the pre_select hook added \p fd to the read fd set */
        int check_r;
+       /** non-zero if the pre_select hook added \p fd to the write fd set */
        int check_w;
+       /** the decrypted challenge */
        long unsigned challenge_nr;
-       /* only used if stdin gets sent to para_server */
+       /** pointer to the data to be sent to para_server */
        char *inbuf;
+       /** number of bytes loaded in \p inbuf */
        size_t *in_loaded;
+       /** non-zero if input task encountered an eof or an errro condition */
        int *in_eof;
 };
 
index c2ae2d315fc650f0e4fc6bd1dc267d34800a2983..b77c192f3a1c31bc0792fd427b39e21518c2fbd1 100644 (file)
@@ -50,8 +50,10 @@ void client_close(struct private_client_data *pcd)
 {
        if (pcd)
                return;
-       if (pcd->fd >= 0)
+       if (pcd->fd >= 0) {
+               disable_crypt(pcd->fd);
                close(pcd->fd);
+       }
        free(pcd->user);
        free(pcd->config_file);
        free(pcd->key_file);
@@ -92,16 +94,11 @@ int client_parse_config(int argc, char *argv[],
                        &pcd->conf, 0, 0, 0);
        ret = 1;
        *pcd_ptr = pcd;
-       PARA_INFO_LOG(
-               "current loglevel: %d\n"
-               "using config_file: %s\n"
-               "using key_file: %s\n"
-               "connecting to %s:%d\n" ,
-               pcd->conf.loglevel_arg,
-               pcd->config_file,
-               pcd->key_file,
-               pcd->conf.hostname_arg, pcd->conf.server_port_arg
-       );
+       PARA_INFO_LOG("loglevel: %d\n", pcd->conf.loglevel_arg);
+       PARA_INFO_LOG("config_file: %s\n", pcd->config_file);
+       PARA_INFO_LOG("key_file: %s\n", pcd->key_file);
+       PARA_NOTICE_LOG("connecting %s:%d\n", pcd->conf.hostname_arg,
+               pcd->conf.server_port_arg);
 out:
        free(home);
        if (ret < 0)
@@ -134,13 +131,13 @@ void client_pre_select(struct sched *s, struct task *t)
                pcd->check_w = 1;
                return;
 
-       case CL_RECEIVING_SERVER_OUTPUT:
+       case CL_RECEIVING:
                if (pcd->loaded < CLIENT_BUFSIZE - 1) {
                        para_fd_set(pcd->fd, &s->rfds, &s->max_fileno);
                        pcd->check_r = 1;
                }
                return;
-       case CL_SENDING_STDIN:
+       case CL_SENDING:
                if (*pcd->in_loaded) {
                        PARA_INFO_LOG("loaded: %zd\n", *pcd->in_loaded);
                        para_fd_set(pcd->fd, &s->wfds, &s->max_fileno);
@@ -274,11 +271,11 @@ void client_post_select(struct sched *s, struct task *t)
                        return;
                t->ret = -E_HANDSHAKE_COMPLETE;
                if (strstr(pcd->buf, AWAITING_DATA_MSG))
-                       pcd->status = CL_SENDING_STDIN;
+                       pcd->status = CL_SENDING;
                else
-                       pcd->status = CL_RECEIVING_SERVER_OUTPUT;
+                       pcd->status = CL_RECEIVING;
                return;
-       case CL_SENDING_STDIN: /* FIXME: might block */
+       case CL_SENDING: /* FIXME: might block */
                PARA_INFO_LOG("loaded: %zd\n", *pcd->in_loaded);
                t->ret = send_bin_buffer(pcd->fd, pcd->inbuf, *pcd->in_loaded);
                if (t->ret <= 0) {
@@ -288,7 +285,7 @@ void client_post_select(struct sched *s, struct task *t)
                }
                *pcd->in_loaded = 0; /* FIXME: short writes */
                return;
-       case CL_RECEIVING_SERVER_OUTPUT:
+       case CL_RECEIVING:
                t->ret = client_recv_buffer(pcd);
                return;
        }
@@ -301,9 +298,6 @@ int client_open(struct private_client_data *pcd)
        struct hostent *he;
        struct sockaddr_in their_addr;
 
-       /* get the host info */
-       PARA_NOTICE_LOG("getting host info of %s\n",
-               pcd->conf.hostname_arg);
        ret = get_host_info(pcd->conf.hostname_arg, &he);
        if (ret < 0)
                goto out;
@@ -314,12 +308,13 @@ int client_open(struct private_client_data *pcd)
        pcd->fd = ret;
        /* init their_addr */
        init_sockaddr(&their_addr, pcd->conf.server_port_arg, he);
-       /* connect */
-       PARA_NOTICE_LOG("connecting to %s\n", pcd->conf.hostname_arg);
        ret = para_connect(pcd->fd, &their_addr);
        if (ret < 0)
                goto out;
        pcd->status = CL_CONNECTED;
+       ret = mark_fd_nonblock(pcd->fd);
+       if (ret < 0)
+               goto out;
        pcd->task.pre_select = client_pre_select;
        pcd->task.post_select = client_post_select;
        pcd->task.private_data = pcd;
diff --git a/dbadm.c b/dbadm.c
index 6b5a3e989f3f30eb82b272d57682b2cbdbddc2ee..40ecf0b862a5a2a6d18bc739eacb44bc5d20f123 100644 (file)
--- a/dbadm.c
+++ b/dbadm.c
@@ -56,19 +56,19 @@ static int client_cmd(const char *cmd)
 static char **get_all_atts(int *num_atts)
 {
        int fd = client_cmd("laa");
-       FILE *pipe;
+       FILE *f;
        char **ret = NULL, *buf;
 
        if (fd < 0)
                return NULL;
-       pipe = fdopen(fd, "r");
-       if (!pipe) {
+       f = fdopen(fd, "r");
+       if (!f) {
                close(fd);
                return NULL;
        }
        *num_atts = 0;
        buf = para_malloc(MAXLINE * sizeof(char));
-       while (fgets(buf, MAXLINE - 1, pipe) && *buf) {
+       while (fgets(buf, MAXLINE - 1, f) && *buf) {
                size_t n = strlen(buf);
                buf[n - 1] = '\0';
                if (choice_len < n - 1)
index 08930ad1852321f877fac474b839ea71bc5ee5d8..aba21a6db1d2e92aa997a964a053d8000df9b2f1 100644 (file)
@@ -122,11 +122,11 @@ static void dccp_shutdown_client(struct dccp_client *dc)
 
 static int dccp_write(int fd, const char *buf, size_t len)
 {
-       size_t send, written = 0;
+       size_t size, written = 0;
        int ret;
 again:
-       send = PARA_MIN(1024, len - written);
-       ret = write(fd, buf + written, send);
+       size = PARA_MIN(1024, len - written);
+       ret = write(fd, buf + written, size);
        if (ret < 0)
                goto err_out;
        written += ret;
diff --git a/fade.c b/fade.c
index b42e4a1c713c6b660c4c32a2c382bcef7f82cac4..8dfbcc2f767f251649cddca00084d1a080b0adae 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -188,7 +188,6 @@ static void sweet_dreams(void)
        time_t t1, wake_time_epoch;
        unsigned int delay;
        struct tm *tm;
-       int hour = args_info.wake_hour_arg;
        int min = args_info.wake_min_arg;
        char *fa_stream = args_info.fa_stream_arg;
        char *wake_stream = args_info.wake_stream_arg;
@@ -201,6 +200,25 @@ static void sweet_dreams(void)
        char *cmd, *sleep_stream = args_info.sleep_stream_given?
                args_info.sleep_stream_arg : NULL;
 
+       /* calculate wake time */
+       time(&t1);
+       if (args_info.wake_hour_given) {
+               int hour = args_info.wake_hour_arg;
+               tm = localtime(&t1);
+               if (tm->tm_hour > hour || (tm->tm_hour == hour && tm->tm_min> min)) {
+                       t1 += 86400; /* wake time is tomorrow */
+                       tm = localtime(&t1);
+               }
+               tm->tm_hour = hour;
+               tm->tm_min = min;
+               tm->tm_sec = 0;
+       } else {
+               t1 += 8 * 60 * 60;
+               PARA_INFO_LOG("default wake time: %lu\n", t1);
+               tm = localtime(&t1);
+       }
+       wake_time_epoch = mktime(tm);
+       PARA_INFO_LOG("waketime: %s", asctime(tm));
        if (sf) {
                PARA_INFO_LOG("initial volume: %d\n", iv);
                set_vol(iv);
@@ -217,27 +235,15 @@ static void sweet_dreams(void)
                client_cmd("stop");
        if (!wf)
                return;
-       /* calculate wake time */
-       time(&t1);
-       tm = localtime(&t1);
-       if (tm->tm_hour > hour || (tm->tm_hour == hour && tm->tm_min> min)) {
-               /* wake time is tomorrow */
-               t1 += 86400;
-               tm = localtime(&t1);
-               t1 -= 86400;
-       }
-       tm->tm_hour = hour;
-       tm->tm_min = min;
-       tm->tm_sec = 0;
-       wake_time_epoch = mktime(tm);
-       PARA_INFO_LOG("waketime: %s", asctime(tm));
-       while (wake_time_epoch > t1 + wf) {
+       for (;;) {
+               time(&t1);
+               if (wake_time_epoch <= t1 + wf)
+                       break;
                delay = wake_time_epoch - t1 - wf;
                PARA_INFO_LOG("sleeping %u seconds (%u:%02u)\n",
                        delay, delay / 3600, 
                        (delay % 3600) / 60);
                sleep(delay);
-               time(&t1);
        }
        cmd = make_message("csp %s\n", wake_stream);
        client_cmd(cmd);
index 0c6d1ba9ab1cd1b90c8a4233244b4246d2a30a7b..f467c1996ac9cfd68487a475cc67e34a8819a6b0 100644 (file)
--- a/fade.ggo
+++ b/fade.ggo
 section "general options"
-option "mode" o "{sleep|fade|snooze}" string default="sleep" optional
-option "config_file" c "(default='~/.paraslash/fade.conf')" string typestr="filename" optional
-option "mixer_device" m "mixer device file" string typestr="device" default="/dev/mixer" optional
+#########################
+
+option "mode" o
+#~~~~~~~~~~~~~~
+
+"{sleep|fade|snooze}"
+       string default="sleep"
+       optional
+
+option "config_file" c
+#~~~~~~~~~~~~~~~~~~~~~
+ "(default='~/.paraslash/fade.conf')"
+       string typestr="filename"
+       optional
+
+option "mixer_device" m
+#~~~~~~~~~~~~~~~~~~~~~~
+ "mixer device file"
+       string typestr="device"
+       default="/dev/mixer"
+       optional
 
 section "sleep options (only relevant in sleep mode)"
-option "sleep_ivol" - "set initial volume before doing anything else" int typestr="volume" default="60" optional
-option "fa_stream" - "fall asleep stream. Change to this stream right after setting the volume" string typestr="streamname" default="fa" optional
-option "fa_fade" - "fall asleep fading time, no fading if set to 0" int typestr="seconds" default="1800" optional
-option "fa_vol" - "volume to fade to" int typestr="volume" default="20" optional
-option "sleep_stream" - "change to this stream after fading, stop playing if unset" string typestr="streamname" default="sleep" optional
-option "wake_hour" H "(0-23)" int default="8" optional
-option "wake_min" M "(0-59)" int default="0" optional
-option "wake_stream" - "changed to on waketime" string typestr="streamname" default="wake" optional
-option "wake_fade" - "no fading in if set to 0" int typestr="seconds" default="1200" optional
-option "wake_vol" - "vol to fade to at waketime" int typestr="volume" default="80" optional
+#####################################################
+
+option "sleep_ivol" -
+#~~~~~~~~~~~~~~~~~~~~
+ "set initial volume before doing anything else"
+       int typestr="volume"
+       default="60"
+       optional
+
+option "fa_stream" -
+#~~~~~~~~~~~~~~~~~~~
+ "fall asleep stream. Change to this stream
+right after setting the volume"
+
+       string typestr="streamname"
+       default="fa"
+       optional
+
+option "fa_fade" -
+#~~~~~~~~~~~~~~~~~
+ "fall asleep fading time, no fading if set
+to 0"
+       int typestr="seconds"
+       default="1800"
+       optional
+
+option "fa_vol" -
+#~~~~~~~~~~~~~~~~
+ "volume to fade to"
+       int typestr="volume"
+       default="20"
+       optional
+
+option "sleep_stream" -
+#~~~~~~~~~~~~~~~~~~~~~~
+ "change to this stream after fading, stop
+playing if unset"
+       string typestr="streamname"
+       default="sleep"
+       optional
+
+option "wake_hour" H
+#~~~~~~~~~~~~~~~~~~~
+ "(0-23)"
+       int typestr="hour"
+       default="8"
+       optional
+
+option "wake_min" M
+#~~~~~~~~~~~~~~~~~~
+"(0-59)"
+       int typestr="seconds"
+       default="0"
+       optional
+
+option "wake_stream" -
+#~~~~~~~~~~~~~~~~~~~~~
+ "change to this stream on waketime"
+       string typestr="streamname"
+       default="wake"
+       optional
+
+option "wake_fade" -
+#~~~~~~~~~~~~~~~~~~~
+ "no fading in if set to 0"
+       int typestr="seconds"
+       default="1200"
+       optional
+
+option "wake_vol" -
+#~~~~~~~~~~~~~~~~~~
+ "vol to fade to at waketime"
+       int typestr="volume"
+       default="80"
+       optional
 
 section "snooze options"
-option "snooze_out_fade" - "fade out time" int typestr="seconds" default="30" optional
-option "snooze_out_vol" - "vol to fade to before snooze" int typestr="volume" default="20" optional
-option "snooze_time" - "delay" int typestr="seconds" default="600" optional
-option "snooze_in_fade" - "fade in time" int typestr="seconds" default="180" optional
-option "snooze_in_vol" - "vol to fade to after snooze" int typestr="volume" default="80" optional
+########################
+
+option "snooze_out_fade" -
+#~~~~~~~~~~~~~~~~~~~~~~~~~
+ "fade out time"
+       int typestr="seconds"
+       default="30"
+       optional
+
+option "snooze_out_vol" -
+#~~~~~~~~~~~~~~~~~~~~~~~~
+ "vol to fade to before snooze"
+       int typestr="volume"
+       default="20"
+       optional
+
+option "snooze_time" -
+#~~~~~~~~~~~~~~~~~~~~~
+ "delay"
+       int typestr="seconds"
+       default="600"
+       optional
+
+option "snooze_in_fade" -
+#~~~~~~~~~~~~~~~~~~~~~~~~
+ "fade in time"
+       int typestr="seconds"
+       default="180"
+       optional
+
+option "snooze_in_vol" -
+#~~~~~~~~~~~~~~~~~~~~~~~
+ "vol to fade to after snooze"
+       int typestr="volume"
+       default="80"
+       optional
 
 section "fade options"
-option "fade_vol" f "volume to fade to" int typestr="volume" default="50" optional
-option "fade_time" t "time to fade in" int typestr="seconds" default="5" optional
+######################
+
+option "fade_vol" f
+#~~~~~~~~~~~~~~~~~~
+ "volume to fade to"
+       int typestr="volume"
+       default="50"
+       optional
+
+option "fade_time" t
+#~~~~~~~~~~~~~~~~~~~
+ "time to fade in"
+       int typestr="seconds"
+       default="5"
+       optional
diff --git a/fd.c b/fd.c
index b913009369ba6029fcdf4fa8378c9d926e30dd10..36b3769d289a03aa0148aa941a713ba1534a2be0 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -56,11 +56,11 @@ int file_exists(const char *fn)
  * \sa select(2) select_tut(2)
  */
 int para_select(int n, fd_set *readfds, fd_set *writefds,
-               struct timeval *timeout)
+               struct timeval *timeout_tv)
 {
        int ret, err;
        do {
-               ret = select(n, readfds, writefds, NULL, timeout);
+               ret = select(n, readfds, writefds, NULL, timeout_tv);
                err = errno;
        } while (ret < 0 && err == EINTR);
        if (ret < 0)
diff --git a/fd.h b/fd.h
index e17f11f6b1e6bf3f7587c7914e6b0fd8a88c0ae1..46178bd4ee92282499c4fb886fa94d9e68e3ca6c 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -20,7 +20,7 @@
 
 int file_exists(const char *);
 int para_select(int n, fd_set *readfds, fd_set *writefds,
-               struct timeval *timeout);
+               struct timeval *timeout_tv);
 int mark_fd_nonblock(int fd);
 void para_fd_set(int fd, fd_set *fds, int *max_fileno);
 __must_check int para_fread(void *dest, size_t nbytes, size_t nmemb, FILE *stream);
index dc601ec0a9de38ebd10d499f8df663dac1630ae3..3684ee6b0304b8c5a381d1b2ce8d06a3aff339bb 100644 (file)
@@ -133,8 +133,8 @@ again:
        list_for_each_entry(fn, &fc->filters, node) {
                if (*loaded && fn->loaded < fn->bufsize) {
                        size_t old_fn_loaded = fn->loaded;
-                       PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n",
-                               fc, *loaded, fn->filter->name);
+//                     PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n",
+//                             fc, *loaded, fn->filter->name);
                        t->ret = fn->filter->convert(ib, *loaded, fn);
                        if (t->ret < 0)
                                goto err_out;
@@ -143,9 +143,9 @@ again:
                        *loaded -= t->ret;
                        conv += t->ret;
                        if (*loaded && t->ret) {
-                               PARA_DEBUG_LOG("moving %zd bytes in input "
-                                       "buffer for %s filter\n",
-                                       *loaded,  fn->filter->name);
+//                             PARA_DEBUG_LOG("moving %zd bytes in input "
+//                                     "buffer for %s filter\n",
+//                                     *loaded,  fn->filter->name);
                                memmove(ib, ib + t->ret, *loaded);
                        }
                }
@@ -153,10 +153,10 @@ again:
                loaded = &fn->loaded;
        }
        conv_total += conv;
-       PARA_DEBUG_LOG("eof (in/out/fc): %d/%d/%d out_loaded: %zd, "
-               "conv: %d, conv_total: %d\n", *fc->input_eof,
-               fc->output_eof? *fc->output_eof : -42,
-               fc->eof, *fc->out_loaded, conv, conv_total);
+//     PARA_DEBUG_LOG("eof (in/out/fc): %d/%d/%d out_loaded: %zd, "
+//             "conv: %d, conv_total: %d\n", *fc->input_eof,
+//             fc->output_eof? *fc->output_eof : -42,
+//             fc->eof, *fc->out_loaded, conv, conv_total);
        if (conv)
                goto again;
        t->ret = 1;
index 735e5b4bc90739c0c55991eaffcaf76f02841ea0..efe9cf613b13720684b24cf2a0db85799fcd3aef 100644 (file)
@@ -89,31 +89,31 @@ rewrite:
 static int check_gc_args(struct grab_client *gc)
 {
        int i;
-       struct grab_client_args_info *conf = gc->conf;
+       struct grab_client_args_info *c = gc->conf;
        char **mv = grab_client_cmdline_parser_mode_values;
 
-       PARA_INFO_LOG("filter_num: %d\n", gc->conf->filter_num_arg);
+       PARA_INFO_LOG("filter_num: %d\n", c->filter_num_arg);
        for (i = 0; mv[i]; i++)
-               if (!strcmp(conf->mode_arg, mv[i]))
+               if (!strcmp(c->mode_arg, mv[i]))
                        break;
        if (!mv[i])
                return -E_GC_SYNTAX;
        gc->mode = i;
        gc->audio_format_num = -1;
-       if (conf->audio_format_given) {
-               gc->audio_format_num = get_audio_format_num(conf->audio_format_arg);
+       if (c->audio_format_given) {
+               gc->audio_format_num = get_audio_format_num(c->audio_format_arg);
                if (gc->audio_format_num < 0)
                        return gc->audio_format_num;
        }
-       if (conf->slot_arg > MAX_STREAM_SLOTS)
+       if (c->slot_arg > MAX_STREAM_SLOTS)
                return -E_BAD_GC_SLOT;
-       if (conf->filter_num_arg <= 0)
+       if (c->filter_num_arg <= 0)
                return -E_BAD_GC_FILTER_NUM;
-       if (conf->audio_format_given) {
-               if (num_filters(gc->audio_format_num) < conf->filter_num_arg)
+       if (c->audio_format_given) {
+               if (num_filters(gc->audio_format_num) < c->filter_num_arg)
                        return -E_BAD_GC_FILTER_NUM;
        } else
-               if (conf->filter_num_arg > max_num_filters())
+               if (c->filter_num_arg > max_num_filters())
                        return -E_BAD_GC_FILTER_NUM;
 
        return 1;
@@ -183,7 +183,7 @@ void activate_grab_client(struct grab_client *gc, struct filter_node *fn)
  * \sa filter_chain_info::filters, inactive_grab_client_list,
  * activate_grab_client
  */
-void activate_inactive_grab_clients(int slot, int audio_format_num,
+void activate_inactive_grab_clients(int slot_num, int audio_format_num,
                struct list_head *filter_list)
 {
        struct grab_client *gc, *tmp;
@@ -192,7 +192,7 @@ void activate_inactive_grab_clients(int slot, int audio_format_num,
 
        list_for_each_entry_safe(gc, tmp, &inactive_grab_client_list, node) {
 //             PARA_INFO_LOG("checking inactive grab client %p\n", gc);
-               if (gc->conf->slot_arg >= 0 && gc->conf->slot_arg != slot)
+               if (gc->conf->slot_arg >= 0 && gc->conf->slot_arg != slot_num)
                        continue;
                if (gc->audio_format_num >= 0 && gc->audio_format_num !=
                                audio_format_num)
diff --git a/gui.c b/gui.c
index 8b1b39a876e3ea84cc6cde1800edb4df3bdf026a..ffd1ea842039760bd6a1ec268a01423334bbb368 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -893,10 +893,7 @@ repeat:
        /* command pipe only for COMMAND_MODE */
        if (command_pipe >= 0 && mode == COMMAND_MODE)
                para_fd_set(command_pipe, &rfds, &max_fileno);
-       if (curses_active)
-               para_fd_set(STDIN_FILENO, &rfds, &max_fileno);
        ret = para_select(max_fileno + 1, &rfds, NULL, &tv);
-//     PARA_DEBUG_LOG("select returned %d\n", ret);
        if (ret <= 0)
                goto check_return; /* skip fd checks */
        /* signals */
@@ -1086,22 +1083,22 @@ static void com_scroll_up(void)
 {
        struct rb_entry *rbe = NULL;
        unsigned lines;
-       int i, first_rbe, scroll;
+       int i, first_rbe, num_scroll;
 
        /* the entry that is going to vanish */
        rbe = ringbuffer_get(bot_win_rb, scroll_position);
        if (!rbe)
                goto err_out;
-       scroll = NUM_LINES(rbe->len);
+       num_scroll = NUM_LINES(rbe->len);
        first_rbe = first_visible_rbe(&lines);
        if (first_rbe < 0 || (first_rbe == ringbuffer_filled(bot_win_rb) - 1))
                goto err_out;
        scroll_position++;
-       wscrl(bot.win, -scroll);
+       wscrl(bot.win, -num_scroll);
        i = draw_top_rbe(&lines);
        if (i < 0)
                goto err_out;
-       while (i > 0 && lines < scroll) {
+       while (i > 0 && lines < num_scroll) {
                int rbe_lines;
                rbe = ringbuffer_get(bot_win_rb, --i);
                if (!rbe)
diff --git a/gui.ggo b/gui.ggo
index ab42144a718e167f318a394c73c10d93e558e06e..34cbdb1978359287291bc0a1a3b5dfd0554c8510 100644 (file)
--- a/gui.ggo
+++ b/gui.ggo
@@ -2,7 +2,7 @@ section "general options"
 option "auto_decode" a "auto-decode audio stream" flag on
 option "config_file" c "(default='~/.paraslash/gui.conf')" string typestr="filename" optional
 option "loglevel" l "set loglevel (0-6)" int typestr="level" default="4" optional
-option "timeout" t "set timeout" int typestr="milliseconds" default="300" optional
+option "timeout" t "set timeout" int typestr="milliseconds" default="30" optional
 option "stat_cmd" s "command to read server and audiod status data from" string typestr="command" default="para_audioc -t 100 stat" optional
 
 section "mapping keys to commands"
index 07cab16fe211c740c7a25a484e1fee5271490498..87676986719c326340d1612ec85763349d2225be 100644 (file)
@@ -1,4 +1,5 @@
 #include "para.h"
+#include "fd.h"
 
 extern const char *status_item_list[NUM_STAT_ITEMS];
 
@@ -7,8 +8,14 @@ int para_open_audiod_pipe(char *cmd)
 {
        int fds[3] = {0, 1, 0};
        pid_t pid;
-       return para_exec_cmdline_pid(&pid, cmd, fds) > 0?
-               fds[1] : -1;
+       int ret = para_exec_cmdline_pid(&pid, cmd, fds);
+       if (ret < 0)
+               return ret;
+       ret = mark_fd_nonblock(fds[1]);
+       if (ret > 0)
+               return fds[1];
+       close(fds[1]);
+       return ret;
 }
 
 int read_audiod_pipe(int fd, void (*line_handler)(char *) )
index f0c9851fbe722889a46f12ff39741a7298b5929f..111c49baf82aa58e9bb9172ad0a8deb86b9ee571 100644 (file)
@@ -208,11 +208,11 @@ static void http_send( long unsigned current_chunk,
                        continue;
                if (hc->status == HTTP_READY_TO_STREAM) {
                        int hlen;
-                       char *buf = afs_get_header(&hlen);
-                       if (buf && hlen > 0 && current_chunk) {
+                       char *hbuf = afs_get_header(&hlen);
+                       if (hbuf && hlen > 0 && current_chunk) {
                                /* need to send header */
                                PARA_INFO_LOG("queueing header: %d\n", hlen);
-                               if (queue_packet(hc, buf, hlen) < 0)
+                               if (queue_packet(hc, hbuf, hlen) < 0)
                                        continue;
                        } else
                                PARA_INFO_LOG("%s", "no need to queue header\n");
index cd0899469b0ba2cd95f88b604c748e9900f309e6..d38e435942843508760e2b5ced1d2c05840efc39 100644 (file)
--- a/mp3_afh.c
+++ b/mp3_afh.c
@@ -403,7 +403,7 @@ static int mp3_read_info(void)
        tv_divide(fcount, &total_time, &af->chunk_tv);
        rewind(mp3.file);
        PARA_DEBUG_LOG("chunk_time: %lums\n", tv2ms(&af->chunk_tv));
-       tv_scale(30, &af->chunk_tv, &af->eof_tv);
+       tv_scale(3, &af->chunk_tv, &af->eof_tv);
        PARA_DEBUG_LOG("eof timeout: %lu\n", tv2ms(&af->eof_tv));
        return 1;
 }
diff --git a/net.c b/net.c
index 28bc777d4dde6f56be5414d4d8d92aeb0d47ab6e..b05f74da69b62d3fd3a25a7ac58633f1628c1249 100644 (file)
--- a/net.c
+++ b/net.c
 #include "string.h"
 #include "error.h"
 
+
+/** \cond holds information about one encrypted connection */
 struct crypt_data {
        crypt_function *recv;
        crypt_function *send;
        void *private_data;
 };
-
-static struct crypt_data *crypt_data_array;
 static unsigned cda_size = 0;
+static struct crypt_data *crypt_data_array;
+/** \endcond */
 
-void enable_crypt(int fd, crypt_function *recv, crypt_function *send,
+
+/**
+ * activate encryption for one file descriptor
+ *
+ * \param fd the file descriptor
+ * \param recv_f the function used for decrypting received data
+ * \param send_f the function used for encrypting before sending
+ * \param private_data user data supplied by the caller
+ */
+void enable_crypt(int fd, crypt_function *recv_f, crypt_function *send_f,
        void *private_data)
 {
        if (fd + 1 > cda_size) {
                crypt_data_array = para_realloc(crypt_data_array,
                        (fd + 1) * sizeof(struct crypt_data));
-               memset(crypt_data_array + cda_size * sizeof(struct crypt_data), 0,
+               memset(crypt_data_array + cda_size, 0,
                        (fd + 1 - cda_size) * sizeof(struct crypt_data));
                cda_size = fd + 1;
        }
-       crypt_data_array[fd].recv = recv;
-       crypt_data_array[fd].send = send;
+       crypt_data_array[fd].recv = recv_f;
+       crypt_data_array[fd].send = send_f;
        crypt_data_array[fd].private_data = private_data;
        PARA_INFO_LOG("rc4 encryption activated for fd %d\n", fd);
 }
 
+/**
+ * deactivate encryption for a given fd
+ *
+ * \param fd the file descriptor
+ *
+ * This must be called if and only if \p fd was activated via enable_crypt().
+ */
 void disable_crypt(int fd)
 {
        if (cda_size < fd + 1)
@@ -560,8 +578,11 @@ int recv_pattern(int fd, const char *pattern, size_t bufsize)
                goto out;
        ret = 1;
 out:
-       if (ret < 0)
-               PARA_NOTICE_LOG("did not receive pattern '%s'\n", pattern);
+       if (ret < 0) {
+               PARA_NOTICE_LOG("n = %d, did not receive pattern '%s'\n", n, pattern);
+               if (n > 0)
+                       PARA_NOTICE_LOG("recvd: %s\n", buf);
+       }
        free(buf);
        return ret;
 }
diff --git a/net.h b/net.h
index 58732c0cbb857ece77b456a4457920b5e1057a77..4a89778b87495136ca046813c3af274201097b19 100644 (file)
--- a/net.h
+++ b/net.h
@@ -48,7 +48,7 @@ int recv_cred_buffer(int, char *, size_t);
 ssize_t send_cred_buffer(int, char*);
 int recv_pattern(int fd, const char *pattern, size_t bufsize);
 int init_tcp_socket(int port);
-void enable_crypt(int fd, crypt_function *recv, crypt_function *send,
+void enable_crypt(int fd, crypt_function *recv_f, crypt_function *send_f,
        void *private_data);
 void disable_crypt(int fd);
 
index 874947e8e3175199aaa780995aac519d8a9aaa66..cce1eb54f40c02d05e96419c1afd0e849c18c6a4 100644 (file)
--- a/ogg_afh.c
+++ b/ogg_afh.c
@@ -37,7 +37,7 @@ static FILE *infile;
 static int header_len, oggbuf_len, vi_channels;
 static char *header, *oggbuf;
 static ssize_t *chunk_table, max_chunk_len;
-struct audio_format_handler *af;
+static struct audio_format_handler *af;
 static long vi_sampling_rate, vi_bitrate, vi_bitrate_nominal,
        num_chunks;
 
@@ -129,7 +129,7 @@ static void tunetable(void)
                        continue;
                }
                if (j < 0)
-                       tv_scale(i + 2, &af->chunk_tv, &af->eof_tv);
+                       tv_scale(i, &af->chunk_tv, &af->eof_tv);
                for (j = lp; j < i; j++)
                        chunk_table[j] = chunk_table[i];
                lp = i;
@@ -207,14 +207,14 @@ static void ogg_close_audio_file(void)
        oggbuf_len = 0;
 }
 
-static int ogg_save_header(FILE *file, int header_len)
+static int ogg_save_header(FILE *file, int len)
 {
        int ret;
 
-       header = para_malloc(header_len);
+       header = para_malloc(len);
        rewind(file);
-       ret = read(fileno(file), header, header_len);
-       if (ret != header_len)
+       ret = read(fileno(file), header, len);
+       if (ret != len)
                return -E_OGG_READ;
        return 1;
 }
index d9b260980e89f0a0c06d9de72cb390de0075aeef..1f2f78b7d08322e2d82550fc31335fed1149a2cf 100644 (file)
@@ -32,8 +32,6 @@
 
 #define CHUNK_SIZE 128 * 1024
 
-extern int msg_to_buf(mblk_t *, char *, int);
-
 /**
  * data specific to the ortp receiver
  *
@@ -67,6 +65,37 @@ uint32_t timestamp;
 uint32_t chunk_ts;
 };
 
+
+static int msg_to_buf(mblk_t *mp, char *buffer, int len)
+{
+       int rlen = len;
+       mblk_t *m, *mprev;
+       int mlen;
+
+       m = mp->b_cont;
+       mprev = mp;
+       while (m != NULL) {
+               mlen = (int) (m->b_wptr - m->b_rptr);
+               if (mlen <= rlen) {
+                       mblk_t *consumed = m;
+                       memcpy (buffer, m->b_rptr, mlen);
+                       /* go to next mblk_t */
+                       mprev->b_cont = m->b_cont;
+                       m = m->b_cont;
+                       consumed->b_cont = NULL;
+                       freeb (consumed);
+                       buffer += mlen;
+                       rlen -= mlen;
+               } else {  /*if mlen>rlen */
+                       memcpy (buffer, m->b_rptr, rlen);
+                       m->b_rptr += rlen;
+                       return len;
+               }
+       }
+       return len - rlen;
+}
+
+
 static void ortp_recv_pre_select(struct sched *s, struct task *t)
 {
        struct receiver_node *rn = t->private_data;
@@ -91,9 +120,9 @@ static void compute_next_chunk(unsigned chunk_time,
        tv_add(&chunk_tv, &pord->next_chunk, &tmp);
        pord->next_chunk = tmp;
        pord->timestamp += pord->chunk_ts;
-       PARA_DEBUG_LOG("next chunk (ts = %d) due at %lu:%lu\n",
-               pord->timestamp, pord->next_chunk.tv_sec,
-               pord->next_chunk.tv_usec);
+//     PARA_DEBUG_LOG("next chunk (ts = %d) due at %lu:%lu\n",
+//             pord->timestamp, pord->next_chunk.tv_sec,
+//             pord->next_chunk.tv_usec);
 }
 
 static void ortp_recv_post_select(__a_unused struct sched *s, struct task *t)
@@ -244,20 +273,20 @@ static void *ortp_recv_parse_config(int argc, char **argv)
 static int ortp_recv_open(struct receiver_node *rn)
 {
        struct private_ortp_recv_data *pord;
-       struct ortp_recv_args_info *conf = rn->conf;
+       struct ortp_recv_args_info *c = rn->conf;
 
        rn->buf = para_calloc(CHUNK_SIZE);
 
        rn->private_data = para_calloc(sizeof(struct private_ortp_recv_data));
        pord = rn->private_data;
        pord->session = rtp_session_new(RTP_SESSION_RECVONLY);
-       PARA_NOTICE_LOG("receiving from %s:%d\n", conf->host_arg, conf->port_arg);
-       rtp_session_set_local_addr(pord->session, conf->host_arg, conf->port_arg);
+       PARA_NOTICE_LOG("receiving from %s:%d\n", c->host_arg, c->port_arg);
+       rtp_session_set_local_addr(pord->session, c->host_arg, c->port_arg);
        rtp_session_set_payload_type(pord->session, PAYLOAD_AUDIO_CONTINUOUS);
-       if (conf->jitter_compensation_arg) {
+       if (c->jitter_compensation_arg) {
                rtp_session_enable_adaptive_jitter_compensation(pord->session, TRUE);
                rtp_session_set_jitter_compensation(pord->session,
-                       conf->jitter_compensation_arg);
+                       c->jitter_compensation_arg);
        }
        return 1;
 }
diff --git a/para.h b/para.h
index 3f05079740160c8aed96c1bf068696c8ca7872c3..26e04c6c435c47c8939f0803fcc62d556c005db1 100644 (file)
--- a/para.h
+++ b/para.h
 #if DEBUG > COMPILE_TIME_LOGLEVEL
 #define PARA_DEBUG_LOG(f,...) para_log(DEBUG, "%s: " f, __FUNCTION__, __VA_ARGS__)
 #else
-#define PARA_DEBUG_LOG(...)
+#define PARA_DEBUG_LOG(...) do {;} while (0)
 #endif
 
 #if INFO > COMPILE_TIME_LOGLEVEL
 #define PARA_INFO_LOG(f,...) para_log(INFO, "%s: " f, __FUNCTION__, __VA_ARGS__)
 #else
-#define PARA_INFO_LOG(...)
+#define PARA_INFO_LOG(...) do {;} while (0)
 #endif
 
 #if NOTICE > COMPILE_TIME_LOGLEVEL
 #define PARA_NOTICE_LOG(f,...) para_log(NOTICE, "%s: " f, __FUNCTION__, __VA_ARGS__)
 #else
-#define PARA_NOTICE_LOG(...)
+#define PARA_NOTICE_LOG(...) do {;} while (0)
 #endif
 
 #if WARNING > COMPILE_TIME_LOGLEVEL
 #define PARA_WARNING_LOG(f,...) para_log(WARNING, "%s: " f, __FUNCTION__, __VA_ARGS__)
 #else
-#define PARA_WARNING_LOG(...)
+#define PARA_WARNING_LOG(...) do {;} while (0)
 #endif
 
 #if ERROR > COMPILE_TIME_LOGLEVEL
 #define PARA_ERROR_LOG(f,...) para_log(ERROR, "%s: " f, __FUNCTION__, __VA_ARGS__)
 #else
-#define PARA_ERROR_LOG(...)
+#define PARA_ERROR_LOG(...) do {;} while (0)
 #endif
 
 #if CRIT > COMPILE_TIME_LOGLEVEL
 #define PARA_CRIT_LOG(f,...) para_log(CRIT, "%s: " f, __FUNCTION__, __VA_ARGS__)
 #else
-#define PARA_CRIT_LOG(...)
+#define PARA_CRIT_LOG(...) do {;} while (0)
 #endif
 
 #if EMERG > COMPILE_TIME_LOGLEVEL
@@ -131,7 +131,7 @@ long unsigned tv2ms(const struct timeval*);
 void d2tv(double, struct timeval*);
 void tv_add(const struct timeval*, const struct timeval *, struct timeval *);
 void tv_scale(const unsigned long, const struct timeval *, struct timeval *);
-void tv_divide(const unsigned long div, const struct timeval *tv,
+void tv_divide(const unsigned long divisor, const struct timeval *tv,
        struct timeval *result);
 int tv_convex_combination(const long a, const struct timeval *tv1,
                const long b, const struct timeval *tv2,
index c30465e57e1f74fe47c2fb34e10d134ad7624c5d..b67b3d1e48554993f61f836e5bc3a60e23f828a1 100644 (file)
--- a/sdl_gui.c
+++ b/sdl_gui.c
@@ -505,7 +505,7 @@ static SDLKey hit_key(const char *msg)
  */
 static int command_handler(void)
 {
-       FILE *pipe;
+       FILE *f;
        unsigned count = 0;
        char text[MAXLINE]="";
        char buf[MAXLINE]="";
@@ -521,15 +521,15 @@ static int command_handler(void)
        if (text[0] == '!') {
                if (text[1] == '\0')
                        return 1;
-               pipe = popen(text + 1, "r");
+               f = popen(text + 1, "r");
        } else {
                sprintf(buf, BINDIR "/para_client %s 2>&1", text);
-               pipe = popen(buf, "r");
+               f = popen(buf, "r");
        }
-       if (!pipe)
+       if (!f)
                return 0;
        fill_output_rect();
-       while(fgets(text, MAXLINE - 1, pipe)) {
+       while(fgets(text, MAXLINE - 1, f)) {
                int len;
 
                tab2space(text);
@@ -554,7 +554,7 @@ static int command_handler(void)
        update_all();
        hit_key("Hit any key to return");
 out:   fill_output_rect();
-       pclose(pipe);
+       pclose(f);
        return 1;
 }
 
@@ -585,14 +585,14 @@ SDL_Surface *load_jpg(void)
        SDL_RWops *rwop;
        int fds[3] = {0, 1, 0};
        pid_t pid;
-       FILE *pipe;
+       FILE *f;
 
        if (para_exec_cmdline_pid(&pid, args_info.pic_cmd_arg, fds) < 0)
                return NULL;
-       pipe = fdopen(fds[1], "r");
-       if (!pipe)
+       f = fdopen(fds[1], "r");
+       if (!f)
                return NULL;
-       if (!(rwop = SDL_RWFromFP(pipe, 0)))
+       if (!(rwop = SDL_RWFromFP(f, 0)))
                return NULL;
        return IMG_LoadJPG_RW(rwop);
 }
@@ -689,7 +689,7 @@ void update_status(char *buf)
  * Read stat line from pipe if pipe is ready, call update_status to
  * display information.
  */
-static int draw_status(int pipe)
+static int draw_status(int fd)
 {
        fd_set rfds;
        int ret;
@@ -698,11 +698,11 @@ static int draw_status(int pipe)
        tv.tv_sec = 0;
        tv.tv_usec = 3000000;
        FD_ZERO(&rfds);
-       FD_SET(pipe, &rfds);
-       ret = para_select(pipe + 1, &rfds, NULL, &tv);
+       FD_SET(fd, &rfds);
+       ret = para_select(fd + 1, &rfds, NULL, &tv);
        if (ret <= 0)
                return 0;
-       if (read_audiod_pipe(pipe, update_status) > 0)
+       if (read_audiod_pipe(fd, update_status) > 0)
                return 1;
        free(stat_items[SI_STATUS_BAR].content);
        stat_items[SI_STATUS_BAR].content =
@@ -739,7 +739,7 @@ static int configfile_exists(void)
  */
 int main(int argc, char *argv[])
 {
-       int i, ret, pipe;
+       int i, ret, fd;
        SDLKey sym;
 
        sdl_gui_cmdline_parser(argc, argv, &args_info);
@@ -759,7 +759,7 @@ int main(int argc, char *argv[])
        height = args_info.height_arg;
 //     printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg);
        init_stat_items();
-       pipe = para_open_audiod_pipe(args_info.stat_cmd_arg);
+       fd = para_open_audiod_pipe(args_info.stat_cmd_arg);
        init_SDL();
        for (i = 0; fonts[i].name[0]; i++) {
                char buf[MAXLINE];
@@ -775,10 +775,10 @@ int main(int argc, char *argv[])
                update_input();
        }
        for (;;) {
-               ret = draw_status(pipe);
+               ret = draw_status(fd);
                if (ret < 0) {
-                       close(pipe);
-                       pipe = -1;
+                       close(fd);
+                       fd = -1;
                }
                if (SDL_QuitRequested())
                        clean_exit(0);
@@ -802,11 +802,9 @@ int main(int argc, char *argv[])
                                || sym == SDLK_COMPOSE
                                )
                                continue;
-                       if (pipe < 0) {
-//                             printf("closing pipe\n");
-                               kill(0, SIGINT);
-                               close(pipe);
-//                             printf("pipe closed\n");
+                       if (fd < 0) {
+                               kill(0, SIGINT);
+                               close(fd);
                        }
                        fill_input_rect();
                        update_input();
@@ -816,7 +814,7 @@ int main(int argc, char *argv[])
                        print_help();
                        update_pic();
                        SDL_UpdateRect(screen, 0, 0, 0, 0);
-                       pipe = para_open_audiod_pipe(args_info.stat_cmd_arg);
+                       fd = para_open_audiod_pipe(args_info.stat_cmd_arg);
                        break;
                }
        }
index 2d40d49bdc30cad6a926c3da7aa1bec71d5417df..f9b95f9006dee9c9cd558bb39bc0cc6c90ca1bb1 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -89,7 +89,7 @@ pid_t para_reap_child(void)
        if (pid <= 0) {
                if (pid < 0)
                        pid = -E_WAITPID;
-               return 0;
+               return pid;
        }
        if (WIFEXITED(status))
                PARA_DEBUG_LOG("child %i exited. Exit status: %i\n", pid,
diff --git a/stat.c b/stat.c
index 39aab43ebd256a6de2e20015e4519ed98b77c761..33fdb8c1d0fec0596482820f447fb57c3754b003 100644 (file)
--- a/stat.c
+++ b/stat.c
 #define MAX_STAT_CLIENTS 50
 
 /**
- * The structure associated with a connected client that sent the 'stat' command
-*
+ * describes a status client of para_audiod
+ *
+ * There's one such structure per audiod client that sent the 'stat' command.
  *
  * A status client is identified by its file descriptor.  para_audiod
  * keeps a list of connected status clients.
  */
 struct stat_client {
-/**
- *
- *
- * the stat client's file descriptor
- */
-int fd;
-long unsigned item_mask;
-/**
- *
- * its entry in the list of stat clients
-*/
-struct list_head node;
+       /** the stat client's file descriptor */
+       int fd;
+       /** bitmask of those status items the client is interested in */
+       long unsigned item_mask;
+       /** its entry in the list of stat clients */
+       struct list_head node;
 };
 
 static struct list_head client_list;
diff --git a/time.c b/time.c
index 34e3de9523cb91a6c4142cf36ec6d540d21d7fe6..d6e070809e527fba5437f59e0fe7976893432b9e 100644 (file)
--- a/time.c
+++ b/time.c
@@ -106,16 +106,17 @@ void tv_scale(const unsigned long mult, const struct timeval *tv,
 /**
  * compute fraction of given struct timeval
  *
- * \param div the integer value to divide by
+ * \param divider the integer value to divide by
  * \param tv the timevalue to divide
  * \param result holds (1 / mult) * tv upon return
  */
-void tv_divide(const unsigned long div, const struct timeval *tv,
+void tv_divide(const unsigned long divisor, const struct timeval *tv,
        struct timeval *result)
 {
-       long unsigned q = tv->tv_usec / div;
-       result->tv_sec = tv->tv_sec / div;
-       result->tv_usec = (tv->tv_sec - result->tv_sec * div) * 1000 * 1000 / div;
+       long unsigned q = tv->tv_usec / divisor;
+       result->tv_sec = tv->tv_sec / divisor;
+       result->tv_usec = (tv->tv_sec - result->tv_sec * divisor)
+               * 1000 * 1000 / divisor;
        if (result->tv_usec + q >= 1000 * 1000) {
                result->tv_sec++;
                result->tv_usec = 1000 * 1000 - result->tv_usec - q;
index 62925efbeb84bb991b280b160a77a5f67bc103b9..2ad43010cff1e18d57b4b742ba96a7d6563e619b 100644 (file)
@@ -156,13 +156,6 @@ SPAN.comment       { color: #00CCCC }
 SPAN.preprocessor  { color: #CC00CC }
 SPAN.stringliteral { color: #e0e020 }
 SPAN.charliteral   { color: #0000ff }
-.mdTable {
-       border: 1px solid #868686;
-       background-color: #112244;
-}
-.mdRow {
-       padding: 8px 10px;
-}
 .mdescLeft {
        padding: 0px 8px 4px 8px;
        font-size: 80%;
@@ -307,4 +300,93 @@ HR { height: 1px;
      border: none;
      border-top: 1px solid yellow;
 }
+/* Style for detailed member documentation */
+.memtemplate {
+  font-size: 80%;
+  color: #a0a0a0; 
+  font-weight: normal;
+} 
+.memnav { 
+/*  background-color: #181eff; */
+  border: 1px solid #845047;
+  text-align: center;
+  margin: 2px;
+  margin-right: 15px;
+  padding: 2px;
+}
+.memitem {
+  padding: 4px;
+  background-color: #000000;
+  border-width: 1px;
+  border-style: solid;
+  border-color: #ffff00;
+  -moz-border-radius: 8px 8px 8px 8px;
+}
+.memname {
+  white-space: nowrap;
+  font-weight: bold;
+}
+.memdoc{
+  padding-left: 10px;
+}
+.memproto {
+  background-color: #000055;
+  width: 100%;
+  border-width: 1px;
+  border-style: solid;
+  border-color: #ffff00;
+  font-weight: bold;
+  -moz-border-radius: 8px 8px 8px 8px;
+}
+.paramkey {
+  text-align: right;
+}
+.paramtype {
+  white-space: nowrap;
+}
+.paramname {
+  color: #00ff00;
+  font-style: italic;
+}
+/* End Styling for detailed member documentation */
+
+
+/* gitweb */
+div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background
+-color:#000000; }                               
+div.page_nav { padding:8px; }                   
+div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
+div.page_footer { height:17px; padding:4px 8px; background-color: #000000; }
+div.page_footer_text { float:left; color:#888888; font-style:italic; }
+div.page_body { padding:8px; }
+div.title, a.title {
+        padding:6px 8px;
+        font-weight:bold;
+}
+div.log_body { padding:8px 8px 8px 150px; }
+span.age { position:relative; float:left; width:142px; font-style:italic; }
+div.log_link {
+        padding:0px 8px;
+        font-size:10px; font-family:sans-serif; font-style:normal;
+        position:relative; float:left; width:136px;
+}
+table { padding:8px 4px; }
+th { padding:2px 5px; font-size:12px; text-align:left; }
+td { padding:2px 5px; font-size:12px; vertical-align:top; }
+td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
+div.pre { font-family:monospace; font-size:12px; white-space:pre; }
+div.diff_info { font-family:monospace; color:#8888ff; font-style:italic; }
+div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
+div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
+a.linenr { color:#999999; text-decoration:none }
+a.rss_logo {
+        float:right; padding:3px 0px; width:35px; line-height:10px;
+        border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
+        color:#ffffff; background-color:#ff6600;
+        font-weight:bold; font-family:sans-serif; font-size:10px;
+        text-align:center; text-decoration:none;
+}
+a.rss_logo:hover { background-color:#ee5500; }
+span.tag {
+        padding:0px 4px; font-size:10px; font-weight:normal;
 
diff --git a/write.c b/write.c
index 498dd78d08c8f90a9334fcaf1d5f4d7820df81ec..7f29665de46f0844589e36a144e4b61848dda79b 100644 (file)
--- a/write.c
+++ b/write.c
@@ -59,37 +59,37 @@ static struct writer_node_group *wng;
  */
 static void check_wav_pre_select(__a_unused struct sched *s, struct task *t)
 {
-       struct check_wav_task *cwt = t->private_data;
+       struct check_wav_task *wt = t->private_data;
        unsigned char *a;
 
-       if (*cwt->loaded < WAV_HEADER_LEN) {
-               t->ret = *cwt->eof? -E_PREMATURE_END : 1;
+       if (*wt->loaded < WAV_HEADER_LEN) {
+               t->ret = *wt->eof? -E_PREMATURE_END : 1;
                return;
        }
-       cwt->channels = 2;
-       cwt->samplerate = 44100;
-       a = (unsigned char*)cwt->buf;
+       wt->channels = 2;
+       wt->samplerate = 44100;
+       a = (unsigned char*)wt->buf;
        t->ret = -E_NO_WAV_HEADER;
        if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F')
                return;
-       cwt->channels = (unsigned) a[22];
-       cwt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
-       *cwt->loaded -= WAV_HEADER_LEN;
-       memmove(cwt->buf, cwt->buf + WAV_HEADER_LEN, *cwt->loaded);
+       wt->channels = (unsigned) a[22];
+       wt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
+       *wt->loaded -= WAV_HEADER_LEN;
+       memmove(wt->buf, wt->buf + WAV_HEADER_LEN, *wt->loaded);
        t->ret = -E_WAV_HEADER_SUCCESS;
-       PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->samplerate);
+       PARA_INFO_LOG("channels: %d, sample rate: %d\n", wt->channels, wt->samplerate);
 }
 
 static void initial_delay_pre_select(struct sched *s, struct task *t)
 {
-       struct initial_delay_task *idt = t->private_data;
+       struct initial_delay_task *dt = t->private_data;
        struct timeval diff;
 
        t->ret = -E_NO_DELAY;
-       if (!idt->start_time.tv_sec && !idt->start_time.tv_usec)
+       if (!dt->start_time.tv_sec && !dt->start_time.tv_usec)
                return;
        t->ret = -E_DELAY_TIMEOUT;
-       if (tv_diff(now, &idt->start_time, &diff) > 0)
+       if (tv_diff(now, &dt->start_time, &diff) > 0)
                return;
        t->ret = 1;
        if (tv_diff(&s->timeout , &diff, NULL) > 0)
@@ -110,7 +110,7 @@ void para_log(int ll, const char* fmt,...)
 static struct writer_node_group *check_args(void)
 {
        int i, ret = -E_WRITE_SYNTAX;
-       struct writer_node_group *wng = NULL;
+       struct writer_node_group *g = NULL;
 
        if (conf.list_writers_given) {
                char *msg = NULL;
@@ -126,8 +126,6 @@ static struct writer_node_group *check_args(void)
                free(msg);
                exit(EXIT_SUCCESS);
        }
-//     if (conf.prebuffer_arg < 0 || conf.prebuffer_arg > 100)
-//             goto out;
        if (conf.start_time_given) {
                long unsigned sec, usec;
                if (sscanf(conf.start_time_arg, "%lu:%lu",
@@ -137,25 +135,25 @@ static struct writer_node_group *check_args(void)
                idt.start_time.tv_usec = usec;
        }
        if (!conf.writer_given) {
-               wng = setup_default_wng();
+               g = setup_default_wng();
                ret = 1;
                goto out;
        }
-       wng = wng_new(conf.writer_given);
+       g = wng_new(conf.writer_given);
        ret = -E_WRITE_SYNTAX;
        for (i = 0; i < conf.writer_given; i++) {
                int writer_num;
-               wng->writer_nodes[i].conf = check_writer_arg(
+               g->writer_nodes[i].conf = check_writer_arg(
                        conf.writer_arg[i], &writer_num);
-               if (!wng->writer_nodes[i].conf)
+               if (!g->writer_nodes[i].conf)
                        goto out;
-               wng->writer_nodes[i].writer = &writers[writer_num];
+               g->writer_nodes[i].writer = &writers[writer_num];
        }
        ret = 1;
 out:
        if (ret > 0)
-               return wng;
-       free(wng);
+               return g;
+       free(g);
        return NULL;
 }