mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Various fixes and improvements to enum_params
This commit is contained in:
parent
4d890a2d98
commit
30a4651c51
12 changed files with 481 additions and 159 deletions
|
|
@ -48,27 +48,44 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct spa_pod_builder *builder)
|
||||
{
|
||||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
if (id == this->type.param.idProps) {
|
||||
spa_pod_builder_object(builder,
|
||||
id, this->type.props,
|
||||
":", this->type.prop_device, "S", this->props.device, sizeof(this->props.device),
|
||||
":", this->type.prop_device_name, "S", this->props.device_name, sizeof(this->props.device_name),
|
||||
":", this->type.prop_card_name, "S", this->props.card_name, sizeof(this->props.card_name),
|
||||
":", this->type.prop_min_latency, "ir", this->props.min_latency,
|
||||
2, 1, INT32_MAX,
|
||||
":", this->type.prop_max_latency, "ir", this->props.max_latency,
|
||||
2, 1, INT32_MAX);
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
else if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_device, "S", p->device, sizeof(p->device),
|
||||
":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name),
|
||||
":", t->prop_card_name, "S-r", p->card_name, sizeof(p->card_name),
|
||||
":", t->prop_min_latency, "ir", p->min_latency,
|
||||
2, 1, INT32_MAX,
|
||||
":", t->prop_max_latency, "ir", p->max_latency,
|
||||
2, 1, INT32_MAX);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -76,19 +93,23 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
const struct spa_pod_object *param)
|
||||
{
|
||||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (id == this->type.param.idProps) {
|
||||
if (param == NULL) {
|
||||
reset_props(&this->props);
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", this->type.prop_device, "?S", this->props.device, sizeof(this->props.device),
|
||||
":", this->type.prop_min_latency, "?i", &this->props.min_latency, NULL);
|
||||
":", t->prop_device, "?S", p->device, sizeof(p->device),
|
||||
":", t->prop_min_latency, "?i", &p->min_latency, NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
|
@ -251,7 +272,6 @@ static int port_get_format(struct spa_node *node,
|
|||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -286,13 +306,27 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return spa_alsa_enum_format(this, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
return port_get_format(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -307,6 +341,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_alloc_buffers.align, "i", 16);
|
||||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(builder,
|
||||
|
|
|
|||
|
|
@ -47,20 +47,41 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct spa_pod_builder *builder)
|
||||
{
|
||||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, this->type.props,
|
||||
":", this->type.prop_device, "S", this->props.device, sizeof(this->props.device),
|
||||
":", this->type.prop_device_name, "S", this->props.device_name, sizeof(this->props.device_name),
|
||||
":", this->type.prop_card_name, "S", this->props.card_name, sizeof(this->props.card_name),
|
||||
":", this->type.prop_min_latency, "ir", this->props.min_latency,
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
else if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_device, "S", p->device, sizeof(p->device),
|
||||
":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name),
|
||||
":", t->prop_card_name, "S-r", p->card_name, sizeof(p->card_name),
|
||||
":", t->prop_min_latency, "ir", p->min_latency,
|
||||
2, 1, INT32_MAX);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -69,14 +90,26 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
const struct spa_pod_object *param)
|
||||
{
|
||||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_pod_object_parse(param,
|
||||
":", this->type.prop_device, "?S", this->props.device, sizeof(this->props.device),
|
||||
":", this->type.prop_min_latency, "?i", &this->props.min_latency, NULL);
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_device, "?S", p->device, sizeof(p->device),
|
||||
":", t->prop_min_latency, "?i", &p->min_latency, NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -265,7 +298,6 @@ static int port_get_format(struct spa_node *node,
|
|||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -299,13 +331,27 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return spa_alsa_enum_format(this, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
return port_get_format(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -318,6 +364,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_alloc_buffers.align, "i", 16);
|
||||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(builder,
|
||||
|
|
|
|||
|
|
@ -369,14 +369,11 @@ static int port_get_format(struct spa_node *node,
|
|||
struct spa_pod_builder *builder)
|
||||
{
|
||||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct port *port;
|
||||
struct type *t = &this->type;
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
struct port *port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -400,6 +397,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
struct type *t;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
|
@ -410,13 +408,29 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
return port_get_format(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -431,6 +445,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_alloc_buffers.align, "i", 16);
|
||||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(builder,
|
||||
|
|
|
|||
|
|
@ -151,8 +151,7 @@ struct impl {
|
|||
struct spa_list empty;
|
||||
};
|
||||
|
||||
#define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
|
||||
#define CHECK_PORT(this,d,p) (CHECK_PORT_NUM(this,d,p) && this->io)
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
|
||||
|
||||
#define DEFAULT_LIVE false
|
||||
#define DEFAULT_WAVE wave_sine
|
||||
|
|
@ -182,21 +181,36 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
else if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_live, "b", this->props.live,
|
||||
":", t->prop_wave, "Ie", this->props.wave,
|
||||
":", t->prop_live, "b", p->live,
|
||||
":", t->prop_wave, "Ie", p->wave,
|
||||
2, t->wave_sine,
|
||||
t->wave_square,
|
||||
":", t->prop_freq, "dr", this->props.freq,
|
||||
":", t->prop_freq, "dr", p->freq,
|
||||
2, 0.0, 50000000.0,
|
||||
":", t->prop_volume, "dr", this->props.volume,
|
||||
":", t->prop_volume, "dr", p->volume,
|
||||
2, 0.0, 10.0);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -212,18 +226,20 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(this, &this->props);
|
||||
reset_props(this, p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":",t->prop_live, "?b", &this->props.live,
|
||||
":",t->prop_wave, "?I", &this->props.wave,
|
||||
":",t->prop_freq, "?d", &this->props.freq,
|
||||
":",t->prop_volume, "?d", &this->props.volume,
|
||||
":",t->prop_live, "?b", &p->live,
|
||||
":",t->prop_wave, "?I", &p->wave,
|
||||
":",t->prop_freq, "?d", &p->freq,
|
||||
":",t->prop_volume, "?d", &p->volume,
|
||||
NULL);
|
||||
|
||||
if (this->props.live)
|
||||
if (p->live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
else
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
@ -577,13 +593,27 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(this, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
return port_get_format(this, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -598,6 +628,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_alloc_buffers.align, "i", 16);
|
||||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(builder,
|
||||
|
|
@ -793,7 +826,7 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT_NUM(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
this->io = io;
|
||||
|
||||
|
|
|
|||
|
|
@ -314,7 +314,17 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
|
|||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct type *t = &this->type;
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
|
|
@ -322,6 +332,10 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -265,7 +265,17 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
|
|||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct type *t = &this->type;
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
|
|
@ -273,6 +283,10 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@ struct impl {
|
|||
struct spa_list ready;
|
||||
};
|
||||
|
||||
#define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) < MAX_PORTS)
|
||||
#define CHECK_PORT(this,d,p) (CHECK_PORT_NUM(this,d,p) && this->io)
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) < MAX_PORTS)
|
||||
|
||||
#define DEFAULT_LIVE false
|
||||
|
||||
|
|
@ -138,7 +137,18 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
else if (id == t->param.idProps) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_live, "b", this->props.live);
|
||||
|
|
@ -146,6 +156,8 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -348,13 +360,13 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
*n_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
*n_output_ports = 0;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
*max_input_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
*max_output_ports = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -368,8 +380,8 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -452,7 +464,19 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
|
|
@ -621,7 +645,7 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT_NUM(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
this->io = io;
|
||||
|
||||
|
|
|
|||
|
|
@ -118,8 +118,7 @@ struct impl {
|
|||
bool underrun;
|
||||
};
|
||||
|
||||
#define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
|
||||
#define CHECK_PORT(this,d,p) (CHECK_PORT_NUM(this,d,p) && this->io)
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
|
||||
|
||||
#define DEFAULT_LIVE false
|
||||
#define DEFAULT_PATTERN 0
|
||||
|
|
@ -145,16 +144,31 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_live, "b", this->props.live,
|
||||
":", t->prop_pattern, "Ie", this->props.pattern,
|
||||
1, this->props.pattern);
|
||||
":", t->prop_live, "b", p->live,
|
||||
":", t->prop_pattern, "Ie", p->pattern,
|
||||
1, p->pattern);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -170,15 +184,17 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(this, &this->props);
|
||||
reset_props(this, p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_live, "?b", &this->props.live,
|
||||
":", t->prop_pattern, "?I", &this->props.pattern, NULL);
|
||||
":", t->prop_live, "?b", &p->live,
|
||||
":", t->prop_pattern, "?I", &p->pattern, NULL);
|
||||
|
||||
if (this->props.live)
|
||||
if (p->live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
else
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
@ -435,7 +451,6 @@ static int port_get_format(struct spa_node *node,
|
|||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -463,13 +478,28 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
return port_get_format(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param_alloc_buffers.Buffers,
|
||||
":", t->param_alloc_buffers.size, "i", 128,
|
||||
|
|
@ -631,7 +661,7 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT_NUM(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
this->io = io;
|
||||
|
||||
|
|
|
|||
|
|
@ -166,27 +166,6 @@ struct impl {
|
|||
|
||||
#include "v4l2-utils.c"
|
||||
|
||||
static int get_props(struct impl *this, uint32_t *index,
|
||||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
struct type *t = &this->type;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(builder, t->param.idProps, t->props,
|
||||
":", t->prop_device, "S", this->props.device, sizeof(this->props.device),
|
||||
":", t->prop_device_name, "S-r", this->props.device_name, sizeof(this->props.device_name),
|
||||
":", t->prop_device_fd, "i-r", this->props.device_fd);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int impl_node_enum_params(struct spa_node *node,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod_object *filter,
|
||||
|
|
@ -202,10 +181,31 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps)
|
||||
return get_props(this, index, filter, builder);
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
else if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder, t->param.idProps, t->props,
|
||||
":", t->prop_device, "S", p->device, sizeof(p->device),
|
||||
":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name),
|
||||
":", t->prop_device_fd, "i-r", p->device_fd);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node,
|
||||
|
|
@ -221,12 +221,14 @@ static int impl_node_set_param(struct spa_node *node,
|
|||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(&this->props);
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_device, "?S", this->props.device, sizeof(this->props.device), NULL);
|
||||
":", t->prop_device, "?S", p->device, sizeof(p->device), NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
|
@ -466,7 +468,6 @@ static int port_get_format(struct spa_node *node,
|
|||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -541,6 +542,8 @@ static int impl_node_port_enum_params(struct spa_node *node,
|
|||
return port_get_format(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
|
|||
|
|
@ -139,8 +139,7 @@ struct impl {
|
|||
struct spa_list empty;
|
||||
};
|
||||
|
||||
#define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
|
||||
#define CHECK_PORT(this,d,p) (CHECK_PORT_NUM(this,d,p) && this->io)
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
|
||||
|
||||
#define DEFAULT_LIVE false
|
||||
#define DEFAULT_PATTERN pattern_smpte_snow
|
||||
|
|
@ -165,20 +164,32 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
else if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_live, "b", this->props.live,
|
||||
":", t->prop_pattern, "Ie", this->props.pattern,
|
||||
2, t->pattern_smpte_snow,
|
||||
t->pattern_snow);
|
||||
":", t->prop_live, "b", p->live,
|
||||
":", t->prop_pattern, "Ie", p->pattern,
|
||||
2, t->pattern_smpte_snow,
|
||||
t->pattern_snow);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -194,12 +205,14 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_live, "?b", &this->props.live,
|
||||
":", t->prop_pattern, "?I", &this->props.pattern,
|
||||
":", t->prop_live, "?b", &p->live,
|
||||
":", t->prop_pattern, "?I", &p->pattern,
|
||||
NULL);
|
||||
|
||||
if (this->props.live)
|
||||
if (p->live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
else
|
||||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
@ -522,7 +535,19 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
|
|
@ -531,6 +556,8 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
else if (id == t->param.idBuffers) {
|
||||
struct spa_video_info_raw *raw_info = &this->current_format.info.raw;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -543,6 +570,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_alloc_buffers.align, "i", 16);
|
||||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(builder,
|
||||
|
|
@ -717,7 +747,7 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT_NUM(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
this->io = io;
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,9 @@ struct impl {
|
|||
#define CHECK_IN_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0)
|
||||
#define CHECK_OUT_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
#define CHECK_PORT(this,d,p) ((p) == 0)
|
||||
#define GET_IN_PORT(this,p) (&this->in_ports[p])
|
||||
#define GET_OUT_PORT(this,p) (&this->out_ports[p])
|
||||
#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
|
||||
|
||||
#define DEFAULT_VOLUME 1.0
|
||||
#define DEFAULT_MUTE false
|
||||
|
|
@ -148,15 +151,30 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
":", t->param.listId, "I", t->param.idProps);
|
||||
}
|
||||
else if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if(*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_volume, "dr", this->props.volume, 2, 0.0, 10.0,
|
||||
":", t->prop_mute, "b", this->props.mute);
|
||||
":", t->prop_volume, "dr", p->volume, 2, 0.0, 10.0,
|
||||
":", t->prop_mute, "b", p->mute);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -172,13 +190,15 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
t = &this->type;
|
||||
|
||||
if (id == t->param.idProps) {
|
||||
struct props *p = &this->props;
|
||||
|
||||
if (param == NULL) {
|
||||
reset_props(&this->props);
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_volume, "?d", &this->props.volume,
|
||||
":", t->prop_mute, "?b", &this->props.mute, NULL);
|
||||
":", t->prop_volume, "?d", &p->volume,
|
||||
":", t->prop_mute, "?b", &p->mute, NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
|
@ -288,8 +308,7 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -344,12 +363,10 @@ static int port_get_format(struct spa_node *node,
|
|||
struct port *port;
|
||||
struct type *t = &this->type;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
|
|
@ -373,6 +390,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
struct type *t;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
|
@ -383,13 +401,32 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
if (id == t->param.idEnumFormat) {
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
t->param.idFormat,
|
||||
t->param.idBuffers,
|
||||
t->param.idMeta };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return port_enum_formats(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
return port_get_format(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
spa_pod_builder_object(builder,
|
||||
id, t->param_alloc_buffers.Buffers,
|
||||
":", t->param_alloc_buffers.size, "iru", 1024 * this->bpf,
|
||||
|
|
@ -438,8 +475,7 @@ static int port_set_format(struct spa_node *node,
|
|||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct port *port;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
|
|
@ -506,8 +542,7 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
|
@ -568,8 +603,7 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -577,7 +611,7 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
|
||||
static void recycle_buffer(struct impl *this, uint32_t id)
|
||||
{
|
||||
struct port *port = &this->out_ports[0];
|
||||
struct port *port = GET_OUT_PORT(this, 0);
|
||||
struct buffer *b = &port->buffers[id];
|
||||
|
||||
if (!b->outstanding) {
|
||||
|
|
@ -602,7 +636,7 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
|
|||
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id),
|
||||
SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = &this->out_ports[port_id];
|
||||
port = GET_OUT_PORT(this, port_id);
|
||||
|
||||
if (port->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
|
@ -695,14 +729,14 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
out_port = &this->out_ports[0];
|
||||
out_port = GET_OUT_PORT(this, 0);
|
||||
output = out_port->io;
|
||||
spa_return_val_if_fail(output != NULL, SPA_RESULT_ERROR);
|
||||
|
||||
if (output->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
|
||||
in_port = &this->in_ports[0];
|
||||
in_port = GET_IN_PORT(this, 0);
|
||||
input = in_port->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_ERROR);
|
||||
|
||||
|
|
@ -737,7 +771,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
out_port = &this->out_ports[0];
|
||||
out_port = GET_OUT_PORT(this, 0);
|
||||
output = out_port->io;
|
||||
spa_return_val_if_fail(output != NULL, SPA_RESULT_ERROR);
|
||||
|
||||
|
|
@ -750,7 +784,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
output->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
in_port = &this->in_ports[0];
|
||||
in_port = GET_IN_PORT(this, 0);
|
||||
input = in_port->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_ERROR);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ static SPA_LOG_IMPL(default_log);
|
|||
struct type {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
uint32_t format;
|
||||
struct spa_type_param param;
|
||||
};
|
||||
|
||||
|
|
@ -51,15 +52,59 @@ struct data {
|
|||
};
|
||||
|
||||
static void
|
||||
inspect_port(struct data *data, struct spa_node *node, enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
inspect_node_params(struct data *data, struct spa_node *node)
|
||||
{
|
||||
int res;
|
||||
uint32_t idx1, idx2;
|
||||
uint32_t buffer[4096];
|
||||
struct spa_pod_builder b = { 0 };
|
||||
|
||||
for (idx1 = 0;;) {
|
||||
uint32_t buffer[4096];
|
||||
struct spa_pod_builder b = { 0 };
|
||||
struct spa_pod_object *param;
|
||||
uint32_t id;
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_enum_params(node,
|
||||
data->type.param.idList, &idx1,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("enum_params error %d\n", res);
|
||||
break;
|
||||
}
|
||||
param = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_pod_object);
|
||||
|
||||
spa_pod_object_parse(param,
|
||||
":", data->type.param.listId, "I", &id,
|
||||
NULL);
|
||||
|
||||
printf("enumerating: %s:\n", spa_type_map_get_type(data->map, id));
|
||||
for (idx2 = 0;;) {
|
||||
uint32_t flags = 0;
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_enum_params(node,
|
||||
id, &idx2,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("enum_params %id error %d\n", id, res);
|
||||
break;
|
||||
}
|
||||
param = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_pod_object);
|
||||
spa_debug_pod(¶m->pod, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
inspect_port_params(struct data *data, struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
int res;
|
||||
uint32_t idx1, idx2;
|
||||
|
||||
for (idx1 = 0;;) {
|
||||
uint32_t buffer[4096];
|
||||
struct spa_pod_builder b = { 0 };
|
||||
struct spa_pod_object *param;
|
||||
uint32_t id;
|
||||
|
||||
|
|
@ -69,28 +114,31 @@ inspect_port(struct data *data, struct spa_node *node, enum spa_direction direct
|
|||
data->type.param.idList, &idx1,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("got error %d\n", res);
|
||||
printf("port_enum_params error %d\n", res);
|
||||
break;
|
||||
}
|
||||
param = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_pod_object);
|
||||
spa_debug_pod(¶m->pod, 0);
|
||||
|
||||
spa_pod_object_parse(param,
|
||||
":", data->type.param.listId, "I", &id,
|
||||
NULL);
|
||||
|
||||
printf("enumerating: %s:\n", spa_type_map_get_type(data->map, id));
|
||||
for (idx2 = 0;;) {
|
||||
uint32_t flags = 0;
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_port_enum_params(node,
|
||||
direction, port_id,
|
||||
id, &idx2,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("got error %d\n", res);
|
||||
printf("port_enum_params error %d\n", res);
|
||||
break;
|
||||
}
|
||||
param = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_pod_object);
|
||||
spa_debug_pod(¶m->pod, 0);
|
||||
if (param->body.type == data->type.format)
|
||||
flags |= SPA_DEBUG_FLAG_FORMAT;
|
||||
spa_debug_pod(¶m->pod, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +146,7 @@ inspect_port(struct data *data, struct spa_node *node, enum spa_direction direct
|
|||
static void inspect_node(struct data *data, struct spa_node *node)
|
||||
{
|
||||
int res;
|
||||
uint32_t i, n_input, max_input, n_output, max_output, index = 0;
|
||||
uint32_t i, n_input, max_input, n_output, max_output;
|
||||
uint32_t *in_ports, *out_ports;
|
||||
|
||||
printf("node info:\n");
|
||||
|
|
@ -107,19 +155,7 @@ static void inspect_node(struct data *data, struct spa_node *node)
|
|||
else
|
||||
printf(" none\n");
|
||||
|
||||
for (index = 0;;) {
|
||||
uint8_t buf[2048];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
|
||||
struct spa_pod_object *param;
|
||||
|
||||
if ((res = spa_node_enum_params(node, SPA_ID_INVALID, &index, NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("enum_params error: %d\n", res);
|
||||
break;
|
||||
}
|
||||
param = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_pod_object);
|
||||
spa_debug_pod(¶m->pod, 0);
|
||||
}
|
||||
inspect_node_params(data, node);
|
||||
|
||||
if ((res = spa_node_get_n_ports(node, &n_input, &max_input, &n_output, &max_output)) < 0) {
|
||||
printf("can't get n_ports: %d\n", res);
|
||||
|
|
@ -137,12 +173,12 @@ static void inspect_node(struct data *data, struct spa_node *node)
|
|||
|
||||
for (i = 0; i < n_input; i++) {
|
||||
printf(" input port: %08x\n", in_ports[i]);
|
||||
inspect_port(data, node, SPA_DIRECTION_INPUT, in_ports[i]);
|
||||
inspect_port_params(data, node, SPA_DIRECTION_INPUT, in_ports[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < n_output; i++) {
|
||||
printf(" output port: %08x\n", out_ports[i]);
|
||||
inspect_port(data, node, SPA_DIRECTION_OUTPUT, out_ports[i]);
|
||||
inspect_port_params(data, node, SPA_DIRECTION_OUTPUT, out_ports[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -245,6 +281,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.type.node = spa_type_map_get_id(data.map, SPA_TYPE__Node);
|
||||
data.type.clock = spa_type_map_get_id(data.map, SPA_TYPE__Clock);
|
||||
data.type.format = spa_type_map_get_id(data.map, SPA_TYPE__Format);
|
||||
spa_type_param_map(data.map, &data.type.param);
|
||||
|
||||
if ((handle = dlopen(argv[1], RTLD_NOW)) == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue