diff --git a/src/daemon/minimal.conf.in b/src/daemon/minimal.conf.in index 370888033..78f857a57 100644 --- a/src/daemon/minimal.conf.in +++ b/src/daemon/minimal.conf.in @@ -185,20 +185,21 @@ 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 = [ ] + #audio.allowed-rates = [ ] #audio.channels = 4 #audio.position = [ FL FR RL RR ] #resample.quality = 4 resample.disable = true - #monitor.channel-volumes = false + #monitor.channel-volumes = false #channelmix.normalize = true #channelmix.mix-lfe = false #channelmix.upmix = false #channelmix.lfe-cutoff = 0 #node.param.Props = { - # params = [ + # params = [ # audio.channels 6 # ] #} @@ -229,14 +230,15 @@ context.objects = [ #api.alsa.start-delay = 0 #api.alsa.disable-mmap = false #api.alsa.disable-batch = false - #api.alsa.use-chmap = false - #api.alsa.multirate = true - #latency.internal.rate = 0 - #latency.internal.ns = 0 - #clock.name = api.alsa.0 + #api.alsa.use-chmap = false + #api.alsa.multirate = true + #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 = [ ] + #audio.allowed-rates = [ ] #audio.channels = 2 #audio.position = "FL,FR" #resample.quality = 4 diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index c4fca8a12..54d346465 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -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); diff --git a/src/pipewire/keys.h b/src/pipewire/keys.h index 3ec3c04fb..58253dc06 100644 --- a/src/pipewire/keys.h +++ b/src/pipewire/keys.h @@ -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 */