]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/command_util_replace_tabs'
authorAndre Noll <maan@systemlinux.org>
Sat, 29 Jan 2011 10:37:34 +0000 (11:37 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 29 Jan 2011 10:37:34 +0000 (11:37 +0100)
15 files changed:
NEWS
aacdec_filter.c
audiod.c
color.c
color.h
command.c
daemon.c
daemon.h
dccp_send.c
http_send.c
para.h
send.h
server.c
udp_send.c
vss.c

diff --git a/NEWS b/NEWS
index adcc23eb32bef81071b159abcd87160074c6ea19..561929b1422c2c56328e96df8cdd9b75eb8e51b2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@
 0.4.6 (to be announced) "deterministic entropy"
 -----------------------------------------------
 
+       - For DCCP/OGG streams the audio file header is only sent once
+         at the beginning of the stream rather than periodically
+         every five seconds. This reduces network traffic and the
+         FEC group size.
+
 --------------------------------------------
 0.4.5 (2010-12-17) "symmetric randomization"
 --------------------------------------------
index 1ac6a99a225ea4b6c4f4faa72ce825dfd285ae72..95c13305519e39a86eff3cbe5cdf06b280ef8d04 100644 (file)
@@ -89,7 +89,7 @@ static void aacdec_post_select(__a_unused struct sched *s, struct task *t)
        int i, ret;
        unsigned char *p, *inbuf, *outbuffer;
        char *btr_buf;
-       size_t len, skip, consumed, loaded, iqs;
+       size_t len, skip, consumed, loaded;
 
 next_buffer:
        t->error = 0;
@@ -102,7 +102,6 @@ next_buffer:
        len = btr_next_buffer(btrn, (char **)&inbuf);
        len = PARA_MIN(len, (size_t)8192);
        consumed = 0;
-       iqs = btr_get_input_queue_size(btrn);
        if (!padd->initialized) {
                unsigned long rate = 0;
                unsigned char channels = 0;
@@ -168,12 +167,15 @@ next_buffer:
                ret = -E_AAC_DECODE;
                if (padd->error_count++ > MAX_ERRORS)
                        goto err;
-               PARA_ERROR_LOG("frame_error: %d (%s), consumed: %zu + %zd + %lu\n",
-                       err, NeAACDecGetErrorMessage(padd->frame_info.error),
+               /* Suppress non-fatal bitstream error message at BOF/EOF */
+               if (len < fn->min_iqs || padd->consumed_total == 0) {
+                       consumed = len;
+                       goto success;
+               }
+               PARA_ERROR_LOG("%s\n", NeAACDecGetErrorMessage(err));
+               PARA_ERROR_LOG("consumed: %zu + %zd + %lu\n",
                        padd->consumed_total, consumed,
                        padd->frame_info.bytesconsumed);
-               PARA_ERROR_LOG("%s\n", NeAACDecGetErrorMessage(
-                       padd->frame_info.error));
                if (consumed < len)
                        consumed++; /* catch 21 */
                goto success;
index 8b62e083fa8bde9b153e97e66315f2a03c4cbdcb..64ea8a51efeeb13cb65f86d1ea417120679ff2f4 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1298,17 +1298,14 @@ __noreturn static void print_help_and_die(void)
 
 static void init_colors_or_die(void)
 {
-       int ret, i;
+       int i;
 
        if (!want_colors())
                return;
        daemon_set_default_log_colors();
        daemon_set_flag(DF_COLOR_LOG);
-       for (i = 0; i < conf.log_color_given; i++) {
-               ret = daemon_set_log_color(conf.log_color_arg[i]);
-               if (ret < 0)
-                       exit(EXIT_FAILURE);
-       }
+       for (i = 0; i < conf.log_color_given; i++)
+               daemon_set_log_color_or_die(conf.log_color_arg[i]);
 }
 
 /**
diff --git a/color.c b/color.c
index ca5a32d3bc6ccec7d4e93c2f8f6b285a53b22dcb..0e2beeb0cac4f703668a666db4b57ab954c27c0e 100644 (file)
--- a/color.c
+++ b/color.c
@@ -47,11 +47,9 @@ static int parse_attr(const char *name, int len)
  * \param value Human-readable color spec.
  * \param dst Result pointer for the escape sequence.
  *
- * \return -1 on errors, 1 on success.
- *
  * Format of \a value: [fg [bg]] [attr].
  */
-int color_parse(const char *value, char *dst)
+void color_parse_or_die(const char *value, char *dst)
 {
        const char *ptr = value;
        int attr = -1;
@@ -60,7 +58,7 @@ int color_parse(const char *value, char *dst)
 
        if (!strcasecmp(value, "reset")) {
                strcpy(dst, COLOR_RESET);
-               return 1;
+               return;
        }
 
        /* [fg [bg]] [attr] */
@@ -125,8 +123,8 @@ int color_parse(const char *value, char *dst)
                *dst++ = 'm';
        }
        *dst = 0;
-       return 1;
+       return;
 bad:
-       PARA_ERROR_LOG("bad color value '%s'\n", value);
-       return -1;
+       PARA_EMERG_LOG("bad color value '%s'\n", value);
+       exit(EXIT_FAILURE);
 }
diff --git a/color.h b/color.h
index 12972b3a2f1b7181305a6f34949a4bcfa08ad1b6..167c929470827cf5e3e8556b3e052dc6dbf82957 100644 (file)
--- a/color.h
+++ b/color.h
@@ -7,4 +7,4 @@
 /** Switch back to normal colors. */
 #define COLOR_RESET "\033[m"
 
-int color_parse(const char *value, char *dst);
+void color_parse_or_die(const char *value, char *dst);
index e95318c4f1661c50caf7664542d20e5babddbcac..57e851f938c700044be20b62226dc07fae63c07e 100644 (file)
--- a/command.c
+++ b/command.c
@@ -13,6 +13,7 @@
 #include <dirent.h>
 #include <openssl/rc4.h>
 #include <osl.h>
+#include <stdbool.h>
 
 #include "para.h"
 #include "error.h"
index a67e9e2b45b43e8abcbe3b5d8a62da3dcb516ffa..b7a0a3267b68df5b020159f90c56337073463244 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -56,10 +56,8 @@ void daemon_set_default_log_colors(void)
                [LL_CRIT] = "magenta bold",
                [LL_EMERG] = "red bold",
        };
-       for (i = 0; i < NUM_LOGLEVELS; i++) {
-               int ret = color_parse(default_log_colors[i], me->log_colors[i]);
-               assert(ret >= 0);
-       }
+       for (i = 0; i < NUM_LOGLEVELS; i++)
+               color_parse_or_die(default_log_colors[i], me->log_colors[i]);
 }
 
 /**
@@ -71,7 +69,7 @@ void daemon_set_default_log_colors(void)
  *
  * \return 1 On success, -1 on errors.
  */
-int daemon_set_log_color(char const *arg)
+void daemon_set_log_color_or_die(char const *arg)
 {
        char *p = strchr(arg, ':');
        int ret, ll;
@@ -83,14 +81,11 @@ int daemon_set_log_color(char const *arg)
                goto err;
        ll = ret;
        p++;
-       ret = color_parse(p, me->log_colors[ll]);
-       if (ret < 0)
-               goto err;
-       return 1;
+       color_parse_or_die(p, me->log_colors[ll]);
+       return;
 err:
-       PARA_ERROR_LOG("%s: color syntax error\n", arg);
-       return -1;
-
+       PARA_EMERG_LOG("%s: color syntax error\n", arg);
+       exit(EXIT_FAILURE);
 }
 
 /**
index 3705b9da27cc9db1892fb06c5b64cdcd273702da..4e803bdc4aa18df8bf124e53d1c024ed65cf2fef 100644 (file)
--- a/daemon.h
+++ b/daemon.h
@@ -15,7 +15,7 @@ void daemon_set_flag(unsigned flag);
 void daemon_clear_flag(unsigned flag);
 void daemon_set_loglevel(char *loglevel);
 void daemon_set_default_log_colors(void);
-int daemon_set_log_color(char const *arg);
+void daemon_set_log_color_or_die(char const *arg);
 
 /** Daemon log configuration flags. */
 enum daemon_flags {
index 425527fc423e90dfc0396d7680d25d00733379ea..304a42e749a647d5d6a568ae0e9850d183907979 100644 (file)
@@ -145,6 +145,7 @@ static void dccp_post_select(fd_set *rfds, __a_unused fd_set *wfds)
        dfc->fcp.slices_per_group       = conf.dccp_slices_per_group_arg;
        dfc->fcp.init_fec               = dccp_init_fec;
        dfc->fcp.send_fec               = dccp_send_fec;
+       dfc->fcp.need_periodic_header   = false;
        dfc->fc = vss_add_fec_client(sc, &dfc->fcp);
 }
 
index 4ad857662f6ef5d9029129c6714b8c0c20ecdca4..086b600f0d043f928e6c2c0f71afa65104045f00 100644 (file)
@@ -10,6 +10,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 #include <osl.h>
+#include <stdbool.h>
 
 #include "para.h"
 #include "error.h"
diff --git a/para.h b/para.h
index df7d755f20072c9a21066fbedfc1b492bdb58de8..c5e12fe6da3ef864bdc16bb0eaa178a8b5965cee 100644 (file)
--- a/para.h
+++ b/para.h
@@ -70,7 +70,7 @@
 /** Version text used by various commands if -V switch was given. */
 #define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION \
        " (" GIT_VERSION ": " CODENAME ")" "\n" \
-       "Copyright (C) 2010 Andre Noll\n" \
+       "Copyright (C) 2011 Andre Noll\n" \
        "This is free software with ABSOLUTELY NO WARRANTY." \
        " See COPYING for details.\n" \
        "Written by Andre Noll.\n" \
diff --git a/send.h b/send.h
index e13909321f193b8326bcfda87e1adecedd2ff5ae..836babd50845088be08a2061fe39cc6ffd7760cb 100644 (file)
--- a/send.h
+++ b/send.h
@@ -131,6 +131,8 @@ struct fec_client_parms {
        uint8_t slices_per_group;
        /** Number of slices minus number of redundant slices. */
        uint8_t data_slices_per_group;
+       /** Whether the header must be sent periodically. */
+       bool need_periodic_header;
        /**
         * Transport-layer initialisation for FEC support.
         *
index dfac4c588910bfbbf3ae1469d26992849b811647..849b707a43043a501ab92cadbed6af66f725a139 100644 (file)
--- a/server.c
+++ b/server.c
@@ -68,6 +68,7 @@
 #include <openssl/rc4.h>
 #include <regex.h>
 #include <osl.h>
+#include <stdbool.h>
 
 #include "para.h"
 #include "error.h"
@@ -146,17 +147,14 @@ static int want_colors(void)
 
 static void init_colors_or_die(void)
 {
-       int ret, i;
+       int i;
 
        if (!want_colors())
                return;
        daemon_set_flag(DF_COLOR_LOG);
        daemon_set_default_log_colors();
-       for (i = 0; i < conf.log_color_given; i++) {
-               ret = daemon_set_log_color(conf.log_color_arg[i]);
-               if (ret < 0)
-                       exit(EXIT_FAILURE);
-       }
+       for (i = 0; i < conf.log_color_given; i++)
+               daemon_set_log_color_or_die(conf.log_color_arg[i]);
 }
 
 /*
index 003757ef8a94b2af8c7218d31fdaca6489ed765b..4fb10b444be321c51e7d33da2442fd6b8a469138 100644 (file)
@@ -14,6 +14,7 @@
 #include <netinet/udp.h>
 #include <net/if.h>
 #include <osl.h>
+#include <stdbool.h>
 
 #include "server.cmdline.h"
 #include "para.h"
@@ -317,6 +318,7 @@ static int udp_com_add(struct sender_command_data *scd)
        ut->fcp.data_slices_per_group = scd->data_slices_per_group;
        ut->fcp.init_fec              = udp_init_fec;
        ut->fcp.send_fec              = udp_send_fec;
+       ut->fcp.need_periodic_header  = true;
 
        sc->private_data = ut;
        sc->fd = -1;
diff --git a/vss.c b/vss.c
index 38e829356e2adf1f866ceaaaa84fbdbe603193ea..916a71d518762f63675c65c195f87b6fdce089e1 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -227,12 +227,29 @@ static bool need_audio_header(struct fec_client *fc, struct vss_task *vsst)
                return false;
        if (vsst->header_len == 0)
                return false;
-       if (fc->group.num && tv_diff(&fc->next_header_time, now, NULL) > 0)
-               return false;
+       if (fc->group.num > 0) {
+               if (!fc->fcp->need_periodic_header)
+                       return false;
+               if (tv_diff(&fc->next_header_time, now, NULL) > 0)
+                       return false;
+       }
        tv_add(now, &vsst->header_interval, &fc->next_header_time);
        return true;
 }
 
+static bool need_data_slices(struct fec_client *fc, struct vss_task *vsst)
+{
+       if (fc->group.num > 0)
+               return true;
+       if (!vsst->header_buf)
+               return true;
+       if (vsst->header_len == 0)
+               return true;
+       if (fc->fcp->need_periodic_header)
+               return true;
+       return false;
+}
+
 static int num_slices(long unsigned bytes, int max_payload, int rs)
 {
        int ret;
@@ -246,11 +263,15 @@ static int num_slices(long unsigned bytes, int max_payload, int rs)
 }
 
 /* set group start and group duration */
-static void set_group_timing(struct fec_client *fc, struct fec_group *g)
+static void set_group_timing(struct fec_client *fc, struct vss_task *vsst)
 {
+       struct fec_group *g = &fc->group;
        struct timeval *chunk_tv = vss_chunk_time();
 
-       tv_scale(g->num_chunks, chunk_tv, &g->duration);
+       if (!need_data_slices(fc, vsst))
+               ms2tv(200, &g->duration);
+       else
+               tv_scale(g->num_chunks, chunk_tv, &g->duration);
        tv_divide(fc->fcp->slices_per_group + fc->num_extra_slices,
                &g->duration, &g->slice_duration);
        PARA_DEBUG_LOG("durations (group/chunk/slice): %lu/%lu/%lu\n",
@@ -288,7 +309,10 @@ static int initialize_fec_client(struct fec_client *fc, struct vss_task *vsst)
        if (ret < 0)
                return ret;
        ds = ret;
-       k = hs + ds;
+       if (fc->fcp->need_periodic_header)
+               k = hs + ds;
+       else
+               k = PARA_MAX(hs, ds);
        if (k < fc->fcp->data_slices_per_group)
                k = fc->fcp->data_slices_per_group;
        fc->num_extra_slices = k - fc->fcp->data_slices_per_group;
@@ -407,6 +431,13 @@ static int compute_slice_size(struct fec_client *fc, struct vss_task *vsst)
                        g->slice_bytes = 1;
                return 1;
        }
+       if (!need_data_slices(fc, vsst)) {
+               g->bytes = 0;
+               g->num_chunks = 0;
+               g->slice_bytes = DIV_ROUND_UP(vsst->header_len, k);
+               g->num_header_slices = k;
+               return 1;
+       }
        h = vsst->header_len;
        max_group_bytes = (k - num_slices(h, max_slice_bytes, n - k))
                * max_slice_bytes;
@@ -467,7 +498,7 @@ static int setup_next_fec_group(struct fec_client *fc, struct vss_task *vsst)
                 */
                tmp = g->start;
                tv_add(&tmp, &g->duration, &g->start);
-               set_group_timing(fc, g);
+               set_group_timing(fc, vsst);
                g->first_chunk += g->num_chunks;
                g->num++;
        }
@@ -483,7 +514,7 @@ static int setup_next_fec_group(struct fec_client *fc, struct vss_task *vsst)
        assert(g->num_header_slices + data_slices <= k);
        fc->current_slice_num = 0;
        if (g->num == 0)
-               set_group_timing(fc, g);
+               set_group_timing(fc, vsst);
 
        /* setup header slices */
        buf = vsst->header_buf;