mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	link: first set all buffers, then complete the state
This commit is contained in:
		
							parent
							
								
									45c00ebb54
								
							
						
					
					
						commit
						6c643a0ad0
					
				
					 1 changed files with 20 additions and 26 deletions
				
			
		| 
						 | 
					@ -550,7 +550,7 @@ static int select_io(struct pw_link *this)
 | 
				
			||||||
static int do_allocation(struct pw_link *this)
 | 
					static int do_allocation(struct pw_link *this)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
 | 
						struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
 | 
				
			||||||
	int res;
 | 
						int res, out_res = 0, in_res = 0;
 | 
				
			||||||
	uint32_t in_flags, out_flags;
 | 
						uint32_t in_flags, out_flags;
 | 
				
			||||||
	char *error = NULL;
 | 
						char *error = NULL;
 | 
				
			||||||
	struct pw_port *input, *output;
 | 
						struct pw_port *input, *output;
 | 
				
			||||||
| 
						 | 
					@ -674,14 +674,7 @@ static int do_allocation(struct pw_link *this)
 | 
				
			||||||
				asprintf(&error, "error alloc output buffers: %d", res);
 | 
									asprintf(&error, "error alloc output buffers: %d", res);
 | 
				
			||||||
				goto error;
 | 
									goto error;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (SPA_RESULT_IS_ASYNC(res)) {
 | 
								out_res = res;
 | 
				
			||||||
				res = spa_node_sync(output->node->node, res),
 | 
					 | 
				
			||||||
				pw_work_queue_add(impl->work, output->node, res,
 | 
					 | 
				
			||||||
						complete_paused, this);
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				complete_paused(output->node, this, res, 0);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			out_flags &= ~SPA_PORT_FLAG_CAN_USE_BUFFERS;
 | 
								out_flags &= ~SPA_PORT_FLAG_CAN_USE_BUFFERS;
 | 
				
			||||||
			move_allocation(&allocation, &output->allocation);
 | 
								move_allocation(&allocation, &output->allocation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -689,7 +682,6 @@ static int do_allocation(struct pw_link *this)
 | 
				
			||||||
				     allocation.n_buffers, allocation.buffers);
 | 
									     allocation.n_buffers, allocation.buffers);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (out_flags & SPA_PORT_FLAG_CAN_USE_BUFFERS) {
 | 
						if (out_flags & SPA_PORT_FLAG_CAN_USE_BUFFERS) {
 | 
				
			||||||
		pw_log_debug("link %p: using %d buffers %p on output port", this,
 | 
							pw_log_debug("link %p: using %d buffers %p on output port", this,
 | 
				
			||||||
			     allocation.n_buffers, allocation.buffers);
 | 
								     allocation.n_buffers, allocation.buffers);
 | 
				
			||||||
| 
						 | 
					@ -701,13 +693,7 @@ static int do_allocation(struct pw_link *this)
 | 
				
			||||||
					spa_strerror(res));
 | 
										spa_strerror(res));
 | 
				
			||||||
			goto error;
 | 
								goto error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (SPA_RESULT_IS_ASYNC(res)) {
 | 
							out_res = res;
 | 
				
			||||||
			res = spa_node_sync(output->node->node, res),
 | 
					 | 
				
			||||||
			pw_work_queue_add(impl->work, output->node, res,
 | 
					 | 
				
			||||||
					complete_paused, this);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			complete_paused(output->node, this, res, 0);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		move_allocation(&allocation, &output->allocation);
 | 
							move_allocation(&allocation, &output->allocation);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (in_flags & SPA_PORT_FLAG_CAN_USE_BUFFERS) {
 | 
						if (in_flags & SPA_PORT_FLAG_CAN_USE_BUFFERS) {
 | 
				
			||||||
| 
						 | 
					@ -721,20 +707,28 @@ static int do_allocation(struct pw_link *this)
 | 
				
			||||||
					spa_strerror(res));
 | 
										spa_strerror(res));
 | 
				
			||||||
			goto error;
 | 
								goto error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (SPA_RESULT_IS_ASYNC(res)) {
 | 
							in_res = res;
 | 
				
			||||||
			res = spa_node_sync(input->node->node, res),
 | 
					 | 
				
			||||||
			pw_work_queue_add(impl->work, input->node, res,
 | 
					 | 
				
			||||||
					complete_paused, this);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			complete_paused(input->node, this, res, 0);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		asprintf(&error, "no common buffer alloc found");
 | 
							asprintf(&error, "no common buffer alloc found");
 | 
				
			||||||
 | 
							res = -EIO;
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return res;
 | 
						if (SPA_RESULT_IS_ASYNC(out_res)) {
 | 
				
			||||||
 | 
							pw_work_queue_add(impl->work, output->node,
 | 
				
			||||||
 | 
									spa_node_sync(output->node->node, out_res),
 | 
				
			||||||
 | 
									complete_paused, this);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							complete_paused(output->node, this, out_res, 0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (SPA_RESULT_IS_ASYNC(in_res)) {
 | 
				
			||||||
 | 
							pw_work_queue_add(impl->work, input->node,
 | 
				
			||||||
 | 
									spa_node_sync(input->node->node, in_res),
 | 
				
			||||||
 | 
									complete_paused, this);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							complete_paused(input->node, this, in_res, 0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      error:
 | 
					      error:
 | 
				
			||||||
	free_allocation(&output->allocation);
 | 
						free_allocation(&output->allocation);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue