mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pod: improve parser and builder
Remove the spa_pod_iter helpers Remove builder/parser vararg recurse option, you have to manually recurse into structures when needed. This simplifies things a lot. Pass spa_pod_frames to builder and parser explicitly, we don't have to keep an internal stack anymore. The parser is now almost a mirror image of the builder. Make the parser safer when iterating over objects, add functions to check and get pod contents in a safe way. Make the builder return errno style results on errors Improve performance of object properties when they are stored and retrieved in the same order. Add many more tests for the builder and parser Add some benchmarks
This commit is contained in:
parent
878ae769ef
commit
351fb9ce29
36 changed files with 1605 additions and 973 deletions
|
|
@ -344,12 +344,13 @@ static int port_enum_formats(struct spa_node *node,
|
|||
}
|
||||
else if (other->have_format) {
|
||||
struct spa_audio_info info;
|
||||
struct spa_pod_frame f;
|
||||
|
||||
info = other->format;
|
||||
|
||||
qsort(info.info.raw.position, info.info.raw.channels, sizeof(uint32_t), int32_cmp);
|
||||
|
||||
spa_pod_builder_push_object(builder,
|
||||
spa_pod_builder_push_object(builder, &f,
|
||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
|
|
@ -367,7 +368,7 @@ static int port_enum_formats(struct spa_node *node,
|
|||
spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id,
|
||||
info.info.raw.channels, info.info.raw.position);
|
||||
}
|
||||
*param = spa_pod_builder_pop(builder);
|
||||
*param = spa_pod_builder_pop(builder, &f);
|
||||
} else {
|
||||
*param = spa_pod_builder_add_object(builder,
|
||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||
|
|
|
|||
|
|
@ -327,13 +327,14 @@ static int port_enum_formats(struct spa_node *node,
|
|||
{
|
||||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct port *other;
|
||||
struct spa_pod_frame f;
|
||||
|
||||
other = GET_PORT(this, SPA_DIRECTION_REVERSE(direction), 0);
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
if (other->have_format) {
|
||||
spa_pod_builder_push_object(builder,
|
||||
spa_pod_builder_push_object(builder, &f,
|
||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
|
|
@ -346,7 +347,7 @@ static int port_enum_formats(struct spa_node *node,
|
|||
spa_pod_builder_prop(builder, SPA_FORMAT_AUDIO_position, 0);
|
||||
spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id,
|
||||
other->format.info.raw.channels, other->format.info.raw.position);
|
||||
*param = spa_pod_builder_pop(builder);
|
||||
*param = spa_pod_builder_pop(builder, &f);
|
||||
} else {
|
||||
*param = spa_pod_builder_add_object(builder,
|
||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue