node: add NODE_SUSPEND_ON_IDLE option

Makes the node suspend as soon as it goes to IDLE.
This commit is contained in:
Wim Taymans 2022-01-18 20:35:00 +01:00
parent 709d25f0c4
commit 6515553b7d
3 changed files with 18 additions and 9 deletions

View file

@ -185,6 +185,7 @@ context.objects = [
#latency.internal.rate = 0
#latency.internal.ns = 0
#clock.name = api.alsa.0
node.suspend-on-idle = true
#audio.format = "S32"
#audio.rate = 48000
#audio.allowed-rates = [ ]
@ -234,6 +235,7 @@ context.objects = [
#latency.internal.rate = 0
#latency.internal.ns = 0
#clock.name = api.alsa.0
node.suspend-on-idle = true
#audio.format = "S32"
#audio.rate = 48000
#audio.allowed-rates = [ ]

View file

@ -59,6 +59,7 @@ struct impl {
struct spa_list pending_list;
unsigned int pause_on_idle:1;
unsigned int suspend_on_idle:1;
unsigned int cache_params:1;
unsigned int pending_play:1;
};
@ -387,6 +388,10 @@ static void node_update_state(struct pw_impl_node *node, enum pw_node_state stat
spa_list_for_each(resource, &node->global->resource_list, link)
pw_resource_error(resource, res, error);
}
if (old == PW_NODE_STATE_RUNNING &&
state == PW_NODE_STATE_IDLE &&
impl->suspend_on_idle)
pw_impl_node_set_state(node, PW_NODE_STATE_SUSPENDED);
}
static int suspend_node(struct pw_impl_node *this)
@ -867,6 +872,7 @@ static void check_properties(struct pw_impl_node *node)
}
impl->pause_on_idle = pw_properties_get_bool(node->properties, PW_KEY_NODE_PAUSE_ON_IDLE, true);
impl->suspend_on_idle = pw_properties_get_bool(node->properties, PW_KEY_NODE_SUSPEND_ON_IDLE, false);
impl->cache_params = pw_properties_get_bool(node->properties, PW_KEY_NODE_CACHE_PARAMS, true);
node->transport_sync = pw_properties_get_bool(node->properties, PW_KEY_NODE_TRANSPORT_SYNC, false);
driver = pw_properties_get_bool(node->properties, PW_KEY_NODE_DRIVER, false);

View file

@ -171,6 +171,7 @@ extern "C" {
#define PW_KEY_NODE_WANT_DRIVER "node.want-driver" /**< the node wants to be grouped with a driver
* node in order to schedule the graph. */
#define PW_KEY_NODE_PAUSE_ON_IDLE "node.pause-on-idle" /**< pause the node when idle */
#define PW_KEY_NODE_SUSPEND_ON_IDLE "node.suspend-on-idle" /**< suspend the node when idle */
#define PW_KEY_NODE_CACHE_PARAMS "node.cache-params" /**< cache the node params */
#define PW_KEY_NODE_TRANSPORT_SYNC "node.transport.sync" /**< the node handles transport sync */
#define PW_KEY_NODE_DRIVER "node.driver" /**< node can drive the graph */