diff options
author | Wim Taymans <wtaymans@redhat.com> | 2017-11-23 12:39:53 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2017-11-23 12:39:53 +0100 |
commit | 4b84e34744fae7d9aebd90c39e363ad5398a3076 (patch) | |
tree | 7fba6e6f167f966ba05d76912edb1a7d91dacf9a /spa | |
parent | 2f66e17180af2e03d6d5a4e9f9bdfd67bc926591 (diff) |
use spa_pod for control values
Pass a spa_pod as the control io area. The pod is not supposed to
change in structure, only the values do so we can achieve the same
kind of performance as passing a single value but still allow for
more complex io area layouts to be passed later.
Diffstat (limited to 'spa')
-rw-r--r-- | spa/plugins/audiotestsrc/audiotestsrc.c | 18 | ||||
-rw-r--r-- | spa/tests/test-control.c | 11 |
2 files changed, 20 insertions, 9 deletions
diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 0664fdab..0e938df5 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -890,12 +890,22 @@ impl_node_port_set_io(struct spa_node *node, this->io = data; else if (id == t->io.ControlRange) this->io_range = data; - else if (id == t->io_prop_wave) - this->io_wave = data; + else if (id == t->io_prop_wave) { + if (SPA_POD_TYPE(data) == SPA_POD_TYPE_ID) + this->io_wave = &SPA_POD_VALUE(struct spa_pod_id, data); + else + return -EINVAL; + } else if (id == t->io_prop_freq) - this->io_freq = data; + if (SPA_POD_TYPE(data) == SPA_POD_TYPE_DOUBLE) + this->io_freq = &SPA_POD_VALUE(struct spa_pod_double, data); + else + return -EINVAL; else if (id == t->io_prop_volume) - this->io_volume = data; + if (SPA_POD_TYPE(data) == SPA_POD_TYPE_DOUBLE) + this->io_volume = &SPA_POD_VALUE(struct spa_pod_double, data); + else + return -EINVAL; else return -ENOENT; diff --git a/spa/tests/test-control.c b/spa/tests/test-control.c index 24872b82..3710fbb9 100644 --- a/spa/tests/test-control.c +++ b/spa/tests/test-control.c @@ -127,9 +127,9 @@ struct data { struct spa_buffer *source_buffers[1]; struct buffer source_buffer[1]; - double ctrl_source_freq; + struct spa_pod_double ctrl_source_freq; double freq_accum; - double ctrl_source_volume; + struct spa_pod_double ctrl_source_volume; double volume_accum; bool running; @@ -242,12 +242,12 @@ static void on_sink_event(void *data, struct spa_event *event) static void update_props(struct data *data) { - data->ctrl_source_freq = ((sin(data->freq_accum) + 1.0) * 200.0) + 440.0; + data->ctrl_source_freq.value = ((sin(data->freq_accum) + 1.0) * 200.0) + 440.0; data->freq_accum += M_PI_M2 / 880.0; if (data->freq_accum >= M_PI_M2) data->freq_accum -= M_PI_M2; - data->ctrl_source_volume = (sin(data->volume_accum) / 2.0) + 0.5; + data->ctrl_source_volume.value = (sin(data->volume_accum) / 2.0) + 0.5; data->volume_accum += M_PI_M2 / 2000.0; if (data->volume_accum >= M_PI_M2) data->volume_accum -= M_PI_M2; @@ -345,7 +345,8 @@ static int make_nodes(struct data *data, const char *device) ":", data->type.props_volume, "d", 0.5, ":", data->type.props_live, "b", false); - data->ctrl_source_freq = 600.0; + data->ctrl_source_freq = SPA_POD_DOUBLE_INIT(600.0); + data->ctrl_source_volume = SPA_POD_DOUBLE_INIT(0.5); if ((res = spa_node_set_param(data->source, data->type.param.idProps, 0, props)) < 0) printf("got set_props error %d\n", res); |