Add systemd socket activation files

Notify of jack graph changes
This commit is contained in:
Wim Taymans 2017-08-17 18:59:03 +02:00
parent 61424a4343
commit 29eb58f7a2
13 changed files with 83 additions and 20 deletions

View file

@ -996,8 +996,12 @@ static void jack_node_pull(void *data)
struct jack_graph_manager *mgr = server->graph_manager;
struct spa_graph_node *n = &jc->node->node->rt.node, *pn;
struct spa_graph_port *p, *pp;
bool res;
jack_graph_manager_try_switch(mgr);
jack_graph_manager_try_switch(mgr, &res);
if (res) {
notify_clients(impl, jack_notify_GraphOrderCallback, false, "", 0, 0);
}
spa_list_for_each(p, &n->ports[SPA_DIRECTION_INPUT], link) {
if ((pp = p->peer) == NULL || ((pn = pp->node) == NULL))
@ -1108,7 +1112,6 @@ make_audio_client(struct impl *impl)
server->audio_ref_num = ref_num;
server->audio_node = node;
server->audio_node_node = node->node;
pw_log_debug("module-jack %p: Added audio driver %d", impl, ref_num);
@ -1171,7 +1174,7 @@ static bool on_global(void *data, struct pw_global *global)
if (strcmp(str, "Audio/Sink") != 0)
return true;
out_port = pw_node_get_free_port(impl->server.audio_node_node, PW_DIRECTION_OUTPUT);
out_port = pw_node_get_free_port(impl->server.audio_node->node, PW_DIRECTION_OUTPUT);
in_port = pw_node_get_free_port(node, PW_DIRECTION_INPUT);
if (out_port == NULL || in_port == NULL)
return true;
@ -1191,23 +1194,10 @@ static bool on_global(void *data, struct pw_global *global)
static bool init_nodes(struct impl *impl)
{
struct pw_core *core = impl->core;
#if 0
struct timespec timeout, interval;
#endif
make_audio_client(impl);
make_freewheel_client(impl);
#if 0
timeout.tv_sec = 0;
timeout.tv_nsec = 1;
interval.tv_sec = 0;
interval.tv_nsec = 10 * SPA_NSEC_PER_MSEC;
impl->timer = pw_loop_add_timer(pw_core_get_main_loop(impl->core), on_timeout, impl);
pw_loop_update_timer(pw_core_get_main_loop(impl->core), impl->timer, &timeout, &interval, false);
#endif
pw_core_for_each_global(core, on_global, impl);
return true;

View file

@ -647,8 +647,16 @@ static void node_free(void *data)
spa_hook_list_call(&nd->listener_list, struct pw_jack_node_events, free);
}
static void node_state_changed(void *data, enum pw_node_state old,
enum pw_node_state state, const char *error)
{
struct node_data *nd = data;
spa_hook_list_call(&nd->listener_list, struct pw_jack_node_events, state_changed, old, state, error);
}
static const struct pw_node_events node_events = {
PW_VERSION_NODE_EVENTS,
.state_changed = node_state_changed,
.destroy = node_destroy,
.free = node_free,
};
@ -759,6 +767,7 @@ pw_jack_driver_new(struct pw_core *core,
spa_hook_list_init(&nd->listener_list);
init_type(&nd->type, pw_core_get_type(core)->map);
pw_node_add_listener(node, &nd->node_listener, &node_events, nd);
pw_node_set_implementation(node, &driver_impl, nd);
this = &nd->node;

View file

@ -50,8 +50,13 @@ struct pw_jack_node_events {
uint32_t version;
void (*destroy) (void *data);
void (*free) (void *data);
/** the state of the node changed */
void (*state_changed) (void *data, enum pw_node_state old,
enum pw_node_state state, const char *error);
void (*pull) (void *data);
void (*push) (void *data);

View file

@ -44,7 +44,6 @@ struct jack_server {
int freewheel_ref_num;
struct pw_jack_node *audio_node;
struct pw_node *audio_node_node;
int audio_used;
};

View file

@ -849,13 +849,14 @@ jack_graph_manager_get_current(struct jack_graph_manager *manager)
}
static inline struct jack_connection_manager *
jack_graph_manager_try_switch(struct jack_graph_manager *manager)
jack_graph_manager_try_switch(struct jack_graph_manager *manager, bool *res)
{
struct jack_atomic_counter old_val;
struct jack_atomic_counter new_val;
do {
old_val = manager->state.counter;
new_val = old_val;
*res = CurIndex(new_val) != NextIndex(new_val);
CurIndex(new_val) = NextIndex(new_val);
}
while (!__atomic_compare_exchange_n((uint32_t*)&manager->state.counter,