mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse: fix drain
The drain operation does not complete with a sync from the server but with an event from the stream. Set a flag in the operation that it completes with a sync. Keep all operations without a sync around in the list.
This commit is contained in:
		
							parent
							
								
									a9c0435317
								
							
						
					
					
						commit
						688041b083
					
				
					 4 changed files with 12 additions and 1 deletions
				
			
		| 
						 | 
					@ -1473,13 +1473,20 @@ static void core_done(void *data, uint32_t id, int seq)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	spa_list_for_each_safe(o, t, &ops, link) {
 | 
						spa_list_for_each_safe(o, t, &ops, link) {
 | 
				
			||||||
 | 
							if (!o->sync)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
		pa_operation_ref(o);
 | 
							pa_operation_ref(o);
 | 
				
			||||||
		pw_log_debug("operation %p complete", o);
 | 
							pw_log_debug("sync operation %p complete", o);
 | 
				
			||||||
		if (o->callback)
 | 
							if (o->callback)
 | 
				
			||||||
			o->callback(o, o->userdata);
 | 
								o->callback(o, o->userdata);
 | 
				
			||||||
		pa_operation_unref(o);
 | 
							pa_operation_unref(o);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	spa_list_consume(o, &ops, link) {
 | 
						spa_list_consume(o, &ops, link) {
 | 
				
			||||||
 | 
							if (!o->sync) {
 | 
				
			||||||
 | 
								spa_list_remove(&o->link);
 | 
				
			||||||
 | 
								spa_list_append(&c->operations, &o->link);
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		pw_log_warn("operation %p canceled", o);
 | 
							pw_log_warn("operation %p canceled", o);
 | 
				
			||||||
		pa_operation_cancel(o);
 | 
							pa_operation_cancel(o);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -491,6 +491,7 @@ struct pa_operation
 | 
				
			||||||
	int refcount;
 | 
						int refcount;
 | 
				
			||||||
	pa_context *context;
 | 
						pa_context *context;
 | 
				
			||||||
	pa_stream *stream;
 | 
						pa_stream *stream;
 | 
				
			||||||
 | 
						unsigned int sync:1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pa_operation_state_t state;
 | 
						pa_operation_state_t state;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,6 +52,7 @@ int pa_operation_sync(pa_operation *o)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	pa_context *c = o->context;
 | 
						pa_context *c = o->context;
 | 
				
			||||||
	c->pending_seq = pw_core_sync(c->core, PW_ID_CORE, 0);
 | 
						c->pending_seq = pw_core_sync(c->core, PW_ID_CORE, 0);
 | 
				
			||||||
 | 
						o->sync = true;
 | 
				
			||||||
	pw_log_debug("operation %p: sync seq:%d", o, c->pending_seq);
 | 
						pw_log_debug("operation %p: sync seq:%d", o, c->pending_seq);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -461,6 +461,8 @@ static void stream_drained(void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	pa_stream *s = data;
 | 
						pa_stream *s = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_log_debug("drained");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (s->drain) {
 | 
						if (s->drain) {
 | 
				
			||||||
		pa_operation *o = s->drain;
 | 
							pa_operation *o = s->drain;
 | 
				
			||||||
		pa_operation_ref(o);
 | 
							pa_operation_ref(o);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue