mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse: improve operation handling
First move all completed operations to a new list, then complete the operations and cancel the ones that are not completed correctly. This ensures that new operations from the callbacks don't get completed immediately as well.
This commit is contained in:
		
							parent
							
								
									af64666716
								
							
						
					
					
						commit
						8638fd0411
					
				
					 1 changed files with 12 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1432,23 +1432,34 @@ static void core_done(void *data, uint32_t id, int seq)
 | 
			
		|||
	pa_context *c = data;
 | 
			
		||||
	pa_operation *o, *t;
 | 
			
		||||
	struct global *g;
 | 
			
		||||
	struct spa_list ops;
 | 
			
		||||
 | 
			
		||||
	pw_log_debug("done id:%u seq:%d/%d", id, seq, c->pending_seq);
 | 
			
		||||
	if (c->pending_seq != seq)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	spa_list_init(&ops);
 | 
			
		||||
	spa_list_consume(o, &c->operations, link) {
 | 
			
		||||
		spa_list_remove(&o->link);
 | 
			
		||||
		spa_list_append(&ops, &o->link);
 | 
			
		||||
	}
 | 
			
		||||
	spa_list_for_each(g, &c->globals, link) {
 | 
			
		||||
		if (g->sync) {
 | 
			
		||||
			do_global_sync(g);
 | 
			
		||||
			g->sync = false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	spa_list_for_each_safe(o, t, &c->operations, link) {
 | 
			
		||||
	spa_list_for_each_safe(o, t, &ops, link) {
 | 
			
		||||
		pa_operation_ref(o);
 | 
			
		||||
		pw_log_debug("operation %p complete", o);
 | 
			
		||||
		if (o->callback)
 | 
			
		||||
			o->callback(o, o->userdata);
 | 
			
		||||
		pa_operation_unref(o);
 | 
			
		||||
	}
 | 
			
		||||
	spa_list_consume(o, &ops, link) {
 | 
			
		||||
		pw_log_warn("operation %p canceled", o);
 | 
			
		||||
		pa_operation_cancel(o);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const struct pw_core_events core_events = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue