mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	loop: improve invoke avail check
First calculate the size of the aligned payload and then check if we can fit this aligned payload in the remaining space in the ringbuffer. Otherwise we might be able to fit the item + payload in the remaining space but then place the alignment bytes at the begginning, which would break alignment of the next invoke_item struct.
This commit is contained in:
		
							parent
							
								
									7f4fa64291
								
							
						
					
					
						commit
						a91502b3e0
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -192,13 +192,13 @@ loop_invoke(void *object,
 | 
			
		|||
	item->size = size;
 | 
			
		||||
	item->block = block && !in_thread;
 | 
			
		||||
	item->user_data = user_data;
 | 
			
		||||
	item->item_size = SPA_ROUND_UP_N(sizeof(struct invoke_item) + size, 8);
 | 
			
		||||
 | 
			
		||||
	spa_log_trace(impl->log, NAME " %p: add item %p filled:%d", impl, item, filled);
 | 
			
		||||
 | 
			
		||||
	if (l0 > sizeof(struct invoke_item) + size) {
 | 
			
		||||
	if (l0 >= item->item_size) {
 | 
			
		||||
		/* item + size fit in current ringbuffer idx */
 | 
			
		||||
		item->data = SPA_PTROFF(item, sizeof(struct invoke_item), void);
 | 
			
		||||
		item->item_size = SPA_ROUND_UP_N(sizeof(struct invoke_item) + size, 8);
 | 
			
		||||
		if (l0 < sizeof(struct invoke_item) + item->item_size) {
 | 
			
		||||
			/* not enough space for next invoke_item, fill up till the end
 | 
			
		||||
			 * so that the next item will be at the start */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue