mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	loop: spa_loop_invoke -> spa_loop_locked where possible
When we simply need to change some state for the code executed in the loop, we can use locked() instead of invoke(). This is more efficient and avoids some context switches in the normal case.
This commit is contained in:
		
							parent
							
								
									b943c31fd8
								
							
						
					
					
						commit
						c45d667934
					
				
					 29 changed files with 75 additions and 75 deletions
				
			
		| 
						 | 
				
			
			@ -285,7 +285,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
 | 
			
		|||
	if (this->started && following != this->following) {
 | 
			
		||||
		spa_log_debug(this->log, "%p: reassign follower %d->%d", this, this->following, following);
 | 
			
		||||
		this->following = following;
 | 
			
		||||
		spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this);
 | 
			
		||||
		spa_loop_locked(this->data_loop, do_reassign_follower, 0, NULL, 0, this);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -764,7 +764,7 @@ static int transport_start(struct impl *this)
 | 
			
		|||
	/* Start socket i/o */
 | 
			
		||||
	if ((res = spa_bt_transport_ensure_sco_io(this->transport, this->data_loop, this->data_system)) < 0)
 | 
			
		||||
		goto fail;
 | 
			
		||||
	spa_loop_invoke(this->data_loop, do_add_source, 0, NULL, 0, true, this);
 | 
			
		||||
	spa_loop_locked(this->data_loop, do_add_source, 0, NULL, 0, this);
 | 
			
		||||
 | 
			
		||||
	/* Set the started flag */
 | 
			
		||||
	this->transport_started = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -862,7 +862,7 @@ static void transport_stop(struct impl *this)
 | 
			
		|||
 | 
			
		||||
	spa_log_debug(this->log, "sco-source %p: transport stop", this);
 | 
			
		||||
 | 
			
		||||
	spa_loop_invoke(this->data_loop, do_remove_transport_source, 0, NULL, 0, true, this);
 | 
			
		||||
	spa_loop_locked(this->data_loop, do_remove_transport_source, 0, NULL, 0, this);
 | 
			
		||||
 | 
			
		||||
	spa_bt_decode_buffer_clear(&port->buffer);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -882,7 +882,7 @@ static int do_stop(struct impl *this)
 | 
			
		|||
 | 
			
		||||
	this->start_ready = false;
 | 
			
		||||
 | 
			
		||||
	spa_loop_invoke(this->data_loop, do_remove_source, 0, NULL, 0, true, this);
 | 
			
		||||
	spa_loop_locked(this->data_loop, do_remove_source, 0, NULL, 0, this);
 | 
			
		||||
 | 
			
		||||
	transport_stop(this);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1589,7 +1589,7 @@ static void transport_destroy(void *data)
 | 
			
		|||
{
 | 
			
		||||
	struct impl *this = data;
 | 
			
		||||
	spa_log_debug(this->log, "transport %p destroy", this->transport);
 | 
			
		||||
	spa_loop_invoke(this->data_loop, do_transport_destroy, 0, NULL, 0, true, this);
 | 
			
		||||
	spa_loop_locked(this->data_loop, do_transport_destroy, 0, NULL, 0, this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const struct spa_bt_transport_events transport_events = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue