mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	context: don't reconfigure when already pending
When we already have a pending rate/quantum change, don't reconfigure the driver. This avoids going into an endless loop when: 1- paplay plays with 44100Hz on device1 2- jack_simple_client starts and attaches to device1 3- jack_simple_client links to device2 4- jack_simple_client is moved from device1 to device2, rate from device1 is moved to device2 (44100Hz) 5- device2 becomes schedulable and sees the rate should be 48000Hz (the default) it does a rate switch to 48KHz 6- jack_simple_client is suspended, links are back to init 7- jack_simple_client is moved back to device1 8- jack_simple_client links are activated and cycle restarts at 4 The cycle is broken because at 6 we avoid doing the suspend.
This commit is contained in:
		
							parent
							
								
									07e6f44e58
								
							
						
					
					
						commit
						8ddb6d711f
					
				
					 2 changed files with 16 additions and 9 deletions
				
			
		| 
						 | 
					@ -1307,18 +1307,18 @@ again:
 | 
				
			||||||
		if (target_rate != current_rate) {
 | 
							if (target_rate != current_rate) {
 | 
				
			||||||
			bool do_reconfigure = false;
 | 
								bool do_reconfigure = false;
 | 
				
			||||||
			/* we doing a rate switch */
 | 
								/* we doing a rate switch */
 | 
				
			||||||
			pw_log_info("(%s-%u) state:%s new rate:%u->%u",
 | 
								pw_log_info("(%s-%u) state:%s new rate:%u/(%u)->%u",
 | 
				
			||||||
					n->name, n->info.id,
 | 
										n->name, n->info.id,
 | 
				
			||||||
					pw_node_state_as_string(n->info.state),
 | 
										pw_node_state_as_string(n->info.state),
 | 
				
			||||||
					n->current_rate.denom,
 | 
										n->current_rate.denom, current_rate,
 | 
				
			||||||
					target_rate);
 | 
										target_rate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (force_rate) {
 | 
								if (force_rate) {
 | 
				
			||||||
				if (settings->clock_rate_update_mode == CLOCK_RATE_UPDATE_MODE_HARD)
 | 
									if (settings->clock_rate_update_mode == CLOCK_RATE_UPDATE_MODE_HARD)
 | 
				
			||||||
					do_reconfigure = true;
 | 
										do_reconfigure = !n->current_pending;
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				if (n->info.state >= PW_NODE_STATE_SUSPENDED)
 | 
									if (n->info.state >= PW_NODE_STATE_SUSPENDED)
 | 
				
			||||||
					do_reconfigure = true;
 | 
										do_reconfigure = !n->current_pending;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (do_reconfigure)
 | 
								if (do_reconfigure)
 | 
				
			||||||
				reconfigure_driver(context, n);
 | 
									reconfigure_driver(context, n);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -841,14 +841,16 @@ int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driv
 | 
				
			||||||
	remove_segment_owner(old, node->info.id);
 | 
						remove_segment_owner(old, node->info.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (old != node && old->driving && driver->info.state < PW_NODE_STATE_RUNNING) {
 | 
						if (old != node && old->driving && driver->info.state < PW_NODE_STATE_RUNNING) {
 | 
				
			||||||
 | 
							pw_log_info("move quantum:%"PRIu64"->%"PRIu64" rate:%d->%d (%s-%d -> %s-%d)",
 | 
				
			||||||
 | 
									driver->current_quantum,
 | 
				
			||||||
 | 
									old->current_quantum,
 | 
				
			||||||
 | 
									driver->current_rate.denom,
 | 
				
			||||||
 | 
									old->current_rate.denom,
 | 
				
			||||||
 | 
									old->name, old->info.id,
 | 
				
			||||||
 | 
									driver->name, driver->info.id);
 | 
				
			||||||
		driver->current_rate = old->current_rate;
 | 
							driver->current_rate = old->current_rate;
 | 
				
			||||||
		driver->current_quantum = old->current_quantum;
 | 
							driver->current_quantum = old->current_quantum;
 | 
				
			||||||
		driver->current_pending = true;
 | 
							driver->current_pending = true;
 | 
				
			||||||
		pw_log_info("move quantum:%"PRIu64" rate:%d (%s-%d -> %s-%d)",
 | 
					 | 
				
			||||||
				driver->current_quantum,
 | 
					 | 
				
			||||||
				driver->current_rate.denom,
 | 
					 | 
				
			||||||
				old->name, old->info.id,
 | 
					 | 
				
			||||||
				driver->name, driver->info.id);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	was_driving = node->driving;
 | 
						was_driving = node->driving;
 | 
				
			||||||
	node->driving = node->driver && driver == node;
 | 
						node->driving = node->driver && driver == node;
 | 
				
			||||||
| 
						 | 
					@ -1682,6 +1684,11 @@ static int node_ready(void *data, int status)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (node->current_pending) {
 | 
							if (node->current_pending) {
 | 
				
			||||||
 | 
								pw_log_debug("apply quantum %"PRIu64"->%"PRIu64" %d->%d",
 | 
				
			||||||
 | 
										node->rt.position->clock.duration,
 | 
				
			||||||
 | 
										node->current_quantum,
 | 
				
			||||||
 | 
										node->rt.position->clock.rate.denom,
 | 
				
			||||||
 | 
										node->current_rate.denom);
 | 
				
			||||||
			node->rt.position->clock.duration = node->current_quantum;
 | 
								node->rt.position->clock.duration = node->current_quantum;
 | 
				
			||||||
			node->rt.position->clock.rate = node->current_rate;
 | 
								node->rt.position->clock.rate = node->current_rate;
 | 
				
			||||||
			node->current_pending = false;
 | 
								node->current_pending = false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue