1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains declaration of internal stuff used by
9 * studio object implementation
10 **************************************************************************
12 * LADI Session Handler is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * LADI Session Handler is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
24 * or write to the Free Software Foundation, Inc.,
25 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28 #ifndef STUDIO_INTERNAL_H__B4CB73EC_8E89_401A_9E49_F0AEEF361D09__INCLUDED
29 #define STUDIO_INTERNAL_H__B4CB73EC_8E89_401A_9E49_F0AEEF361D09__INCLUDED
31 #include "../../proxies/jack_proxy.h"
32 #include "../dbus/error.h"
33 #include "virtualizer.h"
34 #include "app_supervisor.h"
38 #define JACK_CONF_MAX_ADDRESS_SIZE 1024
40 typedef int ladish_environment_id
;
46 } ladish_environment_store
;
48 #define ladish_environment_jack_server_present ((ladish_environment_id)0)
49 #define ladish_environment_jack_server_started ((ladish_environment_id)1)
51 static inline void ladish_environment_init(ladish_environment_store
* store_ptr
)
54 store_ptr
->changed
= 0;
57 static inline uint64_t ladish_environment_state(ladish_environment_id id
)
59 ASSERT(sizeof(id
) < 8);
60 return (uint64_t)1 << id
;
63 static inline void ladish_environment_set(ladish_environment_store
* store_ptr
, ladish_environment_id id
)
65 uint64_t state
= ladish_environment_state(id
);
66 store_ptr
->state
|= state
;
67 store_ptr
->changed
|= state
;
70 static inline void ladish_environment_set_stealth(ladish_environment_store
* store_ptr
, ladish_environment_id id
)
72 uint64_t state
= ladish_environment_state(id
);
73 store_ptr
->state
|= state
;
76 static inline void ladish_environment_reset(ladish_environment_store
* store_ptr
, ladish_environment_id id
)
78 uint64_t state
= ladish_environment_state(id
);
79 store_ptr
->state
&= ~state
;
80 store_ptr
->changed
|= state
;
83 static inline void ladish_environment_reset_stealth(ladish_environment_store
* store_ptr
, ladish_environment_id id
)
85 uint64_t state
= ladish_environment_state(id
);
86 store_ptr
->state
&= ~state
;
89 static inline bool ladish_environment_get(ladish_environment_store
* store_ptr
, ladish_environment_id id
)
91 uint64_t state
= ladish_environment_state(id
);
93 return (store_ptr
->state
& state
) == state
;
96 static inline bool ladish_environment_consume_change(ladish_environment_store
* store_ptr
, ladish_environment_id id
, bool * new_state
)
98 uint64_t state
= ladish_environment_state(id
);
100 if ((store_ptr
->changed
& state
) == 0)
105 *new_state
= (store_ptr
->state
& state
) == state
;
106 store_ptr
->changed
&= ~state
;
110 static inline void ladish_environment_ignore(ladish_environment_store
* store_ptr
, ladish_environment_id id
)
112 uint64_t state
= ladish_environment_state(id
);
114 if ((store_ptr
->changed
& state
) != 0)
116 store_ptr
->changed
&= ~state
;
120 #define ladish_environment_assert_consumed(store_ptr) ASSERT((store_ptr)->changed == 0)
124 struct list_head all_connections
; /* All connections (studio guts and all rooms). Including superconnections. */
125 struct list_head all_ports
; /* All ports (studio guts and all rooms) */
126 struct list_head all_clients
; /* All clients (studio guts and all rooms) */
127 struct list_head jack_connections
; /* JACK connections (studio guts and all rooms). Including superconnections, excluding virtual connections. */
128 struct list_head jack_ports
; /* JACK ports (studio guts and all rooms). Excluding virtual ports. */
129 struct list_head jack_clients
; /* JACK clients (studio guts and all rooms). Excluding virtual clients. */
130 struct list_head rooms
; /* Rooms connected to the studio */
131 struct list_head clients
; /* studio clients (studio guts and room links) */
132 struct list_head ports
; /* studio ports (studio guts and room links) */
134 bool automatic
:1; /* Studio was automatically created because of external JACK start */
135 bool persisted
:1; /* Studio has on-disk representation, i.e. can be reloaded from disk */
136 bool modified
:1; /* Studio needs saving */
137 bool jack_conf_valid
:1; /* JACK server configuration obtained successfully */
139 struct list_head jack_conf
; /* root of the conf tree */
140 struct list_head jack_params
; /* list of conf tree leaves */
142 dbus_object_path dbus_object
;
145 struct ladish_cqueue cmd_queue
;
146 ladish_environment_store env_store
;
151 graph_proxy_handle jack_graph_proxy
;
152 ladish_graph_handle jack_graph
;
153 ladish_graph_handle studio_graph
;
154 ladish_virtualizer_handle virtualizer
;
155 ladish_app_supervisor_handle app_supervisor
;
157 unsigned int room_count
;
160 struct jack_conf_parameter
162 struct list_head siblings
; /* siblings in container children list */
163 struct list_head leaves
; /* studio::jack_param siblings */
165 struct jack_conf_container
* parent_ptr
;
166 char address
[JACK_CONF_MAX_ADDRESS_SIZE
];
167 struct jack_parameter_variant parameter
;
170 struct jack_conf_container
172 struct list_head siblings
;
174 struct jack_conf_container
* parent_ptr
;
175 bool children_leafs
; /* if true, children are "jack_conf_parameter"s, if false, children are "jack_conf_container"s */
176 struct list_head children
;
179 struct conf_callback_context
181 char address
[JACK_CONF_MAX_ADDRESS_SIZE
];
182 struct list_head
* container_ptr
;
183 struct jack_conf_container
* parent_ptr
;
186 extern struct studio g_studio
;
188 extern const struct dbus_interface_descriptor g_interface_studio
;
190 void ladish_studio_jack_conf_clear(void);
191 bool ladish_studio_fetch_jack_settings(void);
192 bool ladish_studio_compose_filename(const char * name
, char ** filename_ptr_ptr
, char ** backup_filename_ptr_ptr
);
193 bool ladish_studio_show(void);
194 void ladish_studio_announce(void);
195 bool ladish_studio_publish(void);
196 void ladish_studio_clear(void);
197 bool ladish_studio_name_generate(char ** name_ptr
);
198 void ladish_studio_emit_started(void);
199 void ladish_studio_emit_stopped(void);
200 void ladish_studio_emit_renamed(void);
201 void ladish_studio_on_event_jack_started(void);
202 void ladish_studio_on_event_jack_stopped(void);
203 void ladish_studio_remove_all_rooms(void);
205 #endif /* #ifndef STUDIO_INTERNAL_H__B4CB73EC_8E89_401A_9E49_F0AEEF361D09__INCLUDED */