mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	bluez5: emit props change events only if values actually changed
This may avoid infinite loops if parameters are being set based on events sent by parameter changes. It's also what alsa-acp devices do, so bluez5 should follow.
This commit is contained in:
		
							parent
							
								
									302282ef59
								
							
						
					
					
						commit
						4389e44903
					
				
					 5 changed files with 138 additions and 71 deletions
				
			
		| 
						 | 
				
			
			@ -308,7 +308,27 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void emit_node_props_changed(struct impl *this);
 | 
			
		||||
static void emit_node_info(struct impl *this, bool full);
 | 
			
		||||
 | 
			
		||||
static int apply_props(struct impl *this, const struct spa_pod *param)
 | 
			
		||||
{
 | 
			
		||||
	struct props new_props = this->props;
 | 
			
		||||
	int changed = 0;
 | 
			
		||||
 | 
			
		||||
	if (param == NULL) {
 | 
			
		||||
		reset_props(&new_props);
 | 
			
		||||
	} else {
 | 
			
		||||
		spa_pod_parse_object(param,
 | 
			
		||||
				SPA_TYPE_OBJECT_Props, NULL,
 | 
			
		||||
				SPA_PROP_minLatency, SPA_POD_OPT_Int(&new_props.min_latency),
 | 
			
		||||
				SPA_PROP_maxLatency, SPA_POD_OPT_Int(&new_props.max_latency),
 | 
			
		||||
				SPA_PROP_latencyOffsetNsec, SPA_POD_OPT_Long(&new_props.latency_offset));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	changed = (memcmp(&new_props, &this->props, sizeof(struct props)) != 0);
 | 
			
		||||
	this->props = new_props;
 | 
			
		||||
	return changed;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
 | 
			
		||||
			       const struct spa_pod *param)
 | 
			
		||||
| 
						 | 
				
			
			@ -320,19 +340,11 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
 | 
			
		|||
	switch (id) {
 | 
			
		||||
	case SPA_PARAM_Props:
 | 
			
		||||
	{
 | 
			
		||||
		struct props *p = &this->props;
 | 
			
		||||
 | 
			
		||||
		if (param == NULL) {
 | 
			
		||||
			reset_props(p);
 | 
			
		||||
			emit_node_props_changed(this);
 | 
			
		||||
			return 0;
 | 
			
		||||
		if (apply_props(this, param) > 0) {
 | 
			
		||||
			this->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS;
 | 
			
		||||
			this->params[1].flags ^= SPA_PARAM_INFO_SERIAL;
 | 
			
		||||
			emit_node_info(this, false);
 | 
			
		||||
		}
 | 
			
		||||
		if (spa_pod_parse_object(param,
 | 
			
		||||
				SPA_TYPE_OBJECT_Props, NULL,
 | 
			
		||||
				SPA_PROP_minLatency, SPA_POD_OPT_Int(&p->min_latency),
 | 
			
		||||
				SPA_PROP_maxLatency, SPA_POD_OPT_Int(&p->max_latency),
 | 
			
		||||
				SPA_PROP_latencyOffsetNsec, SPA_POD_OPT_Long(&p->latency_offset)) > 0)
 | 
			
		||||
			emit_node_props_changed(this);
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	default:
 | 
			
		||||
| 
						 | 
				
			
			@ -869,13 +881,6 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void emit_node_props_changed(struct impl *this)
 | 
			
		||||
{
 | 
			
		||||
        this->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS;
 | 
			
		||||
        this->params[1].flags ^= SPA_PARAM_INFO_SERIAL;
 | 
			
		||||
        emit_node_info(this, false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
impl_node_add_listener(void *object,
 | 
			
		||||
		struct spa_hook *listener,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue