]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - audiod.c
client_close(): disable crypt
[paraslash.git] / audiod.c
index e35c2ec700342c439ac53ec460c2ab34c4ca718d..ac692bc1b5468a2a0f075e8c74ffdf931f556cee 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;
 };
 
@@ -533,8 +540,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 tmp, 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, &tmp);
+                       else
+                               tv_diff(&stat_task->server_stream_start,
+                                       &stat_task->sa_time_diff, &tmp);
+                       tv_add(&tmp, &delay, &initial_delay_barrier);
                }
                break;
        case SI_CURRENT_TIME:
@@ -597,6 +614,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 +633,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,9 +752,10 @@ 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, ':');
+               PARA_INFO_LOG("arg: %s\n", arg);
                ret = -E_MISSING_COLON;
                if (!recv)
                        goto out;