mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-25 01:40:36 -05:00
filter-graph: handle NULL in and out
We need to pass exactly n_inputs and n_outputs pointers to the process function but make it possible to set some to NULL so that the data is ignored.
This commit is contained in:
parent
49f48a5fda
commit
3cf9ccf4a7
2 changed files with 14 additions and 2 deletions
|
|
@ -246,17 +246,20 @@ static int impl_process(void *object,
|
||||||
for (i = 0, j = 0; i < impl->info.n_inputs; i++) {
|
for (i = 0, j = 0; i < impl->info.n_inputs; i++) {
|
||||||
while (j < graph->n_input) {
|
while (j < graph->n_input) {
|
||||||
port = &graph->input[j++];
|
port = &graph->input[j++];
|
||||||
if (port->desc)
|
if (port->desc && in[i])
|
||||||
port->desc->connect_port(*port->hndl, port->port, (float*)in[i]);
|
port->desc->connect_port(*port->hndl, port->port, (float*)in[i]);
|
||||||
if (!port->next)
|
if (!port->next)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < impl->info.n_outputs; i++) {
|
for (i = 0; i < impl->info.n_outputs; i++) {
|
||||||
|
if (out[i] == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
port = i < graph->n_output ? &graph->output[i] : NULL;
|
port = i < graph->n_output ? &graph->output[i] : NULL;
|
||||||
|
|
||||||
if (port && port->desc)
|
if (port && port->desc)
|
||||||
port->desc->connect_port(*port->hndl, port->port, (float*)out[i]);
|
port->desc->connect_port(*port->hndl, port->port, out[i]);
|
||||||
else
|
else
|
||||||
memset(out[i], 0, n_samples * sizeof(float));
|
memset(out[i], 0, n_samples * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -842,6 +842,8 @@ struct impl {
|
||||||
struct spa_handle *handle;
|
struct spa_handle *handle;
|
||||||
struct spa_filter_graph *graph;
|
struct spa_filter_graph *graph;
|
||||||
struct spa_hook graph_listener;
|
struct spa_hook graph_listener;
|
||||||
|
uint32_t n_inputs;
|
||||||
|
uint32_t n_outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void capture_destroy(void *d)
|
static void capture_destroy(void *d)
|
||||||
|
|
@ -907,6 +909,8 @@ static void playback_process(void *d)
|
||||||
data_size = i == 0 ? size : SPA_MIN(data_size, size);
|
data_size = i == 0 ? size : SPA_MIN(data_size, size);
|
||||||
stride = SPA_MAX(stride, bd->chunk->stride);
|
stride = SPA_MAX(stride, bd->chunk->stride);
|
||||||
}
|
}
|
||||||
|
for (; i < impl->n_inputs; i++)
|
||||||
|
cin[i] = NULL;
|
||||||
|
|
||||||
for (i = 0; i < out->buffer->n_datas; i++) {
|
for (i = 0; i < out->buffer->n_datas; i++) {
|
||||||
bd = &out->buffer->datas[i];
|
bd = &out->buffer->datas[i];
|
||||||
|
|
@ -919,6 +923,8 @@ static void playback_process(void *d)
|
||||||
bd->chunk->size = data_size;
|
bd->chunk->size = data_size;
|
||||||
bd->chunk->stride = stride;
|
bd->chunk->stride = stride;
|
||||||
}
|
}
|
||||||
|
for (; i < impl->n_outputs; i++)
|
||||||
|
cout[i] = NULL;
|
||||||
|
|
||||||
pw_log_trace_fp("%p: stride:%d size:%d requested:%"PRIu64" (%"PRIu64")", impl,
|
pw_log_trace_fp("%p: stride:%d size:%d requested:%"PRIu64" (%"PRIu64")", impl,
|
||||||
stride, data_size, out->requested, out->requested * stride);
|
stride, data_size, out->requested, out->requested * stride);
|
||||||
|
|
@ -1224,6 +1230,9 @@ static void graph_info(void *object, const struct spa_filter_graph_info *info)
|
||||||
if (impl->playback_info.channels == 0)
|
if (impl->playback_info.channels == 0)
|
||||||
impl->playback_info.channels = info->n_outputs;
|
impl->playback_info.channels = info->n_outputs;
|
||||||
|
|
||||||
|
impl->n_inputs = info->n_inputs;
|
||||||
|
impl->n_outputs = info->n_outputs;
|
||||||
|
|
||||||
if (impl->capture_info.channels == impl->playback_info.channels) {
|
if (impl->capture_info.channels == impl->playback_info.channels) {
|
||||||
copy_position(&impl->capture_info, &impl->playback_info);
|
copy_position(&impl->capture_info, &impl->playback_info);
|
||||||
copy_position(&impl->playback_info, &impl->capture_info);
|
copy_position(&impl->playback_info, &impl->capture_info);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue