mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
node: add enabled state
Add method to enable/disable a node. Disabled nodes will SUSPEND and not be available for automatic connections, it is intented for handling the monitor node state.
This commit is contained in:
parent
95b3cba3c3
commit
bd1fea49c2
4 changed files with 43 additions and 3 deletions
|
|
@ -610,6 +610,9 @@ struct pw_port *pw_core_find_port(struct pw_core *core,
|
|||
!PW_PERM_IS_R(pw_global_get_permissions(n->global, core->current_client)))
|
||||
continue;
|
||||
|
||||
if (!n->enabled)
|
||||
continue;
|
||||
|
||||
pw_log_debug("node id \"%d\"", n->global->id);
|
||||
|
||||
if (have_id) {
|
||||
|
|
|
|||
|
|
@ -394,6 +394,7 @@ struct pw_node *pw_node_new(struct pw_core *core,
|
|||
if (properties == NULL)
|
||||
goto no_mem;
|
||||
|
||||
this->enabled = true;
|
||||
this->properties = properties;
|
||||
|
||||
impl->work = pw_work_queue_new(this->core->main_loop);
|
||||
|
|
@ -882,8 +883,10 @@ int pw_node_set_active(struct pw_node *node, bool active)
|
|||
pw_log_debug("node %p: %s", node, active ? "activate" : "deactivate");
|
||||
node->active = active;
|
||||
spa_hook_list_call(&node->listener_list, struct pw_node_events, active_changed, active);
|
||||
if (active)
|
||||
if (active) {
|
||||
if (node->enabled)
|
||||
node_activate(node);
|
||||
}
|
||||
else
|
||||
pw_node_set_state(node, PW_NODE_STATE_IDLE);
|
||||
}
|
||||
|
|
@ -894,3 +897,28 @@ bool pw_node_is_active(struct pw_node *node)
|
|||
{
|
||||
return node->active;
|
||||
}
|
||||
|
||||
int pw_node_set_enabled(struct pw_node *node, bool enabled)
|
||||
{
|
||||
bool old = node->enabled;
|
||||
|
||||
if (old != enabled) {
|
||||
pw_log_debug("node %p: %s", node, enabled ? "enable" : "disable");
|
||||
node->enabled = enabled;
|
||||
spa_hook_list_call(&node->listener_list, struct pw_node_events, enabled_changed, enabled);
|
||||
|
||||
if (enabled) {
|
||||
if (node->active)
|
||||
node_activate(node);
|
||||
}
|
||||
else {
|
||||
pw_node_set_state(node, PW_NODE_STATE_SUSPENDED);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pw_node_is_enabled(struct pw_node *node)
|
||||
{
|
||||
return node->enabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ struct pw_node_events {
|
|||
void (*info_changed) (void *data, struct pw_node_info *info);
|
||||
/** the node active state changed */
|
||||
void (*active_changed) (void *data, bool active);
|
||||
/** the node enabled state changed */
|
||||
void (*enabled_changed) (void *data, bool enabled);
|
||||
|
||||
/** a new state is requested on the node */
|
||||
void (*state_request) (void *data, enum pw_node_state state);
|
||||
|
|
@ -164,9 +166,15 @@ struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction d
|
|||
* nodes and start data transport */
|
||||
int pw_node_set_active(struct pw_node *node, bool active);
|
||||
|
||||
/** Check is a node is active */
|
||||
/** Check if a node is active */
|
||||
bool pw_node_is_active(struct pw_node *node);
|
||||
|
||||
/** Set a node enabled. The node will be able to be activated */
|
||||
int pw_node_set_enabled(struct pw_node *node, bool enabled);
|
||||
|
||||
/** Check if a node is enabled */
|
||||
bool pw_node_is_enabled(struct pw_node *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ struct pw_node {
|
|||
|
||||
struct pw_node_info info; /**< introspectable node info */
|
||||
|
||||
bool enabled; /**< if the node is enabled */
|
||||
bool active; /**< if the node is active */
|
||||
bool live; /**< if the node is live */
|
||||
struct spa_clock *clock; /**< handle to SPA clock if any */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue