mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-19 16:01:45 +00:00
audioconvert: only update the arrays when valid
Only update our internal channelmap/volumes array when we actually parsed something.
This commit is contained in:
parent
7b4b73ae5b
commit
385246f5a1
|
@ -524,6 +524,7 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
bool have_channel_volume = false;
|
bool have_channel_volume = false;
|
||||||
bool have_soft_volume = false;
|
bool have_soft_volume = false;
|
||||||
|
uint32_t n;
|
||||||
|
|
||||||
if (param == NULL)
|
if (param == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -541,16 +542,19 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_channelVolumes:
|
case SPA_PROP_channelVolumes:
|
||||||
if ((p->channel.n_volumes = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
||||||
p->channel.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
p->channel.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->channel.n_volumes = n;
|
||||||
changed++;
|
changed++;
|
||||||
have_channel_volume = true;
|
have_channel_volume = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_channelMap:
|
case SPA_PROP_channelMap:
|
||||||
if ((p->n_channels = spa_pod_copy_array(&prop->value, SPA_TYPE_Id,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Id,
|
||||||
p->channel_map, SPA_AUDIO_MAX_CHANNELS)) > 0)
|
p->channel_map, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->n_channels = n;
|
||||||
changed++;
|
changed++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_softMute:
|
case SPA_PROP_softMute:
|
||||||
if (spa_pod_get_bool(&prop->value, &p->soft.mute) == 0) {
|
if (spa_pod_get_bool(&prop->value, &p->soft.mute) == 0) {
|
||||||
|
@ -559,8 +563,9 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_softVolumes:
|
case SPA_PROP_softVolumes:
|
||||||
if ((p->soft.n_volumes = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
||||||
p->soft.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
p->soft.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->soft.n_volumes = n;
|
||||||
changed++;
|
changed++;
|
||||||
have_soft_volume = true;
|
have_soft_volume = true;
|
||||||
}
|
}
|
||||||
|
@ -570,9 +575,11 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
||||||
changed++;
|
changed++;
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_monitorVolumes:
|
case SPA_PROP_monitorVolumes:
|
||||||
if ((p->monitor.n_volumes = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
||||||
p->monitor.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0)
|
p->monitor.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->monitor.n_volumes = n;
|
||||||
changed++;
|
changed++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -430,12 +430,53 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int merger_set_param(struct impl *this, const char *k, const char *s)
|
||||||
|
{
|
||||||
|
if (spa_streq(k, "monitor.channel-volumes"))
|
||||||
|
this->monitor_channel_volumes = spa_atob(s);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_prop_params(struct impl *this, struct spa_pod *params)
|
||||||
|
{
|
||||||
|
struct spa_pod_parser prs;
|
||||||
|
struct spa_pod_frame f;
|
||||||
|
|
||||||
|
spa_pod_parser_pod(&prs, params);
|
||||||
|
if (spa_pod_parser_push_struct(&prs, &f) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const char *name;
|
||||||
|
struct spa_pod *pod;
|
||||||
|
char value[512];
|
||||||
|
|
||||||
|
if (spa_pod_parser_get_string(&prs, &name) < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (spa_pod_parser_get_pod(&prs, &pod) < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (spa_pod_is_bool(pod)) {
|
||||||
|
snprintf(value, sizeof(value), "%s",
|
||||||
|
SPA_POD_VALUE(struct spa_pod_bool, pod) ?
|
||||||
|
"true" : "false");
|
||||||
|
} else
|
||||||
|
continue;
|
||||||
|
|
||||||
|
spa_log_info(this->log, "key:'%s' val:'%s'", name, value);
|
||||||
|
merger_set_param(this, name, value);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int apply_props(struct impl *this, const struct spa_pod *param)
|
static int apply_props(struct impl *this, const struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct spa_pod_prop *prop;
|
struct spa_pod_prop *prop;
|
||||||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
||||||
struct props *p = &this->props;
|
struct props *p = &this->props;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
uint32_t n;
|
||||||
|
|
||||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||||
switch (prop->key) {
|
switch (prop->key) {
|
||||||
|
@ -448,32 +489,40 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
||||||
changed++;
|
changed++;
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_channelVolumes:
|
case SPA_PROP_channelVolumes:
|
||||||
if ((p->channel.n_volumes = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
||||||
p->channel.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0)
|
p->channel.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->channel.n_volumes = n;
|
||||||
changed++;
|
changed++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_channelMap:
|
case SPA_PROP_channelMap:
|
||||||
if ((p->n_channels = spa_pod_copy_array(&prop->value, SPA_TYPE_Id,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Id,
|
||||||
p->channel_map, SPA_AUDIO_MAX_CHANNELS)) > 0)
|
p->channel_map, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->n_channels = n;
|
||||||
changed++;
|
changed++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_softMute:
|
case SPA_PROP_softMute:
|
||||||
if (spa_pod_get_bool(&prop->value, &p->soft.mute) == 0)
|
if (spa_pod_get_bool(&prop->value, &p->soft.mute) == 0)
|
||||||
changed++;
|
changed++;
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_softVolumes:
|
case SPA_PROP_softVolumes:
|
||||||
if ((p->soft.n_volumes = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
||||||
p->soft.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0)
|
p->soft.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->soft.n_volumes = n;
|
||||||
changed++;
|
changed++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_monitorMute:
|
case SPA_PROP_monitorMute:
|
||||||
if (spa_pod_get_bool(&prop->value, &p->monitor.mute) == 0)
|
if (spa_pod_get_bool(&prop->value, &p->monitor.mute) == 0)
|
||||||
changed++;
|
changed++;
|
||||||
break;
|
break;
|
||||||
case SPA_PROP_monitorVolumes:
|
case SPA_PROP_monitorVolumes:
|
||||||
if ((p->monitor.n_volumes = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
if ((n = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
|
||||||
p->monitor.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0)
|
p->monitor.volumes, SPA_AUDIO_MAX_CHANNELS)) > 0) {
|
||||||
|
p->monitor.n_volumes = n;
|
||||||
changed++;
|
changed++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue