scons --> make
[aftubes.git] / main.c
blob17d7f594250a51a9912ab2cbe2a7e7531671b682
1 #include "stdio.h"
2 #include "soundout.h"
3 #include "wavefile.h"
4 #include "modules/modules.h"
5 #include "graph.h"
6 #include "errors.h"
7 #include "assert.h"
9 #include "unistd.h"
10 #include "sys/types.h"
11 #include "signal.h"
13 void moan(err_t err)
15 if (err != EOK){
16 fprintf(stderr, "%s:%d: in function %s: %s\n",
17 get_last_error_file(),
18 get_last_error_line(),
19 get_last_error_func(),
20 get_last_error_message());
21 raise(SIGABRT);
25 int main(int argc, char **argv)
27 struct graph _graph, *graph = &_graph;
28 struct graphnode *node, *source_1, *source_2, *mixer, *sink;
29 err_t err;
31 if (graph_create(graph)){
32 fprintf(stderr, "cannot create graph\n");
33 return 1;
36 moan(wavesource_create(&node, "/home/aoe/reflections.wav"));
37 assert(node);
38 moan(graph_add_node(graph, node));
39 node->name = "source_1";
40 source_1 = node;
42 moan(wavesource_create(&node, "/home/aoe/horizon.wav"));
43 assert(node);
44 moan(graph_add_node(graph, node));
45 node->name = "source_2";
46 source_2 = node;
48 moan(playsink_create(&node));
49 assert(node);
50 moan(graph_add_node(graph, node));
51 node->name = "sink";
52 sink = node;
54 moan(mixer_create(&node));
55 assert(node);
56 moan(graph_add_node(graph, node));
57 node->name = "mixer";
58 mixer = node;
60 printf("connecting mixer in0\n");
61 moan(graph_connect(graph, source_1->pins, mixer->pins->next));
62 printf("connecting mixer in1\n");
63 moan(graph_connect(graph, source_2->pins, mixer->pins->next->next));
64 printf("connecting mixer out\n");
65 moan(graph_connect(graph, mixer->pins, sink->pins));
66 moan(graph_sort(graph));
69 struct graphnode *node;
70 for (node=graph->sorted_nodes; node; node=node->sorted_next){
71 printf("sorted_node: %s\n", node->name);
75 while ((err = graph_run(graph)) == EOK);
76 moan(err);
78 graph_destroy(graph);
81 return 0;