mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
channelmix: clean up param handling
Use defines to access the different params. Fix the name of the function to emit properties.
This commit is contained in:
parent
f41de50b28
commit
6562a2ab79
1 changed files with 34 additions and 26 deletions
|
|
@ -96,7 +96,12 @@ struct port {
|
||||||
|
|
||||||
uint64_t info_all;
|
uint64_t info_all;
|
||||||
struct spa_port_info info;
|
struct spa_port_info info;
|
||||||
struct spa_param_info params[8];
|
#define IDX_EnumFormat 0
|
||||||
|
#define IDX_Meta 1
|
||||||
|
#define IDX_IO 2
|
||||||
|
#define IDX_Format 3
|
||||||
|
#define IDX_Buffers 4
|
||||||
|
struct spa_param_info params[5];
|
||||||
|
|
||||||
struct spa_io_buffers *io;
|
struct spa_io_buffers *io;
|
||||||
|
|
||||||
|
|
@ -127,7 +132,9 @@ struct impl {
|
||||||
uint64_t info_all;
|
uint64_t info_all;
|
||||||
struct spa_node_info info;
|
struct spa_node_info info;
|
||||||
struct props props;
|
struct props props;
|
||||||
struct spa_param_info params[8];
|
#define IDX_PropInfo 0
|
||||||
|
#define IDX_Props 1
|
||||||
|
struct spa_param_info params[2];
|
||||||
|
|
||||||
|
|
||||||
struct port control_port;
|
struct port control_port;
|
||||||
|
|
@ -162,10 +169,10 @@ static void emit_info(struct impl *this, bool full)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emit_params_changed(struct impl *this)
|
static void emit_props_changed(struct impl *this)
|
||||||
{
|
{
|
||||||
this->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS;
|
this->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS;
|
||||||
this->params[1].flags ^= SPA_PARAM_INFO_SERIAL;
|
this->params[IDX_Props].flags ^= SPA_PARAM_INFO_SERIAL;
|
||||||
emit_info(this, false);
|
emit_info(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,7 +312,7 @@ static int setup_convert(struct impl *this,
|
||||||
channelmix_set_volume(&this->mix, this->props.volume, this->props.mute,
|
channelmix_set_volume(&this->mix, this->props.volume, this->props.mute,
|
||||||
this->props.n_channel_volumes, this->props.channel_volumes);
|
this->props.n_channel_volumes, this->props.channel_volumes);
|
||||||
|
|
||||||
emit_params_changed(this);
|
emit_props_changed(this);
|
||||||
|
|
||||||
this->is_passthrough = SPA_FLAG_IS_SET(this->mix.flags, CHANNELMIX_FLAG_IDENTITY);
|
this->is_passthrough = SPA_FLAG_IS_SET(this->mix.flags, CHANNELMIX_FLAG_IDENTITY);
|
||||||
|
|
||||||
|
|
@ -491,7 +498,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case SPA_PARAM_Props:
|
case SPA_PARAM_Props:
|
||||||
if (apply_props(this, param) > 0)
|
if (apply_props(this, param) > 0)
|
||||||
emit_params_changed(this);
|
emit_props_changed(this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
@ -838,11 +845,11 @@ static int port_set_format(void *object,
|
||||||
|
|
||||||
port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
|
port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
|
||||||
if (port->have_format) {
|
if (port->have_format) {
|
||||||
port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READWRITE);
|
port->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READWRITE);
|
||||||
port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, SPA_PARAM_INFO_READ);
|
port->params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, SPA_PARAM_INFO_READ);
|
||||||
} else {
|
} else {
|
||||||
port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
port->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||||
port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
port->params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||||
}
|
}
|
||||||
emit_port_info(this, port, false);
|
emit_port_info(this, port, false);
|
||||||
|
|
||||||
|
|
@ -1293,8 +1300,8 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this->info.flags = SPA_NODE_FLAG_RT;
|
this->info.flags = SPA_NODE_FLAG_RT;
|
||||||
this->info.max_input_ports = 2;
|
this->info.max_input_ports = 2;
|
||||||
this->info.max_output_ports = 1;
|
this->info.max_output_ports = 1;
|
||||||
this->params[0] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ);
|
this->params[IDX_PropInfo] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ);
|
||||||
this->params[1] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_READWRITE);
|
this->params[IDX_Props] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_READWRITE);
|
||||||
this->info.params = this->params;
|
this->info.params = this->params;
|
||||||
this->info.n_params = 2;
|
this->info.n_params = 2;
|
||||||
|
|
||||||
|
|
@ -1305,11 +1312,11 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
SPA_PORT_CHANGE_MASK_PARAMS;
|
SPA_PORT_CHANGE_MASK_PARAMS;
|
||||||
port->info = SPA_PORT_INFO_INIT();
|
port->info = SPA_PORT_INFO_INIT();
|
||||||
port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
|
port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
|
||||||
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
port->params[IDX_EnumFormat] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
||||||
port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
|
port->params[IDX_Meta] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
|
||||||
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
port->params[IDX_IO] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
||||||
port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
port->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||||
port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
port->params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||||
port->info.params = port->params;
|
port->info.params = port->params;
|
||||||
port->info.n_params = 5;
|
port->info.n_params = 5;
|
||||||
spa_list_init(&port->queue);
|
spa_list_init(&port->queue);
|
||||||
|
|
@ -1322,11 +1329,11 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
port->info = SPA_PORT_INFO_INIT();
|
port->info = SPA_PORT_INFO_INIT();
|
||||||
port->info.flags = SPA_PORT_FLAG_NO_REF |
|
port->info.flags = SPA_PORT_FLAG_NO_REF |
|
||||||
SPA_PORT_FLAG_DYNAMIC_DATA;
|
SPA_PORT_FLAG_DYNAMIC_DATA;
|
||||||
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
port->params[IDX_EnumFormat] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
||||||
port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
|
port->params[IDX_Meta] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
|
||||||
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
port->params[IDX_IO] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
||||||
port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
port->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||||
port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
port->params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||||
port->info.params = port->params;
|
port->info.params = port->params;
|
||||||
port->info.n_params = 0;
|
port->info.n_params = 0;
|
||||||
spa_list_init(&port->queue);
|
spa_list_init(&port->queue);
|
||||||
|
|
@ -1340,10 +1347,11 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
port->info = SPA_PORT_INFO_INIT();
|
port->info = SPA_PORT_INFO_INIT();
|
||||||
port->info.flags = SPA_PORT_FLAG_NO_REF |
|
port->info.flags = SPA_PORT_FLAG_NO_REF |
|
||||||
SPA_PORT_FLAG_DYNAMIC_DATA;
|
SPA_PORT_FLAG_DYNAMIC_DATA;
|
||||||
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
port->params[IDX_EnumFormat] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
|
||||||
port->params[1] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
port->params[IDX_Meta] = SPA_PARAM_INFO(SPA_PARAM_Meta, 0);
|
||||||
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
port->params[IDX_IO] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
||||||
port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
port->params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||||
|
port->params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||||
port->info.params = port->params;
|
port->info.params = port->params;
|
||||||
port->info.n_params = 4;
|
port->info.n_params = 4;
|
||||||
spa_list_init(&port->queue);
|
spa_list_init(&port->queue);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue