mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	impl-node: restore running state after reconfigure
Add a reconfigure state on the node that is set when the node was IDLE or RUNNING when reconfigured. The node state will be set to the running state as long as the reconfigure state is active. When the node is running, the reconfigure state is unset again and the node is allowed to IDLE as usual. This fixes the case where an IDLE (but not paused node) will be suspended when a rate change happens but will then not resume afterwards. This causes problems with rate changes and nodes that have the suspend disabled by the session manager. They will be suspened anyway and this can cause problems for devices that need to keep running to keep the amplifiers active. Fixes #2929
This commit is contained in:
		
							parent
							
								
									07633f2146
								
							
						
					
					
						commit
						ba374a7b47
					
				
					 3 changed files with 16 additions and 1 deletions
				
			
		| 
						 | 
					@ -946,6 +946,9 @@ static void reconfigure_driver(struct pw_context *context, struct pw_impl_node *
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pw_log_debug("%p: driver %p: '%s' suspend",
 | 
						pw_log_debug("%p: driver %p: '%s' suspend",
 | 
				
			||||||
			context, n, n->name);
 | 
								context, n, n->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (n->info.state >= PW_NODE_STATE_IDLE)
 | 
				
			||||||
 | 
							n->reconfigure = true;
 | 
				
			||||||
	pw_impl_node_set_state(n, PW_NODE_STATE_SUSPENDED);
 | 
						pw_impl_node_set_state(n, PW_NODE_STATE_SUSPENDED);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1180,8 +1183,11 @@ again:
 | 
				
			||||||
		if (force_rate)
 | 
							if (force_rate)
 | 
				
			||||||
			lock_rate = false;
 | 
								lock_rate = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (n->reconfigure)
 | 
				
			||||||
 | 
								running = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		current_rate = n->current_rate.denom;
 | 
							current_rate = n->current_rate.denom;
 | 
				
			||||||
		if (lock_rate ||
 | 
							if (lock_rate || n->reconfigure ||
 | 
				
			||||||
		    (!force_rate &&
 | 
							    (!force_rate &&
 | 
				
			||||||
		    (n->info.state > PW_NODE_STATE_IDLE)))
 | 
							    (n->info.state > PW_NODE_STATE_IDLE)))
 | 
				
			||||||
			/* when someone wants us to lock the rate of this driver or
 | 
								/* when someone wants us to lock the rate of this driver or
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -418,6 +418,14 @@ 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)
 | 
							spa_list_for_each(resource, &node->global->resource_list, link)
 | 
				
			||||||
			pw_resource_error(resource, res, error);
 | 
								pw_resource_error(resource, res, error);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (node->reconfigure) {
 | 
				
			||||||
 | 
							if (state == PW_NODE_STATE_SUSPENDED &&
 | 
				
			||||||
 | 
							    node->pause_on_idle) {
 | 
				
			||||||
 | 
								node->reconfigure = false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (state == PW_NODE_STATE_RUNNING)
 | 
				
			||||||
 | 
								node->reconfigure = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (old == PW_NODE_STATE_RUNNING &&
 | 
						if (old == PW_NODE_STATE_RUNNING &&
 | 
				
			||||||
	    state == PW_NODE_STATE_IDLE &&
 | 
						    state == PW_NODE_STATE_IDLE &&
 | 
				
			||||||
	    node->suspend_on_idle) {
 | 
						    node->suspend_on_idle) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -721,6 +721,7 @@ struct pw_impl_node {
 | 
				
			||||||
	unsigned int added:1;		/**< the node was add to graph */
 | 
						unsigned int added:1;		/**< the node was add to graph */
 | 
				
			||||||
	unsigned int pause_on_idle:1;	/**< Pause processing when IDLE */
 | 
						unsigned int pause_on_idle:1;	/**< Pause processing when IDLE */
 | 
				
			||||||
	unsigned int suspend_on_idle:1;
 | 
						unsigned int suspend_on_idle:1;
 | 
				
			||||||
 | 
						unsigned int reconfigure:1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32_t port_user_data_size;	/**< extra size for port user data */
 | 
						uint32_t port_user_data_size;	/**< extra size for port user data */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue