]> git.tue.mpg.de Git - paraslash.git/commitdiff
audiod: split init_stream_io()
authorAndre <maan@p133.(none)>
Sun, 28 May 2006 19:35:51 +0000 (21:35 +0200)
committerAndre <maan@p133.(none)>
Sun, 28 May 2006 19:35:51 +0000 (21:35 +0200)
It consists of three independent parts.

audiod.c

index 60e7903fa11b22dcc82a9d84368d642ab932851a..631bcf5e0ff7174fe10a12ab11acc273ceedeaef 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -773,7 +773,7 @@ static int is_frozen(int format, struct timeval *now)
        return (tv_diff(now, &a->restart_barrier, NULL) > 0)? 0 : 1;
 }
 
-static void start_current_receiver(struct timeval *now)
+static void open_current_receiver(struct timeval *now)
 {
        int i;
 
@@ -934,7 +934,7 @@ static void audiod_pre_select(struct sched *s, __a_unused struct task *t)
        if (audiod_status != AUDIOD_ON)
                kill_all_decoders();
        else if (playing)
-               start_current_receiver(&s->now);
+               open_current_receiver(&s->now);
        check_timeouts();
        FOR_EACH_SLOT(i) {
                struct receiver_node *rn;
@@ -1038,9 +1038,9 @@ out:
        return ret;
 }
 
-static int init_stream_io(void)
+static int init_writers(void)
 {
-       int i, ret, receiver_num, nf, nw;
+       int i, ret, nw;
        char *cmd;
        struct audio_format_info *a;
 
@@ -1072,6 +1072,17 @@ static int init_stream_io(void)
                        nw, writer_names[writer_num]);
                a->num_writers++;
        }
+       ret = 1;
+out:
+       return ret;
+}
+
+static int init_receivers(void)
+{
+       int i, ret, receiver_num;
+       char *cmd = NULL;
+       struct audio_format_info *a;
+
        for (i = 0; receivers[i].name; i++) {
                PARA_INFO_LOG("initializing %s receiver\n", receivers[i].name);
                receivers[i].init(&receivers[i]);
@@ -1108,8 +1119,15 @@ static int init_stream_io(void)
                        return -E_RECV_SYNTAX;
                a->receiver = &receivers[receiver_num];
        }
+       ret = 1;
+out:
        free(cmd);
-       /* filters */
+       return ret;
+}
+static int init_filters(void)
+{
+       int i, ret, nf;
+
        filter_init(filters);
        nf = PARA_MAX(2,  conf.filter_given) + 1;
        PARA_INFO_LOG("allocating space for %d filters\n", nf);
@@ -1139,6 +1157,22 @@ out:
        return ret;
 }
 
+static int init_stream_io(void)
+{
+       int ret;
+
+       ret = init_writers();
+       if (ret < 0)
+               return ret;
+       ret = init_receivers();
+       if (ret < 0)
+               return ret;
+       ret = init_filters();
+       if (ret < 0)
+               return ret;
+       return 1;
+}
+
 static int dump_commands(int fd)
 {
        char *buf = para_strdup(""), *tmp = NULL;