From: Andre Date: Sun, 28 May 2006 19:35:51 +0000 (+0200) Subject: audiod: split init_stream_io() X-Git-Tag: v0.2.14~101^2~13 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=e122abcdde0cde522b891315b5cbb680b74fa021;p=paraslash.git audiod: split init_stream_io() It consists of three independent parts. --- diff --git a/audiod.c b/audiod.c index 60e7903f..631bcf5e 100644 --- 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;