murphyif: Free the connect timer when unloading
[profile/ivi/pulseaudio-module-murphy-ivi.git] / murphy / audiomgr.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 fooaudiomgrfoo
21 #define fooaudiomgrfoo
22
23 #include "userdata.h"
24
25 #ifdef WITH_DBUS
26 #include <dbus/dbus.h>
27 typedef dbus_bool_t    am_bool_t;
28 typedef dbus_int16_t   am_int16_t;
29 typedef dbus_uint16_t  am_uint16_t;
30 typedef dbus_int32_t   am_int32_t;
31 typedef dbus_uint32_t  am_uint32_t;
32 #else
33 #include <stdbool.h>
34 typedef bool           am_bool_t;
35 typedef int16_t        am_int16_t;
36 typedef uint16_t       am_uint16_t;
37 typedef int32_t        am_int32_t;
38 typedef uint32_t       am_uint32_t;
39 #endif
40
41
42 /* error codes */
43 #define E_OK              0
44 #define E_UNKNOWN         1
45 #define E_OUT_OF_RANGE    2
46 #define E_NOT_USED        3
47 #define E_DATABSE_ERROR   4
48 #define E_ALREADY_EXISTS  5
49 #define E_NO_CHANGE       6
50 #define E_NOT_POSSIBLE    7
51 #define E_NON_EXISTENT    8
52 #define E_ABORTED         9
53 #define E_WRONG_FORMAT    10
54
55
56
57 struct am_domainreg_data {
58     am_uint16_t  domain_id;
59     const char    *name;      /**< domain name in audio manager  */
60     const char    *bus_name;  /**< audio manager's internal bus name
61                                    (not to confuse this with D-Bus name)  */
62     const char    *node_name; /**< node name on audio manager's internal bus*/
63     am_bool_t    early;
64     am_bool_t    complete;
65     am_uint16_t  state;
66 };
67
68 struct am_nodereg_data {
69     const char    *key;        /* for node lookup's */
70     am_uint16_t  id;
71     const char    *name;
72     am_uint16_t  domain;
73     am_uint16_t  class;
74     am_int32_t   state;      /* 1=on, 2=off */
75     am_int16_t   volume;
76     am_bool_t    visible;
77     struct {
78         am_int16_t  status; /* 1=available, 2=unavailable */
79         am_int16_t  reason; /* 1=newmedia, 2=same media, 3=nomedia */
80     } avail;
81     am_uint16_t  mute;
82     am_uint16_t  mainvol;
83     am_uint16_t  interrupt;  /* 1=off, 2=interrupted */
84 };
85
86 struct am_nodeunreg_data {
87     am_uint16_t  id;
88     const char    *name;
89 };
90
91
92 struct am_connect_data {
93     am_uint16_t  handle;
94     am_uint16_t  connection;
95     am_uint16_t  source;
96     am_uint16_t  sink;
97     am_int32_t   format;
98 };
99
100 struct am_ack_data {
101     am_uint32_t  handle;
102     am_uint16_t  param1;
103     am_uint16_t  param2;
104     am_uint16_t  error;
105 };
106
107
108
109 pa_audiomgr *pa_audiomgr_init(struct userdata *);
110 void pa_audiomgr_done(struct userdata *);
111
112 void pa_audiomgr_register_domain(struct userdata *);
113 void pa_audiomgr_domain_registered(struct userdata *,  uint16_t, uint16_t,
114                                    am_domainreg_data *);
115
116 void pa_audiomgr_unregister_domain(struct userdata *, bool);
117
118
119 void pa_audiomgr_register_node(struct userdata *, mir_node *);
120 void pa_audiomgr_node_registered(struct userdata *, uint16_t, uint16_t,
121                                  am_nodereg_data *);
122
123 void pa_audiomgr_unregister_node(struct userdata *, mir_node *);
124 void pa_audiomgr_node_unregistered(struct userdata *, am_nodeunreg_data *);
125
126 void pa_audiomgr_delete_default_routes(struct userdata *);
127 void pa_audiomgr_add_default_route(struct userdata *, mir_node *, mir_node *);
128 void pa_audiomgr_send_default_routes(struct userdata *);
129
130 void pa_audiomgr_connect(struct userdata *, am_connect_data *);
131 void pa_audiomgr_disconnect(struct userdata *, am_connect_data *);
132
133
134 #endif
135
136 /*
137  * Local Variables:
138  * c-basic-offset: 4
139  * indent-tabs-mode: nil
140  * End:
141  *
142  */