Add new pod parser and builder

Add a new pod builder and parser that is less verbose and
a little more powerful.
This commit is contained in:
Wim Taymans 2017-09-21 18:57:41 +02:00
parent 3e49aec61b
commit 24d80e5c00
54 changed files with 3616 additions and 2817 deletions

View file

@ -112,8 +112,8 @@ fill_item(struct impl *this, snd_ctl_card_info_t *card_info, snd_pcm_info_t *dev
const char *str, *name, *klass = NULL;
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(this->item_buffer, sizeof(this->item_buffer));
const struct spa_handle_factory *factory = NULL;
struct spa_pod_frame f[3];
char card_name[64];
struct type *t = &this->type;
switch (snd_pcm_info_get_stream(dev_info)) {
case SND_PCM_STREAM_PLAYBACK:
@ -141,62 +141,56 @@ fill_item(struct impl *this, snd_ctl_card_info_t *card_info, snd_pcm_info_t *dev
snprintf(card_name, 64, "%s,%d", this->card_name, snd_pcm_info_get_device(dev_info));
spa_pod_builder_add(&b,
SPA_POD_TYPE_OBJECT, &f[0], 0, this->type.monitor.MonitorItem,
SPA_POD_PROP(&f[1], this->type.monitor.id, 0, SPA_POD_TYPE_STRING, 1,
name),
SPA_POD_PROP(&f[1], this->type.monitor.flags, 0, SPA_POD_TYPE_INT, 1,
0),
SPA_POD_PROP(&f[1], this->type.monitor.state, 0, SPA_POD_TYPE_INT, 1,
SPA_MONITOR_ITEM_STATE_AVAILABLE),
SPA_POD_PROP(&f[1], this->type.monitor.name, 0, SPA_POD_TYPE_STRING, 1,
name),
SPA_POD_PROP(&f[1], this->type.monitor.klass, 0, SPA_POD_TYPE_STRING, 1,
klass),
SPA_POD_PROP(&f[1], this->type.monitor.factory, 0, SPA_POD_TYPE_POINTER, 1,
this->type.handle_factory, factory), 0);
"<", 0, t->monitor.MonitorItem,
":", t->monitor.id, "s", name,
":", t->monitor.flags, "i", 0,
":", t->monitor.state, "i", SPA_MONITOR_ITEM_STATE_AVAILABLE,
":", t->monitor.name, "s", name,
":", t->monitor.klass, "s", klass,
":", t->monitor.factory, "p", t->handle_factory, factory, NULL);
spa_pod_builder_add(&b,
SPA_POD_TYPE_PROP, &f[1], this->type.monitor.info, 0,
SPA_POD_TYPE_STRUCT, 1, &f[2], 0);
":", t->monitor.info, "[", NULL);
spa_pod_builder_add(&b,
SPA_POD_TYPE_STRING, "alsa.card", SPA_POD_TYPE_STRING, card_name,
SPA_POD_TYPE_STRING, "alsa.card.id", SPA_POD_TYPE_STRING, snd_ctl_card_info_get_id(card_info),
SPA_POD_TYPE_STRING, "alsa.card.components", SPA_POD_TYPE_STRING, snd_ctl_card_info_get_components(card_info),
SPA_POD_TYPE_STRING, "alsa.card.driver", SPA_POD_TYPE_STRING, snd_ctl_card_info_get_driver(card_info),
SPA_POD_TYPE_STRING, "alsa.card.name", SPA_POD_TYPE_STRING, snd_ctl_card_info_get_name(card_info),
SPA_POD_TYPE_STRING, "alsa.card.longname", SPA_POD_TYPE_STRING, snd_ctl_card_info_get_longname(card_info),
SPA_POD_TYPE_STRING, "alsa.card.mixername", SPA_POD_TYPE_STRING, snd_ctl_card_info_get_mixername(card_info),
SPA_POD_TYPE_STRING, "udev-probed", SPA_POD_TYPE_STRING, "1",
SPA_POD_TYPE_STRING, "device.api", SPA_POD_TYPE_STRING, "alsa",
SPA_POD_TYPE_STRING, "alsa.pcm.id", SPA_POD_TYPE_STRING, snd_pcm_info_get_id(dev_info),
SPA_POD_TYPE_STRING, "alsa.pcm.name", SPA_POD_TYPE_STRING, snd_pcm_info_get_name(dev_info),
SPA_POD_TYPE_STRING, "alsa.pcm.subname", SPA_POD_TYPE_STRING, snd_pcm_info_get_subdevice_name(dev_info), 0);
"s", "alsa.card", "s", card_name,
"s", "alsa.card.id", "s", snd_ctl_card_info_get_id(card_info),
"s", "alsa.card.components", "s", snd_ctl_card_info_get_components(card_info),
"s", "alsa.card.driver", "s", snd_ctl_card_info_get_driver(card_info),
"s", "alsa.card.name", "s", snd_ctl_card_info_get_name(card_info),
"s", "alsa.card.longname", "s", snd_ctl_card_info_get_longname(card_info),
"s", "alsa.card.mixername", "s", snd_ctl_card_info_get_mixername(card_info),
"s", "udev-probed", "s", "1",
"s", "device.api", "s", "alsa",
"s", "alsa.pcm.id", "s", snd_pcm_info_get_id(dev_info),
"s", "alsa.pcm.name", "s", snd_pcm_info_get_name(dev_info),
"s", "alsa.pcm.subname", "s", snd_pcm_info_get_subdevice_name(dev_info),
NULL);
if ((str = udev_device_get_property_value(dev, "SOUND_CLASS")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.class", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.class", "s", str, NULL);
}
str = udev_device_get_property_value(dev, "ID_PATH");
if (!(str && *str))
str = udev_device_get_syspath(dev);
if (str && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.bus_path", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.bus_path", "s", str, 0);
}
if ((str = udev_device_get_syspath(dev)) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "sysfs.path", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "sysfs.path", "s", str, 0);
}
if ((str = udev_device_get_property_value(dev, "ID_ID")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "udev.id", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "udev.id", "s", str, 0);
}
if ((str = udev_device_get_property_value(dev, "ID_BUS")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.bus", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.bus", "s", str, 0);
}
if ((str = udev_device_get_property_value(dev, "SUBSYSTEM")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.subsystem", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.subsystem", "s", str, 0);
}
if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.vendor.id", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.vendor.id", "s", str, 0);
}
str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE");
if (!(str && *str)) {
@ -206,26 +200,20 @@ fill_item(struct impl *this, snd_ctl_card_info_t *card_info, snd_pcm_info_t *dev
}
}
if (str && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.vendor.name", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.vendor.name", "s", str, 0);
}
if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.product.id", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.product.id", "s", str, 0);
}
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.product.name", SPA_POD_TYPE_STRING, name, 0);
spa_pod_builder_add(&b, "s", "device.product.name", "s", name, 0);
if ((str = udev_device_get_property_value(dev, "ID_SERIAL")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.serial", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.serial", "s", str, 0);
}
if ((str = udev_device_get_property_value(dev, "SOUND_FORM_FACTOR")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.form_factor", SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.form_factor", "s", str, 0);
}
spa_pod_builder_add(&b,
-SPA_POD_TYPE_STRUCT, &f[2],
-SPA_POD_TYPE_PROP, &f[1],
-SPA_POD_TYPE_OBJECT, &f[0], 0);
this->item = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_monitor_item);
this->item = spa_pod_builder_add(&b, "]>", NULL);
return 0;
}
@ -342,14 +330,12 @@ static void impl_on_fd_events(struct spa_source *source)
while (true) {
uint8_t buffer[4096];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct spa_pod_frame f[1];
struct spa_event *event;
if (get_next_device(this, dev) < 0)
break;
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->item);
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
event = spa_pod_builder_object(&b, 0, type, "P", this->item);
this->callbacks->event(this->callbacks_data, event);
}
close_card(this);

View file

@ -44,7 +44,6 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -53,17 +52,13 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP(&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING,
this->props.device, sizeof(this->props.device)),
PROP(&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING,
this->props.device_name, sizeof(this->props.device_name)),
PROP(&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING,
this->props.card_name, sizeof(this->props.card_name)),
PROP_MM(&f[1], this->type.prop_min_latency, SPA_POD_TYPE_INT,
this->props.min_latency,
1, INT32_MAX));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b,
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);
return SPA_RESULT_OK;
}
@ -80,10 +75,9 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
reset_props(&this->props);
return SPA_RESULT_OK;
} else {
spa_props_query(props,
this->type.prop_device, -SPA_POD_TYPE_STRING,
this->props.device, sizeof(this->props.device),
this->type.prop_min_latency, SPA_POD_TYPE_INT, &this->props.min_latency, 0);
spa_props_parse(props,
":", this->type.prop_device, "?S", this->props.device, sizeof(this->props.device),
":", this->type.prop_min_latency, "?i", &this->props.min_latency, NULL);
}
return SPA_RESULT_OK;
}
@ -273,7 +267,7 @@ impl_node_port_set_format(struct spa_node *node,
info.media_subtype != this->type.media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio))
if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (spa_alsa_set_format(this, &info, flags) < 0)
@ -299,12 +293,13 @@ impl_node_port_get_format(struct spa_node *node,
{
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct state, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -312,16 +307,12 @@ impl_node_port_get_format(struct spa_node *node,
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
this->current_format.info.raw.format),
PROP(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
this->current_format.info.raw.rate),
PROP(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
this->current_format.info.raw.channels));
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
*format = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
":", t->format_audio.format, "I", this->current_format.info.raw.format,
":", t->format_audio.rate, "i", this->current_format.info.raw.rate,
":", t->format_audio.channels, "i", this->current_format.info.raw.channels);
return SPA_RESULT_OK;
}
@ -354,12 +345,13 @@ impl_node_port_enum_params(struct spa_node *node,
struct state *this;
struct spa_pod_builder b = { NULL };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct state, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -367,48 +359,40 @@ impl_node_port_enum_params(struct spa_node *node,
switch (index) {
case 0:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP_U_MM(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
this->props.min_latency * this->frame_size,
this->props.min_latency * this->frame_size, INT32_MAX),
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
0),
PROP_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
2, 2, 32),
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
16));
*param = spa_pod_builder_param(&b,
t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "iru", this->props.min_latency * this->frame_size,
2, this->props.min_latency * this->frame_size,
INT32_MAX,
":", t->param_alloc_buffers.stride, "i", 0,
":", t->param_alloc_buffers.buffers, "ir", 2,
2, 2, 32,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
case 2:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Ringbuffer),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_ringbuffer)),
PROP(&f[1], this->type.param_alloc_meta_enable.ringbufferSize, SPA_POD_TYPE_INT,
this->period_frames * this->frame_size * 32),
PROP(&f[1], this->type.param_alloc_meta_enable.ringbufferStride, SPA_POD_TYPE_INT,
0),
PROP(&f[1], this->type.param_alloc_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT,
1),
PROP(&f[1], this->type.param_alloc_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT,
16));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Ringbuffer,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_ringbuffer),
":", t->param_alloc_meta_enable.ringbufferSize, "i", this->period_frames *
this->frame_size * 32,
":", t->param_alloc_meta_enable.ringbufferStride, "i", 0,
":", t->param_alloc_meta_enable.ringbufferBlocks, "i", 1,
":", t->param_alloc_meta_enable.ringbufferAlign, "i", 16);
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}

View file

@ -45,7 +45,6 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -54,17 +53,13 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP(&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING,
this->props.device, sizeof(this->props.device)),
PROP(&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING,
this->props.device_name, sizeof(this->props.device_name)),
PROP(&f[1], this->type. prop_card_name, -SPA_POD_TYPE_STRING,
this->props.card_name, sizeof(this->props.card_name)),
PROP_MM(&f[1], this->type.prop_min_latency, SPA_POD_TYPE_INT,
this->props.min_latency, 1, INT32_MAX));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b,
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);
return SPA_RESULT_OK;
}
@ -81,10 +76,9 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
reset_props(&this->props);
return SPA_RESULT_OK;
} else {
spa_props_query(props,
this->type.prop_device, -SPA_POD_TYPE_STRING,
this->props.device, sizeof(this->props.device),
this->type.prop_min_latency, SPA_POD_TYPE_INT, &this->props.min_latency, 0);
spa_props_parse(props,
":", this->type.prop_device, "?S", this->props.device, sizeof(this->props.device),
":", this->type.prop_min_latency, "?i", &this->props.min_latency, NULL);
}
return SPA_RESULT_OK;
@ -300,7 +294,7 @@ impl_node_port_set_format(struct spa_node *node,
info.media_subtype != this->type.media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio))
if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (spa_alsa_set_format(this, &info, flags) < 0)
@ -324,12 +318,13 @@ impl_node_port_get_format(struct spa_node *node,
{
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct state, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -337,16 +332,12 @@ impl_node_port_get_format(struct spa_node *node,
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
this->current_format.info.raw.format),
PROP(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
this->current_format.info.raw.rate),
PROP(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
this->current_format.info.raw.channels));
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
*format = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
":", t->format_audio.format, "I", this->current_format.info.raw.format,
":", t->format_audio.rate, "i", this->current_format.info.raw.rate,
":", t->format_audio.channels, "i", this->current_format.info.raw.channels);
return SPA_RESULT_OK;
}
@ -375,12 +366,13 @@ impl_node_port_enum_params(struct spa_node *node,
{
struct state *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct state, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -388,32 +380,26 @@ impl_node_port_enum_params(struct spa_node *node,
switch (index) {
case 0:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT
, this->props.min_latency * this->frame_size),
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
0),
PROP_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
32,
1, 32),
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
16));
*param = spa_pod_builder_param(&b,
t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "i", this->props.min_latency * this->frame_size,
":", t->param_alloc_buffers.stride, "i", 0,
":", t->param_alloc_buffers.buffers, "i", 2,
2, 1, 32,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}

View file

@ -161,19 +161,6 @@ struct state {
int64_t last_monotonic;
};
#define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
int
spa_alsa_enum_format(struct state *state,
struct spa_format **format, const struct spa_format *filter, uint32_t index);

View file

@ -122,19 +122,6 @@ struct impl {
#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 PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
return SPA_RESULT_NOT_IMPLEMENTED;
@ -310,13 +297,14 @@ impl_node_port_enum_formats(struct spa_node *node,
struct spa_format *fmt;
uint8_t buffer[256];
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
uint32_t count, match;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -327,24 +315,20 @@ impl_node_port_enum_formats(struct spa_node *node,
switch (count++) {
case 0:
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP_U_EN(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID, 3,
this->type.audio_format.S16,
this->type.audio_format.S16,
this->type.audio_format.F32),
PROP_U_MM(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
44100,
1, INT32_MAX),
PROP_U_MM(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
2,
1, INT32_MAX));
fmt = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
":", t->format_audio.format, "Ieu", t->audio_format.S16,
2, t->audio_format.S16,
t->audio_format.F32,
":", t->format_audio.rate, "iru", 44100,
2, 1, INT32_MAX,
":", t->format_audio.channels, "iru", 2,
2, 1, INT32_MAX);
break;
default:
return SPA_RESULT_ENUM_END;
}
fmt = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
@ -375,10 +359,12 @@ impl_node_port_set_format(struct spa_node *node,
{
struct impl *this;
struct port *port;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -396,11 +382,11 @@ impl_node_port_set_format(struct spa_node *node,
SPA_FORMAT_MEDIA_SUBTYPE(format),
};
if (info.media_type != this->type.media_type.audio ||
info.media_subtype != this->type.media_subtype.raw)
if (info.media_type != t->media_type.audio ||
info.media_subtype != t->media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio))
if (spa_format_audio_raw_parse(format, &info.info.raw, &t->format_audio) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (this->have_format) {
@ -409,11 +395,11 @@ impl_node_port_set_format(struct spa_node *node,
} else {
this->have_format = true;
this->format = info;
if (info.info.raw.format == this->type.audio_format.S16) {
if (info.info.raw.format == t->audio_format.S16) {
this->copy = this->ops.copy[CONV_S16_S16];
this->add = this->ops.add[CONV_S16_S16];
}
else if (info.info.raw.format == this->type.audio_format.F32) {
else if (info.info.raw.format == t->audio_format.F32) {
this->copy = this->ops.copy[CONV_F32_F32];
this->add = this->ops.add[CONV_F32_F32];
}
@ -437,12 +423,13 @@ impl_node_port_get_format(struct spa_node *node,
struct impl *this;
struct port *port;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -452,16 +439,12 @@ impl_node_port_get_format(struct spa_node *node,
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
this->format.info.raw.format),
PROP(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
this->format.info.raw.rate),
PROP(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
this->format.info.raw.channels));
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
*format = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
":", t->format_audio.format, "I", this->format.info.raw.format,
":", t->format_audio.rate, "i", this->format.info.raw.rate,
":", t->format_audio.channels, "i", this->format.info.raw.channels);
return SPA_RESULT_OK;
}
@ -517,10 +500,12 @@ impl_node_port_use_buffers(struct spa_node *node,
struct impl *this;
struct port *port;
uint32_t i;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -537,11 +522,11 @@ impl_node_port_use_buffers(struct spa_node *node,
b = &port->buffers[i];
b->outbuf = buffers[i];
b->outstanding = direction == SPA_DIRECTION_INPUT ? true : false;
b->h = spa_buffer_find_meta(buffers[i], this->type.meta.Header);
b->h = spa_buffer_find_meta(buffers[i], t->meta.Header);
if (!((d[0].type == this->type.data.MemPtr ||
d[0].type == this->type.data.MemFd ||
d[0].type == this->type.data.DmaBuf) && d[0].data != NULL)) {
if (!((d[0].type == t->data.MemPtr ||
d[0].type == t->data.MemFd ||
d[0].type == t->data.DmaBuf) && d[0].data != NULL)) {
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
buffers[i]);
return SPA_RESULT_ERROR;

View file

@ -169,46 +169,28 @@ static void reset_props(struct impl *this, struct props *props)
props->volume = DEFAULT_VOLUME;
}
#define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP(&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL,
this->props.live),
PROP_EN(&f[1], this->type.prop_wave, SPA_POD_TYPE_ID, 3,
this->props.wave,
this->type.wave_sine,
this->type.wave_square),
PROP_MM(&f[1], this->type.prop_freq, SPA_POD_TYPE_DOUBLE,
this->props.freq,
0.0, 50000000.0),
PROP_MM(&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE,
this->props.volume,
0.0, 10.0));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b, t->props,
":", t->prop_live, "b", this->props.live,
":", t->prop_wave, "Ie", this->props.wave,
2, t->wave_sine,
t->wave_square,
":", t->prop_freq, "dr", this->props.freq,
2, 0.0, 50000000.0,
":", t->prop_volume, "dr", this->props.volume,
2, 0.0, 10.0);
return SPA_RESULT_OK;
}
@ -216,20 +198,22 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
{
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (props == NULL) {
reset_props(this, &this->props);
} else {
spa_props_query(props,
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
this->type.prop_wave, SPA_POD_TYPE_ID, &this->props.wave,
this->type.prop_freq, SPA_POD_TYPE_DOUBLE, &this->props.freq,
this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
0);
spa_props_parse(props,
":",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,
NULL);
}
if (this->props.live)
@ -483,13 +467,14 @@ impl_node_port_enum_formats(struct spa_node *node,
struct spa_format *fmt;
uint8_t buffer[256];
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
uint32_t count, match;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -500,26 +485,22 @@ impl_node_port_enum_formats(struct spa_node *node,
switch (count++) {
case 0:
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP_U_EN(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID, 5,
this->type.audio_format.S16,
this->type.audio_format.S16,
this->type.audio_format.S32,
this->type.audio_format.F32,
this->type.audio_format.F64),
PROP_U_MM(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
44100,
1, INT32_MAX),
PROP_U_MM(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
2,
1, INT32_MAX));
fmt = spa_pod_builder_format(&b, t->format,
t->media_type.audio,
t->media_subtype.raw,
":", t->format_audio.format, "Ieu", t->audio_format.S16,
4, t->audio_format.S16,
t->audio_format.S32,
t->audio_format.F32,
t->audio_format.F64,
":", t->format_audio.rate, "iru", 44100,
2, 1, INT32_MAX,
":", t->format_audio.channels, "iru", 2,
2, 1, INT32_MAX);
break;
default:
return SPA_RESULT_ENUM_END;
}
fmt = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
@ -551,10 +532,12 @@ impl_node_port_set_format(struct spa_node *node,
const struct spa_format *format)
{
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -568,20 +551,20 @@ impl_node_port_set_format(struct spa_node *node,
int idx;
int sizes[4] = { 2, 4, 4, 8 };
if (info.media_type != this->type.media_type.audio ||
info.media_subtype != this->type.media_subtype.raw)
if (info.media_type != t->media_type.audio ||
info.media_subtype != t->media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio))
if (spa_format_audio_raw_parse(format, &info.info.raw, &t->format_audio) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (info.info.raw.format == this->type.audio_format.S16)
if (info.info.raw.format == t->audio_format.S16)
idx = 0;
else if (info.info.raw.format == this->type.audio_format.S32)
else if (info.info.raw.format == t->audio_format.S32)
idx = 1;
else if (info.info.raw.format == this->type.audio_format.F32)
else if (info.info.raw.format == t->audio_format.F32)
idx = 2;
else if (info.info.raw.format == this->type.audio_format.F64)
else if (info.info.raw.format == t->audio_format.F64)
idx = 3;
else
return SPA_RESULT_INVALID_MEDIA_TYPE;
@ -607,12 +590,13 @@ impl_node_port_get_format(struct spa_node *node,
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -620,17 +604,11 @@ impl_node_port_get_format(struct spa_node *node,
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
this->current_format.info.raw.format),
PROP(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
this->current_format.info.raw.rate),
PROP(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
this->current_format.info.raw.channels));
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
*format = spa_pod_builder_format(&b, t->format,
t->media_type.audio, t->media_subtype.raw,
":", t->format_audio.format, "I", this->current_format.info.raw.format,
":", t->format_audio.rate, "i", this->current_format.info.raw.rate,
":", t->format_audio.channels, "i", this->current_format.info.raw.channels);
return SPA_RESULT_OK;
}
@ -664,12 +642,13 @@ impl_node_port_enum_params(struct spa_node *node,
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -677,30 +656,28 @@ impl_node_port_enum_params(struct spa_node *node,
switch (index) {
case 0:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP_U_MM(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
1024 * this->bpf,
16 * this->bpf,
INT32_MAX / this->bpf),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 2, 1, 32),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
*param = spa_pod_builder_param(&b,
t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "iru", 1024 * this->bpf,
2, 16 * this->bpf,
INT32_MAX / this->bpf,
":", t->param_alloc_buffers.stride, "i", 0,
":", t->param_alloc_buffers.buffers, "iru", 2,
2, 1, 32,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}

View file

@ -244,7 +244,7 @@ spa_ffmpeg_dec_node_port_set_format(struct spa_node *node,
info.media_subtype != this->type.media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video))
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {

View file

@ -248,7 +248,7 @@ spa_ffmpeg_enc_node_port_set_format(struct spa_node *node,
info.media_subtype != this->type.media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video))
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {

View file

@ -125,24 +125,10 @@ static void reset_props(struct impl *this, struct props *props)
props->live = DEFAULT_LIVE;
}
#define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key, SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -150,10 +136,9 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP(&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL,
this->props.live));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b,
this->type.props,
":", this->type.prop_live, "b", this->props.live);
return SPA_RESULT_OK;
}
@ -169,8 +154,8 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
if (props == NULL) {
reset_props(this, &this->props);
} else {
spa_props_query(props,
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, 0);
spa_props_parse(props,
":", this->type.prop_live, "?b", &this->props.live, NULL);
}
if (this->props.live)
@ -497,12 +482,13 @@ impl_node_port_enum_params(struct spa_node *node,
{
struct impl *this;
struct spa_pod_builder b = { NULL };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -510,30 +496,25 @@ impl_node_port_enum_params(struct spa_node *node,
switch (index) {
case 0:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
128),
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
1),
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
32,
2, 32),
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
16));
*param = spa_pod_builder_param(&b,
t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "i", 128,
":", t->param_alloc_buffers.stride, "i", 1,
":", t->param_alloc_buffers.buffers, "ir", 2,
2, 1, 32,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}

View file

@ -131,39 +131,24 @@ static void reset_props(struct impl *this, struct props *props)
props->pattern = DEFAULT_PATTERN;
}
#define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key, SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP(&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL,
this->props.live),
PROP_EN(&f[1], this->type.prop_pattern, SPA_POD_TYPE_ID, 1,
this->props.pattern,
this->props.pattern));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b,
t->props,
":", t->prop_live, "b", this->props.live,
":", t->prop_pattern, "Ie", this->props.pattern,
1, this->props.pattern);
return SPA_RESULT_OK;
}
@ -171,17 +156,19 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
{
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (props == NULL) {
reset_props(this, &this->props);
} else {
spa_props_query(props,
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
this->type.prop_pattern, SPA_POD_TYPE_ID, &this->props.pattern, 0);
spa_props_parse(props,
":", t->prop_live, "?b", &this->props.live,
":", t->prop_pattern, "?I", &this->props.pattern, NULL);
}
if (this->props.live)
@ -514,12 +501,13 @@ impl_node_port_enum_params(struct spa_node *node,
{
struct impl *this;
struct spa_pod_builder b = { NULL };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -527,30 +515,25 @@ impl_node_port_enum_params(struct spa_node *node,
switch (index) {
case 0:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
128),
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
1),
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
32,
2, 32),
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
16));
*param = spa_pod_builder_param(&b,
t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "i", 128,
":", t->param_alloc_buffers.stride, "i", 1,
":", t->param_alloc_buffers.buffers, "ir", 32,
2, 2, 32,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}

View file

@ -89,7 +89,7 @@ static void fill_item(struct impl *this, struct item *item, struct udev_device *
{
const char *str, *name;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[3];
struct type *t = &this->type;
if (item->udevice)
udev_device_unref(item->udevice);
@ -112,59 +112,43 @@ static void fill_item(struct impl *this, struct item *item, struct udev_device *
spa_pod_builder_init(&b, this->item_buffer, sizeof(this->item_buffer));
spa_pod_builder_push_object(&b, &f[0], 0, this->type.monitor.MonitorItem);
spa_pod_builder_add(&b,
"<", 0, t->monitor.MonitorItem,
":", t->monitor.id, "s", udev_device_get_syspath(item->udevice),
":", t->monitor.flags, "i", 0,
":", t->monitor.state, "i", SPA_MONITOR_ITEM_STATE_AVAILABLE,
":", t->monitor.name, "s", name,
":", t->monitor.klass, "s", "Video/Source",
":", t->monitor.factory, "p", t->handle_factory, &spa_v4l2_source_factory,
":", t->monitor.info, "[",
NULL);
spa_pod_builder_add(&b,
SPA_POD_PROP(&f[1], this->type.monitor.id, 0, SPA_POD_TYPE_STRING, 1,
udev_device_get_syspath(item->udevice)),
SPA_POD_PROP(&f[1], this->type.monitor.flags, 0, SPA_POD_TYPE_INT, 1,
0),
SPA_POD_PROP(&f[1], this->type.monitor.state, 0, SPA_POD_TYPE_INT, 1,
SPA_MONITOR_ITEM_STATE_AVAILABLE),
SPA_POD_PROP(&f[1], this->type.monitor.name, 0, SPA_POD_TYPE_STRING, 1,
name),
SPA_POD_PROP(&f[1], this->type.monitor.klass, 0, SPA_POD_TYPE_STRING, 1,
"Video/Source"),
SPA_POD_PROP(&f[1], this->type.monitor.factory, 0, SPA_POD_TYPE_POINTER, 1,
this->type.handle_factory, &spa_v4l2_source_factory),
0);
spa_pod_builder_add(&b,
SPA_POD_TYPE_PROP, &f[1], this->type.monitor.info, 0,
SPA_POD_TYPE_STRUCT, 1, &f[2], 0);
spa_pod_builder_add(&b,
SPA_POD_TYPE_STRING, "udev-probed", SPA_POD_TYPE_STRING, "1",
SPA_POD_TYPE_STRING, "device.api", SPA_POD_TYPE_STRING, "v4l2",
SPA_POD_TYPE_STRING, "device.path", SPA_POD_TYPE_STRING,
udev_device_get_devnode(item->udevice), 0);
"s", "udev-probed", "s", "1",
"s", "device.api", "s", "v4l2",
"s", "device.path", "s", udev_device_get_devnode(item->udevice),
NULL);
str = udev_device_get_property_value(item->udevice, "ID_PATH");
if (!(str && *str))
str = udev_device_get_syspath(item->udevice);
if (str && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.bus_path", SPA_POD_TYPE_STRING,
str, 0);
spa_pod_builder_add(&b, "s", "device.bus_path", "s", str, 0);
}
if ((str = udev_device_get_syspath(item->udevice)) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "sysfs.path", SPA_POD_TYPE_STRING,
str, 0);
spa_pod_builder_add(&b, "s", "sysfs.path", "s", str, 0);
}
if ((str = udev_device_get_property_value(item->udevice, "ID_ID")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "udev.id", SPA_POD_TYPE_STRING,
str, 0);
spa_pod_builder_add(&b, "s", "udev.id", "s", str, 0);
}
if ((str = udev_device_get_property_value(item->udevice, "ID_BUS")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.bus", SPA_POD_TYPE_STRING,
str, 0);
spa_pod_builder_add(&b, "s", "device.bus", "s", str, 0);
}
if ((str = udev_device_get_property_value(item->udevice, "SUBSYSTEM")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.subsystem",
SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.subsystem", "s", str, 0);
}
if ((str = udev_device_get_property_value(item->udevice, "ID_VENDOR_ID")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.vendor.id",
SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.vendor.id", "s", str, 0);
}
str = udev_device_get_property_value(item->udevice, "ID_VENDOR_FROM_DATABASE");
if (!(str && *str)) {
@ -174,29 +158,20 @@ static void fill_item(struct impl *this, struct item *item, struct udev_device *
}
}
if (str && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.vendor.name",
SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.vendor.name", "s", str, 0);
}
if ((str = udev_device_get_property_value(item->udevice, "ID_MODEL_ID")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.product.id",
SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.product.id", "s", str, 0);
}
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.product.name", SPA_POD_TYPE_STRING,
name, 0);
spa_pod_builder_add(&b, "s", "device.product.name", "s", name, 0);
if ((str = udev_device_get_property_value(item->udevice, "ID_SERIAL")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.serial", SPA_POD_TYPE_STRING,
str, 0);
spa_pod_builder_add(&b, "s", "device.serial", "s", str, 0);
}
if ((str = udev_device_get_property_value(item->udevice, "ID_V4L_CAPABILITIES")) && *str) {
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.capabilities",
SPA_POD_TYPE_STRING, str, 0);
spa_pod_builder_add(&b, "s", "device.capabilities", "s", str, 0);
}
spa_pod_builder_add(&b, -SPA_POD_TYPE_STRUCT, &f[2], -SPA_POD_TYPE_PROP, &f[1], 0);
spa_pod_builder_pop(&b, &f[0]);
item->item = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_monitor_item);
item->item = spa_pod_builder_add(&b, "]>", NULL);
}
static void impl_on_fd_events(struct spa_source *source)
@ -207,7 +182,6 @@ static void impl_on_fd_events(struct spa_source *source)
const char *action;
uint32_t type;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[1];
uint8_t buffer[4096];
dev = udev_monitor_receive_device(this->umonitor);
@ -228,9 +202,8 @@ static void impl_on_fd_events(struct spa_source *source)
return;
spa_pod_builder_init(&b, buffer, sizeof(buffer));
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->uitem.item);
event = spa_pod_builder_object(&b, 0, type, "P", this->uitem.item);
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
this->callbacks->event(this->callbacks_data, event);
}

View file

@ -166,42 +166,25 @@ struct impl {
#define CHECK_PORT(this,direction,port_id) ((direction) == SPA_DIRECTION_OUTPUT && (port_id) == 0)
#define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_R(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_READONLY,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#include "v4l2-utils.c"
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP(&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING,
this->props.device, sizeof(this->props.device)),
PROP_R(&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING,
this->props.device_name, sizeof(this->props.device_name)),
PROP_R(&f[1], this->type.prop_device_fd, SPA_POD_TYPE_INT,
this->props.device_fd));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b, 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);
return SPA_RESULT_OK;
}
@ -209,18 +192,20 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
{
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (props == NULL) {
reset_props(&this->props);
return SPA_RESULT_OK;
} else {
spa_props_query(props, this->type.prop_device, -SPA_POD_TYPE_STRING,
this->props.device, sizeof(this->props.device), 0);
}
spa_props_parse(props,
":", t->prop_device, "?S", this->props.device, sizeof(this->props.device), NULL);
return SPA_RESULT_OK;
}
@ -456,10 +441,12 @@ static int impl_node_port_set_format(struct spa_node *node,
struct impl *this;
struct port *state;
struct spa_video_info info;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -475,13 +462,13 @@ static int impl_node_port_set_format(struct spa_node *node,
info.media_type = SPA_FORMAT_MEDIA_TYPE(format);
info.media_subtype = SPA_FORMAT_MEDIA_SUBTYPE(format);
if (info.media_type != this->type.media_type.video) {
if (info.media_type != t->media_type.video) {
spa_log_error(this->log, "media type must be video");
return SPA_RESULT_INVALID_MEDIA_TYPE;
}
if (info.media_subtype == this->type.media_subtype.raw) {
if (!spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video)) {
if (info.media_subtype == t->media_subtype.raw) {
if (spa_format_video_raw_parse(format, &info.info.raw, &t->format_video) < 0) {
spa_log_error(this->log, "can't parse video raw");
return SPA_RESULT_INVALID_MEDIA_TYPE;
}
@ -492,8 +479,8 @@ static int impl_node_port_set_format(struct spa_node *node,
info.info.raw.size.width == state->current_format.info.raw.size.width &&
info.info.raw.size.height == state->current_format.info.raw.size.height)
return SPA_RESULT_OK;
} else if (info.media_subtype == this->type.media_subtype_video.mjpg) {
if (!spa_format_video_mjpg_parse(format, &info.info.mjpg, &this->type.format_video))
} else if (info.media_subtype == t->media_subtype_video.mjpg) {
if (spa_format_video_mjpg_parse(format, &info.info.mjpg, &t->format_video) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (state->have_format && info.media_type == state->current_format.media_type &&
@ -501,8 +488,8 @@ static int impl_node_port_set_format(struct spa_node *node,
info.info.mjpg.size.width == state->current_format.info.mjpg.size.width &&
info.info.mjpg.size.height == state->current_format.info.mjpg.size.height)
return SPA_RESULT_OK;
} else if (info.media_subtype == this->type.media_subtype_video.h264) {
if (!spa_format_video_h264_parse(format, &info.info.h264, &this->type.format_video))
} else if (info.media_subtype == t->media_subtype_video.h264) {
if (spa_format_video_h264_parse(format, &info.info.h264, &t->format_video) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (state->have_format && info.media_type == state->current_format.media_type &&
@ -537,12 +524,14 @@ static int impl_node_port_get_format(struct spa_node *node,
struct impl *this;
struct port *state;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct spa_pod_frame f[1];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -554,36 +543,28 @@ static int impl_node_port_get_format(struct spa_node *node,
b.data = state->format_buffer;
b.size = sizeof(state->format_buffer);
spa_pod_builder_push_format(&b, &f[0], this->type.format,
spa_pod_builder_push_format(&b, &f[0], t->format,
state->current_format.media_type,
state->current_format.media_subtype);
if (state->current_format.media_subtype == this->type.media_subtype.raw) {
if (state->current_format.media_subtype == t->media_subtype.raw) {
spa_pod_builder_add(&b,
PROP(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID,
state->current_format.info.raw.format),
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
&state->current_format.info.raw.size),
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
&state->current_format.info.raw.framerate), 0);
} else if (state->current_format.media_subtype == this->type.media_subtype_video.mjpg ||
state->current_format.media_subtype == this->type.media_subtype_video.jpeg) {
":", t->format_video.format, "I", state->current_format.info.raw.format,
":", t->format_video.size, "R", &state->current_format.info.raw.size,
":", t->format_video.framerate, "F", &state->current_format.info.raw.framerate, 0);
} else if (state->current_format.media_subtype == t->media_subtype_video.mjpg ||
state->current_format.media_subtype == t->media_subtype_video.jpeg) {
spa_pod_builder_add(&b,
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
&state->current_format.info.mjpg.size),
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
&state->current_format.info.mjpg.framerate), 0);
} else if (state->current_format.media_subtype == this->type.media_subtype_video.h264) {
":", t->format_video.size, "R", &state->current_format.info.mjpg.size,
":", t->format_video.framerate, "F", &state->current_format.info.mjpg.framerate, 0);
} else if (state->current_format.media_subtype == t->media_subtype_video.h264) {
spa_pod_builder_add(&b,
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
&state->current_format.info.h264.size),
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
&state->current_format.info.h264.framerate), 0);
":", t->format_video.size, "R", &state->current_format.info.h264.size,
":", t->format_video.framerate, "F", &state->current_format.info.h264.framerate, 0);
} else
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_pop(&b, &f[0]);
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
return SPA_RESULT_OK;
@ -618,12 +599,13 @@ static int impl_node_port_enum_params(struct spa_node *node,
struct impl *this;
struct port *state;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -633,30 +615,23 @@ static int impl_node_port_enum_params(struct spa_node *node,
switch (index) {
case 0:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
state->fmt.fmt.pix.sizeimage),
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
state->fmt.fmt.pix.bytesperline),
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
MAX_BUFFERS, 2, MAX_BUFFERS),
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
*param = spa_pod_builder_param(&b, t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "i", state->fmt.fmt.pix.sizeimage,
":", t->param_alloc_buffers.stride, "i", state->fmt.fmt.pix.bytesperline,
":", t->param_alloc_buffers.buffers, "iru", MAX_BUFFERS,
2, 2, MAX_BUFFERS,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b, t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}

View file

@ -680,12 +680,11 @@ spa_v4l2_enum_format(struct impl *this,
if (media_subtype == this->type.media_subtype.raw) {
spa_pod_builder_add(&b,
PROP(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID,
video_format), 0);
":", this->type.format_video.format, "I", video_format, 0);
}
spa_pod_builder_add(&b,
PROP(&f[1], this->type.format_video.size, SPA_POD_TYPE_RECTANGLE,
state->frmsize.discrete.width, state->frmsize.discrete.height), 0);
":", this->type.format_video.size, "R", &SPA_RECTANGLE(state->frmsize.discrete.width,
state->frmsize.discrete.height), 0);
spa_pod_builder_push_prop(&b, &f[1], this->type.format_video.framerate,
SPA_POD_PROP_RANGE_NONE | SPA_POD_PROP_FLAG_UNSET);

View file

@ -153,40 +153,25 @@ static void reset_props(struct impl *this, struct props *props)
props->pattern = this->type.DEFAULT_PATTERN;
}
#define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP(&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL,
this->props.live),
PROP_EN(&f[1], this->type.prop_pattern, SPA_POD_TYPE_ID, 3,
this->props.pattern,
this->type.pattern_smpte_snow,
this->type.pattern_snow));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b,
t->props,
":", t->prop_live, "b", this->props.live,
":", t->prop_pattern, "Ie", this->props.pattern,
2, t->pattern_smpte_snow,
t->pattern_snow);
return SPA_RESULT_OK;
}
@ -194,18 +179,20 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
{
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (props == NULL) {
reset_props(this, &this->props);
} else {
spa_props_query(props,
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
this->type.prop_pattern, SPA_POD_TYPE_ID, &this->props.pattern,
0);
spa_props_parse(props,
":", t->prop_live, "?b", &this->props.live,
":", t->prop_pattern, "?I", &this->props.pattern,
NULL);
}
if (this->props.live)
@ -433,13 +420,14 @@ impl_node_port_enum_formats(struct spa_node *node,
struct spa_format *fmt;
uint8_t buffer[256];
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
uint32_t count, match;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -450,26 +438,22 @@ impl_node_port_enum_formats(struct spa_node *node,
switch (count++) {
case 0:
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.video,
this->type.media_subtype.raw,
PROP_U_EN(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID, 3,
this->type.video_format.RGB,
this->type.video_format.RGB,
this->type.video_format.UYVY),
PROP_U_MM(&f[1], this->type.format_video.size, SPA_POD_TYPE_RECTANGLE,
320, 240,
1, 1,
INT32_MAX, INT32_MAX),
PROP_U_MM(&f[1], this->type.format_video.framerate, SPA_POD_TYPE_FRACTION,
25, 1,
0, 1,
INT32_MAX, 1));
fmt = spa_pod_builder_format(&b,
t->format,
t->media_type.video, t->media_subtype.raw,
":", t->format_video.format, "Ieu", t->video_format.RGB,
2, t->video_format.RGB,
t->video_format.UYVY,
":", t->format_video.size, "Rru", &SPA_RECTANGLE(320, 240),
2, &SPA_RECTANGLE(1, 1),
&SPA_RECTANGLE(INT32_MAX, INT32_MAX),
":", t->format_video.framerate, "Fru", &SPA_FRACTION(25,1),
2, &SPA_FRACTION(0, 1),
&SPA_FRACTION(INT32_MAX, 1));
break;
default:
return SPA_RESULT_ENUM_END;
}
fmt = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
@ -520,7 +504,7 @@ impl_node_port_set_format(struct spa_node *node,
info.media_subtype != this->type.media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video))
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (info.info.raw.format == this->type.video_format.RGB)
@ -550,12 +534,13 @@ impl_node_port_get_format(struct spa_node *node,
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -563,17 +548,12 @@ impl_node_port_get_format(struct spa_node *node,
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.video,
this->type.media_subtype.raw,
PROP(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID,
this->current_format.info.raw.format),
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
&this->current_format.info.raw.size),
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
&this->current_format.info.raw.framerate));
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
*format = spa_pod_builder_format(&b,
t->format,
t->media_type.video, t->media_subtype.raw,
":", t->format_video.format, "I", this->current_format.info.raw.format,
":", t->format_video.size, "R", &this->current_format.info.raw.size,
":", t->format_video.framerate, "F", &this->current_format.info.raw.framerate);
return SPA_RESULT_OK;
}
@ -607,12 +587,13 @@ impl_node_port_enum_params(struct spa_node *node,
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -622,31 +603,26 @@ impl_node_port_enum_params(struct spa_node *node,
case 0: {
struct spa_video_info_raw *raw_info = &this->current_format.info.raw;
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
this->stride * raw_info->size.height),
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
this->stride),
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
2, 1, 32),
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
16));
*param = spa_pod_builder_param(&b,
t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "i", this->stride * raw_info->size.height,
":", t->param_alloc_buffers.stride, "i", this->stride,
":", t->param_alloc_buffers.buffers, "ir", 2,
2, 1, 32,
":", t->param_alloc_buffers.align, "i", 16);
break;
}
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}

View file

@ -135,38 +135,23 @@ static void reset_props(struct props *props)
props->mute = DEFAULT_MUTE;
}
#define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
#define PROP_U_EN(f,key,type,n,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
spa_pod_builder_props(&b, &f[0], this->type.props,
PROP_MM(&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE,
this->props.volume,
0.0, 10.0),
PROP(&f[1], this->type.prop_mute, SPA_POD_TYPE_BOOL,
this->props.mute));
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
*props = spa_pod_builder_props(&b,
t->props,
":", t->prop_volume, "dr", this->props.volume, 2, 0.0, 10.0,
":", t->prop_mute, "b", this->props.mute);
return SPA_RESULT_OK;
}
@ -174,17 +159,19 @@ static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
{
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (props == NULL) {
reset_props(&this->props);
} else {
spa_props_query(props,
this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
this->type.prop_mute, SPA_POD_TYPE_BOOL, &this->props.mute, 0);
spa_props_parse(props,
":", t->prop_volume, "?d", &this->props.volume,
":", t->prop_mute, "?b", &this->props.mute, NULL);
}
return SPA_RESULT_OK;
}
@ -288,13 +275,14 @@ impl_node_port_enum_formats(struct spa_node *node,
struct spa_format *fmt;
uint8_t buffer[1024];
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
uint32_t count, match;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -305,25 +293,19 @@ impl_node_port_enum_formats(struct spa_node *node,
switch (count++) {
case 0:
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP_U_EN(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID, 3,
this->type.audio_format.S16,
this->type.audio_format.S16,
this->type.audio_format.S32),
PROP_U_MM(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
44100,
1, INT32_MAX),
PROP_U_MM(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
2,
1, INT32_MAX));
fmt = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
":", t->format_audio.format, "Ieu", t->audio_format.S16,
2, t->audio_format.S16,
t->audio_format.S32,
":", t->format_audio.rate, "iru", 44100, 2, 1, INT32_MAX,
":", t->format_audio.channels,"iru", 2, 2, 1, INT32_MAX);
break;
default:
return SPA_RESULT_ENUM_END;
}
fmt = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
if ((res = spa_format_filter(fmt, filter, &b)) != SPA_RESULT_OK || match++ != index)
@ -375,7 +357,7 @@ impl_node_port_set_format(struct spa_node *node,
info.media_subtype != this->type.media_subtype.raw)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio))
if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
this->bpf = 2 * info.info.raw.channels;
@ -395,12 +377,13 @@ impl_node_port_get_format(struct spa_node *node,
struct impl *this;
struct port *port;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -411,16 +394,12 @@ impl_node_port_get_format(struct spa_node *node,
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
spa_pod_builder_format(&b, &f[0], this->type.format,
this->type.media_type.audio,
this->type.media_subtype.raw,
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
this->current_format.info.raw.format),
PROP(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
this->current_format.info.raw.rate),
PROP(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
this->current_format.info.raw.channels));
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
*format = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
":", t->format_audio.format, "I", this->current_format.info.raw.format,
":", t->format_audio.rate, "i", this->current_format.info.raw.rate,
":", t->format_audio.channels, "i", this->current_format.info.raw.channels);
return SPA_RESULT_OK;
}
@ -456,14 +435,15 @@ impl_node_port_enum_params(struct spa_node *node,
struct spa_param **param)
{
struct spa_pod_builder b = { NULL };
struct spa_pod_frame f[2];
struct impl *this;
struct port *port;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -474,31 +454,28 @@ impl_node_port_enum_params(struct spa_node *node,
switch (index) {
case 0:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP_U_MM(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
1024 * this->bpf,
16 * this->bpf,
INT32_MAX / this->bpf),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
2, 1, MAX_BUFFERS),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
*param = spa_pod_builder_param(&b,
t->param_alloc_buffers.Buffers,
":", t->param_alloc_buffers.size, "iru", 1024 * this->bpf,
2, 16 * this->bpf,
INT32_MAX / this->bpf,
":", t->param_alloc_buffers.stride, "i", 0,
":", t->param_alloc_buffers.buffers, "iru", 2,
2, 1, MAX_BUFFERS,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
this->type.meta.Header),
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
sizeof(struct spa_meta_header)));
*param = spa_pod_builder_param(&b,
t->param_alloc_meta_enable.MetaEnable,
":", t->param_alloc_meta_enable.type, "I", t->meta.Header,
":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}