mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pipewire/stream: Don't queue back cleared buffers
When renegotiating stream parameters (e.g. size), the buffers are cleared should no longer be queued back. Add a flag to detect this, while logging a warning and erroring out when the user tries to queue such a buffer.
This commit is contained in:
		
							parent
							
								
									124aa40f64
								
							
						
					
					
						commit
						4ec9994bf0
					
				
					 1 changed files with 12 additions and 1 deletions
				
			
		| 
						 | 
					@ -39,7 +39,8 @@ struct buffer {
 | 
				
			||||||
	uint32_t id;
 | 
						uint32_t id;
 | 
				
			||||||
#define BUFFER_FLAG_MAPPED	(1 << 0)
 | 
					#define BUFFER_FLAG_MAPPED	(1 << 0)
 | 
				
			||||||
#define BUFFER_FLAG_QUEUED	(1 << 1)
 | 
					#define BUFFER_FLAG_QUEUED	(1 << 1)
 | 
				
			||||||
#define BUFFER_FLAG_ADDED	(1 << 2)
 | 
					#define BUFFER_FLAG_DEQUEUED	(1 << 2)
 | 
				
			||||||
 | 
					#define BUFFER_FLAG_ADDED	(1 << 3)
 | 
				
			||||||
	uint32_t flags;
 | 
						uint32_t flags;
 | 
				
			||||||
	struct spa_meta_busy *busy;
 | 
						struct spa_meta_busy *busy;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -2478,6 +2479,9 @@ struct pw_buffer *pw_stream_dequeue_buffer(struct pw_stream *stream)
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SPA_FLAG_SET(b->flags, BUFFER_FLAG_DEQUEUED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &b->this;
 | 
						return &b->this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2488,6 +2492,13 @@ int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer)
 | 
				
			||||||
	struct buffer *b = SPA_CONTAINER_OF(buffer, struct buffer, this);
 | 
						struct buffer *b = SPA_CONTAINER_OF(buffer, struct buffer, this);
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_DEQUEUED)) {
 | 
				
			||||||
 | 
							pw_log_warn("%p: tried to queue cleared buffer %d", stream, b->id);
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SPA_FLAG_CLEAR(b->flags, BUFFER_FLAG_DEQUEUED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (b->busy)
 | 
						if (b->busy)
 | 
				
			||||||
		SPA_ATOMIC_DEC(b->busy->count);
 | 
							SPA_ATOMIC_DEC(b->busy->count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue