audiod: Deprecate the --no_default_filters option.
[paraslash.git] / audiod.c
index 8008e2c..d7765e2 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1,14 +1,13 @@
 /*
 /*
- * Copyright (C) 2005-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
-/** \file audiod.c the paraslash's audio daemon */
+/** \file audiod.c The paraslash's audio daemon. */
 #include <regex.h>
 #include <sys/types.h>
 #include <signal.h>
 #include <regex.h>
 #include <sys/types.h>
 #include <signal.h>
-#include <stdbool.h>
 
 #include "para.h"
 #include "error.h"
 
 #include "para.h"
 #include "error.h"
@@ -33,6 +32,7 @@
 #include "signal.h"
 #include "version.h"
 
 #include "signal.h"
 #include "version.h"
 
+__printf_2_3 void (*para_log)(int, const char*, ...) = daemon_log;
 /** define the array of error lists needed by para_audiod */
 INIT_AUDIOD_ERRLISTS;
 /** define the array containing all supported audio formats */
 /** define the array of error lists needed by para_audiod */
 INIT_AUDIOD_ERRLISTS;
 /** define the array containing all supported audio formats */
@@ -77,6 +77,8 @@ enum vss_status_flags {
        VSS_STATUS_FLAG_PLAYING = 2,
 };
 
        VSS_STATUS_FLAG_PLAYING = 2,
 };
 
+struct sched sched = {.max_fileno = 0};
+
 /**
  * The task for obtaining para_server's status (para_client stat).
  *
 /**
  * The task for obtaining para_server's status (para_client stat).
  *
@@ -504,7 +506,7 @@ static void open_filters(struct slot_info *s)
                                .handler = f->execute, .context = fn));
 
                f->open(fn);
                                .handler = f->execute, .context = fn));
 
                f->open(fn);
-               register_task(&fn->task);
+               register_task(&sched, &fn->task);
                parent = fn->btrn;
                PARA_NOTICE_LOG("%s filter %d/%d (%s) started in slot %d\n",
                        audio_formats[s->format], i,  nf, f->name, (int)(s - slot));
                parent = fn->btrn;
                PARA_NOTICE_LOG("%s filter %d/%d (%s) started in slot %d\n",
                        audio_formats[s->format], i,  nf, f->name, (int)(s - slot));
@@ -527,7 +529,7 @@ static void open_writers(struct slot_info *s)
                wn = s->wns + i;
                wn->conf = a->writer_conf[i];
                wn->writer_num = a->writer_nums[i];
                wn = s->wns + i;
                wn->conf = a->writer_conf[i];
                wn->writer_num = a->writer_nums[i];
-               register_writer_node(wn, parent);
+               register_writer_node(wn, parent, &sched);
        }
 }
 
        }
 }
 
@@ -564,7 +566,7 @@ static int open_receiver(int format)
        rn->task.pre_select = r->pre_select;
        rn->task.post_select = r->post_select;
        sprintf(rn->task.status, "%s receiver node", r->name);
        rn->task.pre_select = r->pre_select;
        rn->task.post_select = r->post_select;
        sprintf(rn->task.status, "%s receiver node", r->name);
-       register_task(&rn->task);
+       register_task(&sched, &rn->task);
        return slot_num;
 }
 
        return slot_num;
 }
 
@@ -916,8 +918,10 @@ static int parse_filter_args(void)
 {
        int i, j, ret, af_mask;
 
 {
        int i, j, ret, af_mask;
 
-       if (!conf.no_default_filters_given)
-               return init_default_filters();
+       if (conf.no_default_filters_given) {
+               PARA_WARNING_LOG("--no_default_filters is deprecated\n");
+               PARA_WARNING_LOG("It has no effect and will be removed soon\n");
+       }
        for (i = 0; i < conf.filter_given; i++) {
                char *arg;
                ret = parse_stream_command(conf.filter_arg[i], &arg);
        for (i = 0; i < conf.filter_given; i++) {
                char *arg;
                ret = parse_stream_command(conf.filter_arg[i], &arg);
@@ -1146,7 +1150,7 @@ static void start_stop_decoders(void)
        if (a->num_filters)
                open_filters(sl);
        open_writers(sl);
        if (a->num_filters)
                open_filters(sl);
        open_writers(sl);
-       activate_grab_clients();
+       activate_grab_clients(&sched);
        btr_log_tree(sl->receiver_node->btrn, LL_NOTICE);
 }
 
        btr_log_tree(sl->receiver_node->btrn, LL_NOTICE);
 }
 
@@ -1157,7 +1161,7 @@ static void status_pre_select(struct sched *s, struct task *t)
 
        if (must_start_decoder())
                goto min_delay;
 
        if (must_start_decoder())
                goto min_delay;
-       ret = btr_node_status(st->btrn, 0, BTR_NT_LEAF);
+       ret = btr_node_status(st->btrn, st->min_iqs, BTR_NT_LEAF);
        if (ret > 0)
                goto min_delay;
        if (st->ct && audiod_status == AUDIOD_OFF)
        if (ret > 0)
                goto min_delay;
        if (st->ct && audiod_status == AUDIOD_OFF)
@@ -1179,7 +1183,7 @@ min_delay:
 }
 
 /* restart the client task if necessary */
 }
 
 /* restart the client task if necessary */
-static void status_post_select(__a_unused struct sched *s, struct task *t)
+static void status_post_select(struct sched *s, struct task *t)
 {
        struct status_task *st = container_of(t, struct status_task, task);
 
 {
        struct status_task *st = container_of(t, struct status_task, task);
 
@@ -1241,13 +1245,13 @@ static void status_post_select(__a_unused struct sched *s, struct task *t)
                int argc = 5;
                PARA_INFO_LOG("clock diff count: %d\n", st->clock_diff_count);
                st->clock_diff_count--;
                int argc = 5;
                PARA_INFO_LOG("clock diff count: %d\n", st->clock_diff_count);
                st->clock_diff_count--;
-               client_open(argc, argv, &st->ct, NULL, NULL, st->btrn);
+               client_open(argc, argv, &st->ct, NULL, NULL, st->btrn, s);
                set_stat_task_restart_barrier(2);
 
        } else {
                char *argv[] = {"audiod", "--", "stat", "-p", NULL};
                int argc = 4;
                set_stat_task_restart_barrier(2);
 
        } else {
                char *argv[] = {"audiod", "--", "stat", "-p", NULL};
                int argc = 4;
-               client_open(argc, argv, &st->ct, NULL, NULL, st->btrn);
+               client_open(argc, argv, &st->ct, NULL, NULL, st->btrn, s);
                set_stat_task_restart_barrier(5);
        }
        free(stat_item_values[SI_BASENAME]);
                set_stat_task_restart_barrier(5);
        }
        free(stat_item_values[SI_BASENAME]);
@@ -1331,7 +1335,6 @@ static void init_colors_or_die(void)
 int main(int argc, char *argv[])
 {
        int ret, i;
 int main(int argc, char *argv[])
 {
        int ret, i;
-       static struct sched s;
        struct command_task command_task_struct, *cmd_task = &command_task_struct;
        struct audiod_cmdline_parser_params params = {
                .override = 0,
        struct command_task command_task_struct, *cmd_task = &command_task_struct;
        struct audiod_cmdline_parser_params params = {
                .override = 0,
@@ -1383,12 +1386,12 @@ int main(int argc, char *argv[])
        if (conf.daemon_given)
                daemonize(false /* parent exits immediately */);
 
        if (conf.daemon_given)
                daemonize(false /* parent exits immediately */);
 
-       register_task(&sig_task->task);
-       register_task(&cmd_task->task);
-       register_task(&stat_task->task);
-       s.default_timeout.tv_sec = 2;
-       s.default_timeout.tv_usec = 999 * 1000;
-       ret = schedule(&s);
+       register_task(&sched, &sig_task->task);
+       register_task(&sched, &cmd_task->task);
+       register_task(&sched, &stat_task->task);
+       sched.default_timeout.tv_sec = 2;
+       sched.default_timeout.tv_usec = 999 * 1000;
+       ret = schedule(&sched);
 
        PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        return EXIT_FAILURE;
 
        PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        return EXIT_FAILURE;