mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
small cleanups
This commit is contained in:
parent
28ae844de9
commit
6953642ed5
12 changed files with 32 additions and 24 deletions
|
|
@ -545,7 +545,7 @@ static int impl_node_process_input(struct spa_node *node)
|
||||||
input = this->io;
|
input = this->io;
|
||||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_WRONG_STATE);
|
spa_return_val_if_fail(input != NULL, SPA_RESULT_WRONG_STATE);
|
||||||
|
|
||||||
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id != SPA_ID_INVALID) {
|
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||||
struct buffer *b = &this->buffers[input->buffer_id];
|
struct buffer *b = &this->buffers[input->buffer_id];
|
||||||
|
|
||||||
if (!b->outstanding) {
|
if (!b->outstanding) {
|
||||||
|
|
|
||||||
|
|
@ -573,7 +573,7 @@ static int impl_node_process_output(struct spa_node *node)
|
||||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||||
return SPA_RESULT_HAVE_BUFFER;
|
return SPA_RESULT_HAVE_BUFFER;
|
||||||
|
|
||||||
if (io->buffer_id != SPA_ID_INVALID) {
|
if (io->buffer_id < this->n_buffers) {
|
||||||
recycle_buffer(this, io->buffer_id);
|
recycle_buffer(this, io->buffer_id);
|
||||||
io->buffer_id = SPA_ID_INVALID;
|
io->buffer_id = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -732,11 +732,11 @@ static int impl_node_process_input(struct spa_node *node)
|
||||||
struct port *inport = GET_IN_PORT(this, i);
|
struct port *inport = GET_IN_PORT(this, i);
|
||||||
struct spa_port_io *inio;
|
struct spa_port_io *inio;
|
||||||
|
|
||||||
if ((inio = inport->io) == NULL || inport->n_buffers == 0)
|
if ((inio = inport->io) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (inport->queued_bytes == 0 &&
|
if (inport->queued_bytes == 0 &&
|
||||||
inio->status == SPA_RESULT_HAVE_BUFFER && inio->buffer_id != SPA_ID_INVALID) {
|
inio->status == SPA_RESULT_HAVE_BUFFER && inio->buffer_id < inport->n_buffers) {
|
||||||
struct buffer *b = &inport->buffers[inio->buffer_id];
|
struct buffer *b = &inport->buffers[inio->buffer_id];
|
||||||
|
|
||||||
if (!b->outstanding) {
|
if (!b->outstanding) {
|
||||||
|
|
@ -788,7 +788,7 @@ static int impl_node_process_output(struct spa_node *node)
|
||||||
return SPA_RESULT_HAVE_BUFFER;
|
return SPA_RESULT_HAVE_BUFFER;
|
||||||
|
|
||||||
/* recycle */
|
/* recycle */
|
||||||
if (outio->buffer_id != SPA_ID_INVALID) {
|
if (outio->buffer_id < outport->n_buffers) {
|
||||||
recycle_buffer(this, outio->buffer_id);
|
recycle_buffer(this, outio->buffer_id);
|
||||||
outio->buffer_id = SPA_ID_INVALID;
|
outio->buffer_id = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -862,7 +862,7 @@ static int impl_node_process_output(struct spa_node *node)
|
||||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||||
return SPA_RESULT_HAVE_BUFFER;
|
return SPA_RESULT_HAVE_BUFFER;
|
||||||
|
|
||||||
if (io->buffer_id != SPA_ID_INVALID) {
|
if (io->buffer_id < this->n_buffers) {
|
||||||
reuse_buffer(this, this->io->buffer_id);
|
reuse_buffer(this, this->io->buffer_id);
|
||||||
this->io->buffer_id = SPA_ID_INVALID;
|
this->io->buffer_id = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -656,7 +656,7 @@ static int impl_node_process_input(struct spa_node *node)
|
||||||
input = this->io;
|
input = this->io;
|
||||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_WRONG_STATE);
|
spa_return_val_if_fail(input != NULL, SPA_RESULT_WRONG_STATE);
|
||||||
|
|
||||||
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id != SPA_ID_INVALID) {
|
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||||
struct buffer *b = &this->buffers[input->buffer_id];
|
struct buffer *b = &this->buffers[input->buffer_id];
|
||||||
|
|
||||||
if (!b->outstanding) {
|
if (!b->outstanding) {
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@ static int impl_node_process_output(struct spa_node *node)
|
||||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||||
return SPA_RESULT_HAVE_BUFFER;
|
return SPA_RESULT_HAVE_BUFFER;
|
||||||
|
|
||||||
if (io->buffer_id != SPA_ID_INVALID) {
|
if (io->buffer_id < this->n_buffers) {
|
||||||
reuse_buffer(this, this->io->buffer_id);
|
reuse_buffer(this, this->io->buffer_id);
|
||||||
this->io->buffer_id = SPA_ID_INVALID;
|
this->io->buffer_id = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -816,7 +816,7 @@ static int impl_node_process_output(struct spa_node *node)
|
||||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||||
return SPA_RESULT_HAVE_BUFFER;
|
return SPA_RESULT_HAVE_BUFFER;
|
||||||
|
|
||||||
if (io->buffer_id != SPA_ID_INVALID) {
|
if (io->buffer_id < this->out_ports[0].n_buffers) {
|
||||||
res = spa_v4l2_buffer_recycle(this, io->buffer_id);
|
res = spa_v4l2_buffer_recycle(this, io->buffer_id);
|
||||||
io->buffer_id = SPA_ID_INVALID;
|
io->buffer_id = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -806,7 +806,7 @@ static int impl_node_process_output(struct spa_node *node)
|
||||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||||
return SPA_RESULT_HAVE_BUFFER;
|
return SPA_RESULT_HAVE_BUFFER;
|
||||||
|
|
||||||
if (io->buffer_id != SPA_ID_INVALID) {
|
if (io->buffer_id < this->n_buffers) {
|
||||||
reuse_buffer(this, this->io->buffer_id);
|
reuse_buffer(this, this->io->buffer_id);
|
||||||
this->io->buffer_id = SPA_ID_INVALID;
|
this->io->buffer_id = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -750,7 +750,7 @@ static int impl_node_process_output(struct spa_node *node)
|
||||||
return SPA_RESULT_HAVE_BUFFER;
|
return SPA_RESULT_HAVE_BUFFER;
|
||||||
|
|
||||||
/* recycle */
|
/* recycle */
|
||||||
if (output->buffer_id != SPA_ID_INVALID) {
|
if (output->buffer_id < out_port->n_buffers) {
|
||||||
recycle_buffer(this, output->buffer_id);
|
recycle_buffer(this, output->buffer_id);
|
||||||
output->buffer_id = SPA_ID_INVALID;
|
output->buffer_id = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1000,6 +1000,16 @@ jack_engine_control_reset_rolling_usecs(struct jack_engine_control *ctrl)
|
||||||
ctrl->rolling_interval = floor((JACK_ENGINE_ROLLING_INTERVAL * 1000.f) / ctrl->period_usecs);
|
ctrl->rolling_interval = floor((JACK_ENGINE_ROLLING_INTERVAL * 1000.f) / ctrl->period_usecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint64_t calc_computation(jack_nframes_t buffer_size)
|
||||||
|
{
|
||||||
|
if (buffer_size < 128)
|
||||||
|
return 500;
|
||||||
|
else if (buffer_size < 256)
|
||||||
|
return 300;
|
||||||
|
else
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct jack_engine_control *
|
static inline struct jack_engine_control *
|
||||||
jack_engine_control_alloc(const char* name)
|
jack_engine_control_alloc(const char* name)
|
||||||
{
|
{
|
||||||
|
|
@ -1040,9 +1050,8 @@ jack_engine_control_alloc(const char* name)
|
||||||
jack_engine_control_reset_rolling_usecs(ctrl);
|
jack_engine_control_reset_rolling_usecs(ctrl);
|
||||||
ctrl->CPU_load = 0.f;
|
ctrl->CPU_load = 0.f;
|
||||||
|
|
||||||
ctrl->period = 0;
|
ctrl->period = ctrl->constraint = ctrl->period_usecs * 1000;
|
||||||
ctrl->computation = 0;
|
ctrl->computation = calc_computation(ctrl->buffer_size) * 1000;
|
||||||
ctrl->constraint = 0;
|
|
||||||
|
|
||||||
return ctrl;
|
return ctrl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -657,7 +657,7 @@ struct spa_format *pw_core_find_format(struct pw_core *core,
|
||||||
} else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) {
|
} else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) {
|
||||||
again:
|
again:
|
||||||
/* both ports need a format */
|
/* both ports need a format */
|
||||||
pw_log_debug("core %p: finding best format", core);
|
pw_log_debug("core %p: do enum input %d", core, iidx);
|
||||||
if ((res = spa_node_port_enum_formats(input->node->node, input->direction, input->port_id,
|
if ((res = spa_node_port_enum_formats(input->node->node, input->direction, input->port_id,
|
||||||
&filter, NULL, iidx)) < 0) {
|
&filter, NULL, iidx)) < 0) {
|
||||||
if (res == SPA_RESULT_ENUM_END && iidx != 0) {
|
if (res == SPA_RESULT_ENUM_END && iidx != 0) {
|
||||||
|
|
@ -665,7 +665,7 @@ struct spa_format *pw_core_find_format(struct pw_core *core,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pw_log_debug("Try filter: %p", filter);
|
pw_log_debug("enum output %d with filter: %p", oidx, filter);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
spa_debug_format(filter);
|
spa_debug_format(filter);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1115,10 +1115,10 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
|
|
||||||
spa_list_insert(core->link_list.prev, &this->link);
|
spa_list_insert(core->link_list.prev, &this->link);
|
||||||
|
|
||||||
this->info.output_node_id = output ? output_node->global->id : -1;
|
this->info.output_node_id = output_node->global->id;
|
||||||
this->info.output_port_id = output ? output->port_id : -1;
|
this->info.output_port_id = output->port_id;
|
||||||
this->info.input_node_id = input ? input_node->global->id : -1;
|
this->info.input_node_id = input_node->global->id;
|
||||||
this->info.input_port_id = input ? input->port_id : -1;
|
this->info.input_port_id = input->port_id;
|
||||||
this->info.format = NULL;
|
this->info.format = NULL;
|
||||||
|
|
||||||
spa_graph_port_init(&this->rt.out_port,
|
spa_graph_port_init(&this->rt.out_port,
|
||||||
|
|
@ -1135,11 +1135,10 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
this->rt.in_port.callbacks_data = this;
|
this->rt.in_port.callbacks_data = this;
|
||||||
this->rt.out_port.callbacks_data = this;
|
this->rt.out_port.callbacks_data = this;
|
||||||
|
|
||||||
pw_loop_invoke(output_node->data_loop,
|
/* nodes can be in different data loops so we do this twice */
|
||||||
do_add_link,
|
pw_loop_invoke(output_node->data_loop, do_add_link,
|
||||||
SPA_ID_INVALID, sizeof(struct pw_port *), &output, false, this);
|
SPA_ID_INVALID, sizeof(struct pw_port *), &output, false, this);
|
||||||
pw_loop_invoke(input_node->data_loop,
|
pw_loop_invoke(input_node->data_loop, do_add_link,
|
||||||
do_add_link,
|
|
||||||
SPA_ID_INVALID, sizeof(struct pw_port *), &input, false, this);
|
SPA_ID_INVALID, sizeof(struct pw_port *), &input, false, this);
|
||||||
|
|
||||||
spa_hook_list_call(&output->listener_list, struct pw_port_events, link_added, this);
|
spa_hook_list_call(&output->listener_list, struct pw_port_events, link_added, this);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue