mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	a2dp: fix audio
Don't just remove the buffer from the queue when it was only partially written. To do this, return the error code from add_buffer and only remove the buffer when there is a real error.
This commit is contained in:
		
							parent
							
								
									f026e95585
								
							
						
					
					
						commit
						5f70a2713e
					
				
					 1 changed files with 16 additions and 14 deletions
				
			
		| 
						 | 
					@ -473,10 +473,8 @@ static int add_data(struct impl *this, const void *data, int size)
 | 
				
			||||||
	while (size > 0) {
 | 
						while (size > 0) {
 | 
				
			||||||
		processed = encode_buffer(this, data, size);
 | 
							processed = encode_buffer(this, data, size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (processed == -ENOSPC || processed == 0)
 | 
							if (processed <= 0)
 | 
				
			||||||
			break;
 | 
								return total > 0 ? total : processed;
 | 
				
			||||||
		if (processed < 0)
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		data = SPA_MEMBER(data, processed, void);
 | 
							data = SPA_MEMBER(data, processed, void);
 | 
				
			||||||
		size -= processed;
 | 
							size -= processed;
 | 
				
			||||||
| 
						 | 
					@ -557,21 +555,25 @@ static int flush_data(struct impl *this, uint64_t now_time)
 | 
				
			||||||
		l0 = SPA_MIN(n_bytes, d[0].maxsize - offs);
 | 
							l0 = SPA_MIN(n_bytes, d[0].maxsize - offs);
 | 
				
			||||||
		l1 = n_bytes - l0;
 | 
							l1 = n_bytes - l0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		n_bytes = add_data(this, src + offs, l0);
 | 
							written = add_data(this, src + offs, l0);
 | 
				
			||||||
		if (n_bytes > 0 && l1 > 0)
 | 
							if (written > 0 && l1 > 0)
 | 
				
			||||||
			n_bytes += add_data(this, src, l1);
 | 
								written += add_data(this, src, l1);
 | 
				
			||||||
		if (n_bytes <= 0) {
 | 
							if (written <= 0) {
 | 
				
			||||||
			port->need_data = true;
 | 
								port->need_data = true;
 | 
				
			||||||
 | 
								if (written < 0 && written != -ENOSPC) {
 | 
				
			||||||
				spa_list_remove(&b->link);
 | 
									spa_list_remove(&b->link);
 | 
				
			||||||
				b->outstanding = true;
 | 
									b->outstanding = true;
 | 
				
			||||||
 | 
									spa_log_trace(this->log, NAME " %p: error %s, reuse buffer %u",
 | 
				
			||||||
 | 
											this, spa_strerror(written), b->id);
 | 
				
			||||||
				spa_node_call_reuse_buffer(&this->callbacks, 0, b->id);
 | 
									spa_node_call_reuse_buffer(&this->callbacks, 0, b->id);
 | 
				
			||||||
				port->ready_offset = 0;
 | 
									port->ready_offset = 0;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		n_frames = n_bytes / port->frame_size;
 | 
							n_frames = written / port->frame_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		port->ready_offset += n_bytes;
 | 
							port->ready_offset += written;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (port->ready_offset >= d[0].chunk->size) {
 | 
							if (port->ready_offset >= d[0].chunk->size) {
 | 
				
			||||||
			spa_list_remove(&b->link);
 | 
								spa_list_remove(&b->link);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue