audiod: Only call audiod_status_dump twice per second.
[paraslash.git] / audiod.c
index 2b6f1e69637d1b851926d25b277c90c6d6f5df9a..3d0cd6483173cd75f571cb9669f297be4954afea 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -5,6 +5,7 @@
  */
 
 /** \file audiod.c the paraslash's audio daemon */
+#include <regex.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <signal.h>
@@ -19,7 +20,6 @@
 #include "ggo.h"
 #include "recv.h"
 #include "filter.h"
-#include "grab_client.cmdline.h"
 #include "grab_client.h"
 #include "client.cmdline.h"
 #include "client.h"
@@ -162,7 +162,7 @@ struct command_task {
  * \return The audio format number on success, -E_UNSUPPORTED_AUDIO_FORMAT if
  * \a name is not a supported audio format.
  */
-int get_audio_format_num(char *name)
+int get_audio_format_num(const char *name)
 {
        int i;
 
@@ -445,7 +445,7 @@ static void open_writers(int slot_num)
                stat_task->server_stream_start : *now;
        s->offset_seconds = stat_task->offset_seconds;
        s->seconds_total = stat_task->length_seconds;
-       activate_inactive_grab_clients(slot_num, s->format, s->fc);
+       activate_inactive_grab_clients(s->format, s->fc);
 }
 
 static int open_receiver(int format)
@@ -902,8 +902,15 @@ static void command_post_select(struct sched *s, struct task *t)
 {
        int ret;
        struct command_task *ct = container_of(t, struct command_task, task);
+       static struct timeval last_status_dump;
+       struct timeval tmp;
+
+       tv_add(&last_status_dump, &(struct timeval){0, 500 * 1000}, &tmp);
+       if (tv_diff(&tmp, now, NULL) < 0) {
+               audiod_status_dump();
+               last_status_dump = *now;
+       }
 
-       audiod_status_dump();
        if (!FD_ISSET(ct->fd, &s->rfds))
                return;
        ret = handle_connect(ct->fd);