mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
link: avoid getting params
We don't need to iterate the port params again when we already can reuse buffers from the ports.
This commit is contained in:
parent
cc53023fb9
commit
96fdfc86f7
1 changed files with 33 additions and 37 deletions
|
|
@ -552,14 +552,31 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
||||||
spa_debug_port_info(oinfo);
|
spa_debug_port_info(oinfo);
|
||||||
spa_debug_port_info(iinfo);
|
spa_debug_port_info(iinfo);
|
||||||
}
|
}
|
||||||
|
if (this->buffers == NULL && output->n_buffers) {
|
||||||
if (this->buffers == NULL) {
|
out_flags = 0;
|
||||||
|
in_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||||
|
this->n_buffers = output->n_buffers;
|
||||||
|
this->buffers = output->buffers;
|
||||||
|
this->buffer_owner = output;
|
||||||
|
pw_log_debug("link %p: reusing %d output buffers %p", this, this->n_buffers,
|
||||||
|
this->buffers);
|
||||||
|
} else if (this->buffers == NULL && input->n_buffers && input->mix == NULL) {
|
||||||
|
out_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||||
|
in_flags = 0;
|
||||||
|
this->n_buffers = input->n_buffers;
|
||||||
|
this->buffers = input->buffers;
|
||||||
|
this->buffer_owner = input;
|
||||||
|
pw_log_debug("link %p: reusing %d input buffers %p", this, this->n_buffers,
|
||||||
|
this->buffers);
|
||||||
|
} else if (this->buffers == NULL) {
|
||||||
struct spa_pod **params, *param;
|
struct spa_pod **params, *param;
|
||||||
uint8_t buffer[4096];
|
uint8_t buffer[4096];
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
int i, offset, n_params;
|
int i, offset, n_params;
|
||||||
uint32_t max_buffers;
|
uint32_t max_buffers;
|
||||||
size_t minsize = 1024, stride = 0;
|
size_t minsize = 1024, stride = 0;
|
||||||
|
size_t data_sizes[1];
|
||||||
|
ssize_t data_strides[1];
|
||||||
|
|
||||||
n_params = param_filter(this, input, output, t->param.idBuffers, &b);
|
n_params = param_filter(this, input, output, t->param.idBuffers, &b);
|
||||||
n_params += param_filter(this, input, output, t->param.idMeta, &b);
|
n_params += param_filter(this, input, output, t->param.idMeta, &b);
|
||||||
|
|
@ -588,7 +605,7 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
||||||
|
|
||||||
max_buffers =
|
max_buffers =
|
||||||
qmax_buffers == 0 ? max_buffers : SPA_MIN(qmax_buffers,
|
qmax_buffers == 0 ? max_buffers : SPA_MIN(qmax_buffers,
|
||||||
max_buffers);
|
max_buffers);
|
||||||
minsize = SPA_MAX(minsize, qminsize);
|
minsize = SPA_MAX(minsize, qminsize);
|
||||||
stride = SPA_MAX(stride, qstride);
|
stride = SPA_MAX(stride, qstride);
|
||||||
|
|
||||||
|
|
@ -605,42 +622,21 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
||||||
(out_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS))
|
(out_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS))
|
||||||
minsize = 0;
|
minsize = 0;
|
||||||
|
|
||||||
if (output->n_buffers) {
|
data_sizes[0] = minsize;
|
||||||
out_flags = 0;
|
data_strides[0] = stride;
|
||||||
in_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
|
||||||
this->n_buffers = output->n_buffers;
|
|
||||||
this->buffers = output->buffers;
|
|
||||||
this->buffer_owner = output;
|
|
||||||
pw_log_debug("link %p: reusing %d output buffers %p", this, this->n_buffers,
|
|
||||||
this->buffers);
|
|
||||||
} else if (input->n_buffers && input->mix == NULL) {
|
|
||||||
out_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
|
||||||
in_flags = 0;
|
|
||||||
this->n_buffers = input->n_buffers;
|
|
||||||
this->buffers = input->buffers;
|
|
||||||
this->buffer_owner = input;
|
|
||||||
pw_log_debug("link %p: reusing %d input buffers %p", this, this->n_buffers,
|
|
||||||
this->buffers);
|
|
||||||
} else {
|
|
||||||
size_t data_sizes[1];
|
|
||||||
ssize_t data_strides[1];
|
|
||||||
|
|
||||||
data_sizes[0] = minsize;
|
this->buffer_owner = this;
|
||||||
data_strides[0] = stride;
|
this->n_buffers = max_buffers;
|
||||||
|
this->buffers = alloc_buffers(this,
|
||||||
|
this->n_buffers,
|
||||||
|
n_params,
|
||||||
|
params,
|
||||||
|
1,
|
||||||
|
data_sizes, data_strides,
|
||||||
|
&this->buffer_mem);
|
||||||
|
|
||||||
this->buffer_owner = this;
|
pw_log_debug("link %p: allocating %d buffers %p %zd %zd", this,
|
||||||
this->n_buffers = max_buffers;
|
this->n_buffers, this->buffers, minsize, stride);
|
||||||
this->buffers = alloc_buffers(this,
|
|
||||||
this->n_buffers,
|
|
||||||
n_params,
|
|
||||||
params,
|
|
||||||
1,
|
|
||||||
data_sizes, data_strides,
|
|
||||||
&this->buffer_mem);
|
|
||||||
|
|
||||||
pw_log_debug("link %p: allocating %d buffers %p %zd %zd", this,
|
|
||||||
this->n_buffers, this->buffers, minsize, stride);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
|
if (out_flags & SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS) {
|
||||||
if ((res = pw_port_alloc_buffers(output,
|
if ((res = pw_port_alloc_buffers(output,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue