routing: set correct routing class when reinstating a default stream
[profile/ivi/pulseaudio-module-murphy-ivi.git] / murphy / router.h
1 /*
2  * module-murphy-ivi -- PulseAudio module for providing audio routing support
3  * Copyright (c) 2012, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU Lesser General Public License,
7  * version 2.1, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
17  * MA 02110-1301 USA.
18  *
19  */
20 #ifndef foomirrouterfoo
21 #define foomirrouterfoo
22
23 #include <sys/types.h>
24
25 #include "userdata.h"
26 #include "list.h"
27
28 typedef pa_bool_t (*mir_rtgroup_accept_t)(struct userdata *, mir_rtgroup *,
29                                           mir_node *);
30 typedef int       (*mir_rtgroup_compare_t)(struct userdata *u,
31                                            mir_node *, mir_node *);
32
33 struct pa_router {
34     pa_hashmap   *rtgroups;
35     int           maplen;     /**< length of the class- and priormap */
36     mir_rtgroup **classmap;   /**< to map device node types to rtgroups */
37     int          *priormap;   /**< stream node priorities */
38     mir_dlist     nodlist;    /**< priorized list of the input stream nodes */
39     mir_dlist     connlist;   /**< listhead of the connections */
40 };
41
42
43 struct mir_rtentry {
44     mir_dlist    link;        /**< rtgroup chain */
45     mir_dlist    nodchain;    /**< node chain */
46     mir_rtgroup *group;       /**< back pointer to the group  */
47     mir_node    *node;        /**< pointer to the owning node */
48     bool         blocked;     /**< weather this routing entry is active */
49     uint32_t     stamp;
50 };
51
52 struct mir_rtgroup {
53     char                 *name;     /**< name of the rtgroup  */
54     mir_dlist             entries;  /**< listhead of ordered rtentries */
55     mir_rtgroup_accept_t  accept;   /**< wheter to accept a node or not */
56     mir_rtgroup_compare_t compare;  /**< comparision function for ordering */
57 };
58
59 struct mir_connection {
60     mir_dlist     link;     /**< list of connections */
61     pa_bool_t     blocked;  /**< true if this conflicts with another route */
62     uint16_t      amid;     /**< audio manager connection id */
63     uint32_t      from;     /**< source node index */
64     uint32_t      to;       /**< destination node index */
65     uint32_t      stream;   /**< index of the sink-input to be routed */
66 };
67
68
69 pa_router *pa_router_init(struct userdata *);
70 void pa_router_done(struct userdata *);
71
72 void mir_router_assign_class_priority(struct userdata *, mir_node_type, int);
73
74 pa_bool_t mir_router_create_rtgroup(struct userdata *, const char *,
75                                     mir_rtgroup_accept_t,
76                                     mir_rtgroup_compare_t);
77 void mir_router_destroy_rtgroup(struct userdata *, const char *);
78 pa_bool_t mir_router_assign_class_to_rtgroup(struct userdata *, mir_node_type,
79                                              const char *);
80
81 void mir_router_register_node(struct userdata *, mir_node *);
82 void mir_router_unregister_node(struct userdata *, mir_node *);
83
84 mir_node *mir_router_make_prerouting(struct userdata *, mir_node *);
85 void mir_router_make_routing(struct userdata *);
86
87 mir_connection *mir_router_add_explicit_route(struct userdata *, uint16_t,
88                                               mir_node *, mir_node *);
89 void mir_router_remove_explicit_route(struct userdata *, mir_connection *);
90
91
92 int mir_router_print_rtgroups(struct userdata *, char *, int);
93
94 pa_bool_t mir_router_default_accept(struct userdata *, mir_rtgroup *,
95                                     mir_node *);
96 pa_bool_t mir_router_phone_accept(struct userdata *, mir_rtgroup *,
97                                   mir_node *);
98
99 int mir_router_default_compare(struct userdata *, mir_node *, mir_node *);
100 int mir_router_phone_compare(struct userdata *, mir_node *, mir_node *);
101
102
103 #endif  /* foomirrouterfoo */
104
105
106 /*
107  * Local Variables:
108  * c-basic-offset: 4
109  * indent-tabs-mode: nil
110  * End:
111  *
112  */