routing: set correct routing class when reinstating a default stream
[profile/ivi/pulseaudio-module-murphy-ivi.git] / murphy / node.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 foomirnodefoo
21 #define foomirnodefoo
22
23 #include <sys/types.h>
24
25 #include "userdata.h"
26 #include "list.h"
27 #include "multiplex.h"
28 #include "loopback.h"
29 #include "volume.h"
30
31 #define AM_ID_INVALID  65535
32
33
34 enum mir_direction {
35     mir_direction_unknown,
36     mir_input,
37     mir_output
38 };
39
40 enum mir_implement {
41     mir_implementation_unknown = 0,
42     mir_device,
43     mir_stream
44 };
45
46 enum mir_location {
47     mir_location_unknown = 0,
48     mir_internal,
49     mir_external
50 };
51
52 enum mir_node_type {
53     mir_node_type_unknown = 0,
54
55     /* application classes */
56     mir_application_class_begin,
57     mir_radio = mir_application_class_begin,
58     mir_player,
59     mir_navigator,
60     mir_game,
61     mir_browser,
62     mir_phone,
63     mir_event,
64     mir_application_class_end,
65
66     /* device types */
67     mir_device_class_begin = 128,
68     mir_null = mir_device_class_begin,
69     mir_speakers,
70     mir_front_speakers,
71     mir_rear_speakers,
72     mir_microphone,
73     mir_jack,
74     mir_spdif,
75     mir_hdmi,
76     mir_wired_headset,
77     mir_wired_headphone,
78     mir_usb_headset,
79     mir_usb_headphone,
80     mir_bluetooth_sco,
81     mir_bluetooth_a2dp,
82     mir_bluetooth_carkit,
83     mir_bluetooth_source,
84     mir_bluetooth_sink,
85     mir_device_class_end,
86
87     /* extensions */
88     mir_user_defined_start = 256
89 };
90
91 enum mir_privacy {
92     mir_privacy_unknown = 0,
93     mir_public,
94     mir_private
95 };
96
97 struct pa_node_card {
98     uint32_t  index;
99     char     *profile;
100 };
101
102
103 /**
104  * @brief routing endpoint
105  *
106  * @details node is a routing endpoint in the GenIVI audio model.
107  *          In pulseaudio terminology a routing endpoint is one of
108  *          the following
109  * @li      node is a pulseaudio sink or source. Such node is a
110  *          combination of pulseudio card/profile + sink/port
111  * @li      node is a pulseaudio stream. Such node in pulseaudio
112  *          is either a sink_input or a source_output
113  */
114 struct mir_node {
115     uint32_t       index;     /**< index into nodeset->idxset */
116     char          *key;       /**< hash key for discover lookups */
117     mir_direction  direction; /**< mir_input | mir_output */
118     mir_implement  implement; /**< mir_device | mir_stream */
119     uint32_t       channels;  /**< number of channels (eg. 1=mono, 2=stereo) */
120     mir_location   location;  /**< mir_internal | mir_external */
121     mir_privacy    privacy;   /**< mir_public | mir_private */
122     mir_node_type  type;      /**< mir_speakers | mir_headset | ...  */
123     pa_bool_t      visible;   /**< internal or can appear on UI  */
124     pa_bool_t      available; /**< eg. is the headset connected?  */
125     pa_bool_t      ignore;    /**< do not consider it while routing  */
126     char          *amname;    /**< audiomanager name */
127     char          *amdescr;   /**< UI description */
128     uint16_t       amid;      /**< handle to audiomanager, if any */
129     char          *paname;    /**< sink|source|sink_input|source_output name */
130     uint32_t       paidx;     /**< sink|source|sink_input|source_output index*/
131     pa_node_card   pacard;    /**< pulse card related data, if any  */
132     char          *paport;    /**< sink or source port if applies */
133     pa_muxnode    *mux;       /**< for multiplexable input streams only */
134     pa_loopnode   *loop;      /**< for looped back sources only */
135     mir_dlist      rtentries; /**< for devices: listhead of nodchain,
136                                    for streams: priority link (head is in
137                                                                pa_router )
138                                */
139     mir_dlist      constrains;/**< listhead of constrains */
140     mir_vlim       vlim;      /**< volume limit */
141     uint32_t       stamp;
142 };
143
144
145 pa_nodeset *pa_nodeset_init(struct userdata *);
146 void pa_nodeset_done(struct userdata *);
147
148
149 mir_node *mir_node_create(struct userdata *, mir_node *);
150 void mir_node_destroy(struct userdata *, mir_node *);
151
152 mir_node *mir_node_find_by_index(struct userdata *, uint32_t);
153
154 int mir_node_print(mir_node *, char *, int);
155
156 const char *mir_direction_str(mir_direction);
157 const char *mir_implement_str(mir_implement);
158 const char *mir_location_str(mir_location);
159 const char *mir_node_type_str(mir_node_type);
160 const char *mir_node_type_str(mir_node_type);
161 const char *mir_privacy_str(mir_privacy);
162
163 #endif
164
165
166 /*
167  * Local Variables:
168  * c-basic-offset: 4
169  * indent-tabs-mode: nil
170  * End:
171  *
172  */