Merge branch 'maint'
[paraslash.git] / audiod.c
index 1bed20c03871caaaac50c21377746001891d4d61..778318cebc2b8958e26b378987a4842c615a237d 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -191,7 +191,7 @@ int get_audio_format_num(const char *name)
  * It has to to take into account that probably the stream was not started at
  * the beginning of the file, that the clock between the server and the client
  * host may differ and that playback of the stream was delayed, e.g. because
- * the prebuffer filter is used in the filter chain of the given slot.
+ * the prebuffer filter is used in the filter configuration of the given slot.
  *
  * If no writer is active in the given slot, or \a slot_num is negative
  * (indicating that para_audiod runs in standby mode), an approximation based
@@ -980,19 +980,16 @@ static void signal_pre_select(struct sched *s, struct task *t)
        para_fd_set(st->fd, &s->rfds, &s->max_fileno);
 }
 
-static void signal_post_select(struct sched *s, struct task *t)
+static void signal_post_select(struct sched *s, __a_unused struct task *t)
 {
-       struct signal_task *st = container_of(t, struct signal_task, task);
-
-       if (!FD_ISSET(st->fd, &s->rfds))
-               return;
+       int signum;
 
-       st->signum = para_next_signal();
-       switch (st->signum) {
+       signum = para_next_signal(&s->rfds);
+       switch (signum) {
        case SIGINT:
        case SIGTERM:
        case SIGHUP:
-               PARA_EMERG_LOG("terminating on signal %d\n", st->signum);
+               PARA_EMERG_LOG("terminating on signal %d\n", signum);
                clean_exit(EXIT_FAILURE, "caught deadly signal");
        }
 }
@@ -1023,11 +1020,10 @@ static void command_post_select(struct sched *s, struct task *t)
                last_status_dump = *now;
        }
 
-       if (!FD_ISSET(ct->fd, &s->rfds))
-               return;
-       ret = handle_connect(ct->fd);
+       ret = handle_connect(ct->fd, &s->rfds);
        if (ret < 0)
                PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+       audiod_status_dump();
 }
 
 static void init_command_task(struct command_task *ct)
@@ -1151,10 +1147,19 @@ static void status_pre_select(struct sched *s, struct task *t)
        ret = btr_node_status(st->btrn, 0, BTR_NT_LEAF);
        if (ret > 0)
                goto min_delay;
-       if (!st->ct)
+       if (st->ct && audiod_status == AUDIOD_OFF)
+               goto min_delay;
+       if (!st->ct && audiod_status != AUDIOD_OFF)
                sched_request_barrier_or_min_delay(&st->restart_barrier, s);
        if (cafn >= 0)
                sched_request_barrier(&afi[cafn].restart_barrier, s);
+       /*
+        * If para_server is playing we'd like to have a smooth time display
+        * even if we are running in standby mode. So we request a timeout that
+        * expires at the next full second.
+        */
+       if (stat_task->vss_status & VSS_STATUS_FLAG_PLAYING)
+               sched_request_timeout_ms(1000 - now->tv_usec / 1000, s);
        return;
 min_delay:
        sched_min_delay(s);