Implement routing groups and volume ramp up/down
[staging/agl-audio-plugin.git] / node.h
1 /*
2  * module-agl-audio -- PulseAudio module for providing audio routing support
3  * (forked from "module-murphy-ivi" - https://github.com/otcshare )
4  * Copyright (c) 2012, Intel Corporation.
5  * Copyright (c) 2016, IoT.bzh
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms and conditions of the GNU Lesser General Public License,
9  * version 2.1, as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
19  * MA 02110-1301 USA.
20  *
21  */
22 #ifndef paaglnode
23 #define paaglnode
24
25 #include <stdbool.h>
26 #include <stdint.h>
27
28 #include "userdata.h"
29 #include "list.h"
30 #include "loopback.h"
31
32 #define APCLASS_DIM  (agl_application_class_end - agl_application_class_begin + 1)
33
34 struct agl_nodeset {
35         pa_idxset  *nodes;
36         pa_hashmap *roles;
37         pa_hashmap *binaries;
38         const char *class_name[APCLASS_DIM]; /* as much elements as app.classes (see in "userdata.h") */
39 };
40
41 struct agl_nodeset_resdef {
42         uint32_t priority;
43         struct {
44                 uint32_t rset;
45                 uint32_t audio;
46         } flags;
47 };
48
49 struct agl_nodeset_map {
50         const char *name;
51         agl_node_type type;
52         const char *role;
53         agl_nodeset_resdef *resdef;
54 };
55
56 struct agl_node_card {
57         uint32_t  index;
58         char     *profile;
59 };
60
61 struct agl_node_rset {
62         char     *id;               /**< resource set id, if any */
63         bool      grant;            /**< permission to play/render etc */
64 };
65
66 struct agl_node {
67         uint32_t       index;     /**< index into nodeset->idxset */
68         char          *key;       /**< hash key for discover lookups */
69         agl_direction  direction; /**< agl_input | agl_output */
70         agl_implement  implement; /**< agl_device | agl_stream */
71         pa_client     *client;    /**< matching client pointer (for agl_input nodes only) */
72         agl_null_sink  *nullsink; /**< associated null sink (for agl_input nodes only) */
73         agl_loopnode   *loopnode; /**< associated loopback */
74         uint32_t       channels;  /**< number of channels (eg. 1=mono, 2=stereo) */
75         agl_location   location;  /**< mir_internal | mir_external */
76         agl_privacy    privacy;   /**< mir_public | mir_private */
77         agl_node_type  type;      /**< mir_speakers | mir_headset | ...  */
78         char          *zone;      /**< zone where the node belong */
79         bool           visible;   /**< internal or can appear on UI  */
80         bool           available; /**< eg. is the headset connected?  */
81         bool           ignore;    /**< do not consider it while routing  */
82         bool           localrset; /**< locally generated resource set */
83         const char    *amname;    /**< audiomanager name */
84         const char    *amdescr;   /**< UI description */
85         uint16_t       amid;      /**< handle to audiomanager, if any */
86         const char    *paname;    /**< sink|source|sink_input|source_output name */
87         uint32_t       paidx;     /**< sink|source|sink_input|source_output index*/
88         agl_node_card   pacard;   /**< pulse card related data, if any  */
89         const char    *paport;    /**< sink or source port if applies */
90         /*pa_muxnode    *mux;*/       /**< for multiplexable input streams only */
91         agl_dlist      rtentries; /**< in device nodes: listhead of nodchain */
92         agl_dlist      rtprilist; /**< in stream nodes: priority link (head is in
93                                                                    pa_router)*/
94         agl_dlist      constrains; /**< listhead of constrains */
95         /*mir_vlim       vlim;*/      /**< volume limit */
96         agl_node_rset   rset;      /**< resource set info if applies */
97         uint32_t       stamp;
98         /*scripting_node *scripting;*/ /** scripting data, if any */
99 };
100
101 agl_nodeset *agl_nodeset_init (struct userdata *);
102 void agl_nodeset_done (struct userdata *);
103
104 int agl_nodeset_add_role (struct userdata *, const char *, agl_node_type, agl_nodeset_resdef *);
105
106 agl_node *agl_node_create (struct userdata *, agl_node *);
107 void agl_node_destroy (struct userdata *, agl_node *);
108 const char *agl_node_type_str (agl_node_type);
109 const char *agl_node_direction_str (agl_direction);
110
111 agl_node *agl_node_get_from_data (struct userdata *, agl_direction, void *);
112 agl_node *agl_node_get_from_client (struct userdata *, pa_client *);
113
114 bool agl_node_has_highest_priority (struct userdata *, agl_node *);
115
116 #endif