mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	alsa: check the offset against the size of the buffer
We need to check the last offset against the size of the buffer, not the remaining size in the buffer. When the writing is split, this could cause the buffer to be reused wrongly. See #2536
This commit is contained in:
		
							parent
							
								
									11bc60a53d
								
							
						
					
					
						commit
						52281b9a7e
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -1971,13 +1971,14 @@ again:
 | 
			
		|||
		size_t n_bytes, n_frames;
 | 
			
		||||
		struct buffer *b;
 | 
			
		||||
		struct spa_data *d;
 | 
			
		||||
		uint32_t i, offs, size;
 | 
			
		||||
		uint32_t i, offs, size, last_offset;
 | 
			
		||||
 | 
			
		||||
		b = spa_list_first(&state->ready, struct buffer, link);
 | 
			
		||||
		d = b->buf->datas;
 | 
			
		||||
 | 
			
		||||
		offs = d[0].chunk->offset + state->ready_offset;
 | 
			
		||||
		size = d[0].chunk->size - state->ready_offset;
 | 
			
		||||
		last_offset = d[0].chunk->size;
 | 
			
		||||
		size = last_offset - state->ready_offset;
 | 
			
		||||
 | 
			
		||||
		offs = SPA_MIN(offs, d[0].maxsize);
 | 
			
		||||
		size = SPA_MIN(d[0].maxsize - offs, size);
 | 
			
		||||
| 
						 | 
				
			
			@ -2003,7 +2004,7 @@ again:
 | 
			
		|||
 | 
			
		||||
		state->ready_offset += n_bytes;
 | 
			
		||||
 | 
			
		||||
		if (state->ready_offset >= size) {
 | 
			
		||||
		if (state->ready_offset >= last_offset) {
 | 
			
		||||
			spa_list_remove(&b->link);
 | 
			
		||||
			SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
 | 
			
		||||
			state->io->buffer_id = b->id;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue