mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
filter-graph: handle NULL data
Because the max plugin is marked as SUPPORTS_NULL, the input and output pointers can be NULL. Handle these cases. Also reindent with tabs (not 7 spaces).
This commit is contained in:
parent
7f80711158
commit
6e2f631230
1 changed files with 30 additions and 19 deletions
|
|
@ -2084,31 +2084,42 @@ static const struct spa_fga_descriptor param_eq_desc = {
|
||||||
/** max */
|
/** max */
|
||||||
static void max_run(void * Instance, unsigned long SampleCount)
|
static void max_run(void * Instance, unsigned long SampleCount)
|
||||||
{
|
{
|
||||||
struct builtin *impl = Instance;
|
struct builtin *impl = Instance;
|
||||||
float *out = impl->port[0], *in1 = impl->port[1], *in2 = impl->port[2];
|
float *out = impl->port[0], *in1 = impl->port[1], *in2 = impl->port[2];
|
||||||
|
unsigned long n;
|
||||||
|
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned long n;
|
if (in1 != NULL && in2 != NULL) {
|
||||||
for (n = 0; n < SampleCount; n++)
|
for (n = 0; n < SampleCount; n++) {
|
||||||
out[n] = SPA_MAX(in1[n], in2[n]);
|
out[n] = fmaxf(in1[n], in2[n]);
|
||||||
|
} else if (in1 != NULL) {
|
||||||
|
for (n = 0; n < SampleCount; n++) {
|
||||||
|
out[n] = in1[n];
|
||||||
|
} else if (in2 != NULL) {
|
||||||
|
for (n = 0; n < SampleCount; n++) {
|
||||||
|
out[n] = in2[n];
|
||||||
|
} else {
|
||||||
|
for (n = 0; n < SampleCount; n++) {
|
||||||
|
out[n] = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct spa_fga_port max_ports[] = {
|
static struct spa_fga_port max_ports[] = {
|
||||||
{ .index = 0,
|
{ .index = 0,
|
||||||
.name = "Out",
|
.name = "Out",
|
||||||
.flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
|
.flags = SPA_FGA_PORT_OUTPUT | SPA_FGA_PORT_AUDIO,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ .index = 1,
|
{ .index = 1,
|
||||||
.name = "In 1",
|
.name = "In 1",
|
||||||
.flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
|
.flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
|
||||||
},
|
},
|
||||||
{ .index = 2,
|
{ .index = 2,
|
||||||
.name = "In 2",
|
.name = "In 2",
|
||||||
.flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
|
.flags = SPA_FGA_PORT_INPUT | SPA_FGA_PORT_AUDIO,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct spa_fga_descriptor max_desc = {
|
static const struct spa_fga_descriptor max_desc = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue