mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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.
This commit is contained in:
parent
2f66e17180
commit
4b84e34744
2 changed files with 20 additions and 9 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue