pod: improve the vararg pod builder and parser

Automatically parse and build key/value when in objects without having
to prefix the key with ":"
Automatically build control/value when in sequence without the "."
prefix.
Remove the builder with key/pod, taking a reference to the stack built
temporary pods is not allowed in c++. We can use the varargs version
with the same convenient syntax.
Remove the parser "*" option, it is unused.
Improve spa_pod_builder_add_* and spa_pod_parser_get_* and make them
look similar.
This commit is contained in:
Wim Taymans 2019-01-16 11:05:12 +01:00
parent 79d68ace68
commit 80cfda89c1
59 changed files with 1833 additions and 2005 deletions

View file

@ -245,10 +245,9 @@ static int impl_port_enum_params(struct spa_node *node,
SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
SPA_PARAM_LIST_id, SPA_POD_Id(list[*index]));
else
return 0;
break;
@ -266,31 +265,28 @@ static int impl_port_enum_params(struct spa_node *node,
if (*index != 0)
return 0;
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamBuffers, id,
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 2, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(d->stride * d->format.size.height),
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(d->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(2, 2, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(d->stride * d->format.size.height),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(d->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
break;
case SPA_PARAM_Meta:
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
break;
case 1:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoDamage),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_region)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoDamage),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_region)));
break;
default:
return 0;
@ -300,18 +296,16 @@ static int impl_port_enum_params(struct spa_node *node,
case SPA_PARAM_IO:
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_buffers)));
break;
case 1:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
0);
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Notify),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024));
break;
default:
return 0;

View file

@ -181,19 +181,18 @@ static int port_enum_formats(struct spa_node *node,
if (*index != 0)
return 0;
*param = spa_pod_builder_object(builder,
*param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(5,
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
SPA_FORMAT_AUDIO_format, SPA_POD_CHOICE_ENUM_Id(5,
SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S16P,
SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_F32P,
SPA_AUDIO_FORMAT_F32),
SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
0);
SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
SPA_FORMAT_AUDIO_rate, SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX));
(*index)++;
@ -220,10 +219,9 @@ static int impl_port_enum_params(struct spa_node *node,
SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
SPA_PARAM_LIST_id, SPA_POD_Id(list[*index]));
else
return 0;
break;
@ -243,24 +241,22 @@ static int impl_port_enum_params(struct spa_node *node,
if (*index > 0)
return 0;
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamBuffers, id,
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, 32),
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(BUFFER_SAMPLES * sizeof(float), 32, 4096),
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, 32),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(BUFFER_SAMPLES * sizeof(float), 32, 4096),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(0),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
break;
case SPA_PARAM_Meta:
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
break;
default:
return 0;
@ -269,18 +265,16 @@ static int impl_port_enum_params(struct spa_node *node,
case SPA_PARAM_IO:
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_buffers)));
break;
case 1:
param = spa_pod_builder_object(builder,
param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
0);
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Notify),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024));
break;
default:
return 0;

View file

@ -180,25 +180,23 @@ static int impl_port_enum_params(struct spa_node *node,
if (*index > 0)
return 0;
*result = spa_pod_builder_object(builder,
*result = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamBuffers, id,
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(d->stride * d->format.size.height),
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(d->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(d->stride * d->format.size.height),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(d->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
break;
case SPA_PARAM_Meta:
if (*index > 0)
return 0;
*result = spa_pod_builder_object(builder,
*result = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamMeta, id,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
break;
default:

View file

@ -934,11 +934,10 @@ static void stream_set_volume(struct impl *impl, struct node *node, float volume
pw_node_proxy_set_param((struct pw_node_proxy*)node->obj.proxy,
SPA_PARAM_Props, 0,
spa_pod_builder_object(&b,
spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_Props, SPA_PARAM_Props,
SPA_PROP_volume, &SPA_POD_Float(volume),
SPA_PROP_mute, &SPA_POD_Bool(mute),
0));
SPA_PROP_volume, SPA_POD_Float(volume),
SPA_PROP_mute, SPA_POD_Bool(mute)));
}
static int rescan_node(struct impl *impl, struct node *node)
@ -1148,12 +1147,11 @@ do_link_profile:
node->profile_format = audio_info;
spa_pod_builder_init(&b, buf, sizeof(buf));
param = spa_pod_builder_object(&b,
param = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &audio_info);
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamProfile, SPA_PARAM_Profile,
SPA_PARAM_PROFILE_direction, &SPA_POD_Id(pw_direction_reverse(direction)),
SPA_PARAM_PROFILE_format, spa_format_audio_raw_build(&b,
SPA_PARAM_Format, &audio_info),
0);
SPA_PARAM_PROFILE_direction, SPA_POD_Id(pw_direction_reverse(direction)),
SPA_PARAM_PROFILE_format, SPA_POD_Pod(param));
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_pod(2, NULL, param);
@ -1241,11 +1239,10 @@ static void rescan_session(struct impl *impl, struct session *sess)
spa_pod_builder_init(&b, buf, sizeof(buf));
param = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &info);
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamProfile, SPA_PARAM_Profile,
SPA_PARAM_PROFILE_direction, &SPA_POD_Id(pw_direction_reverse(sess->direction)),
SPA_PARAM_PROFILE_format, param,
0);
SPA_PARAM_PROFILE_direction, SPA_POD_Id(pw_direction_reverse(sess->direction)),
SPA_PARAM_PROFILE_format, SPA_POD_Pod(param));
pw_node_proxy_set_param((struct pw_node_proxy*)sess->dsp_proxy,
SPA_PARAM_Profile, 0, param);

View file

@ -124,16 +124,16 @@ static struct spa_pod *sdl_build_formats(SDL_RendererInfo *info, struct spa_pod_
spa_pod_builder_id(b, id);
}
spa_pod_builder_pop(b);
spa_pod_builder_props(b,
SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
SPA_RECTANGLE(WIDTH, HEIGHT),
SPA_RECTANGLE(1,1),
SPA_RECTANGLE(info->max_texture_width,
spa_pod_builder_add(b,
SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE(WIDTH, HEIGHT),
&SPA_RECTANGLE(1,1),
&SPA_RECTANGLE(info->max_texture_width,
info->max_texture_height)),
SPA_FORMAT_VIDEO_framerate, &SPA_POD_CHOICE_RANGE_Fraction(
SPA_FRACTION(25,1),
SPA_FRACTION(0,1),
SPA_FRACTION(30,1)),
SPA_FORMAT_VIDEO_framerate, SPA_POD_CHOICE_RANGE_Fraction(
&SPA_FRACTION(25,1),
&SPA_FRACTION(0,1),
&SPA_FRACTION(30,1)),
0);
return spa_pod_builder_pop(b);
}

View file

@ -238,35 +238,31 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
data->rect.w = data->format.size.width;
data->rect.h = data->format.size.height;
params[0] = spa_pod_builder_object(&b,
params[0] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(8, 2, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(data->stride * data->format.size.height),
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(data->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(8, 2, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(data->stride * data->format.size.height),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(data->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
params[1] = spa_pod_builder_object(&b,
params[1] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
params[2] = spa_pod_builder_object(&b,
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
params[2] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoCrop),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_region)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoCrop),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_region)));
#define CURSOR_META_SIZE(w,h) (sizeof(struct spa_meta_cursor) + \
sizeof(struct spa_meta_bitmap) + w * h * 4)
params[3] = spa_pod_builder_object(&b,
params[3] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Cursor),
SPA_PARAM_META_size, &SPA_POD_CHOICE_RANGE_Int(
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Cursor),
SPA_PARAM_META_size, SPA_POD_CHOICE_RANGE_Int(
CURSOR_META_SIZE(64,64),
CURSOR_META_SIZE(1,1),
CURSOR_META_SIZE(256,256)),
0);
CURSOR_META_SIZE(256,256)));
pw_stream_finish_format(stream, 0, params, 4);
}

View file

@ -224,42 +224,37 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
data->stride = SPA_ROUND_UP_N(data->format.size.width * BPP, 4);
params[0] = spa_pod_builder_object(&b,
params[0] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(data->stride * data->format.size.height),
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(data->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(data->stride * data->format.size.height),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(data->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
params[1] = spa_pod_builder_object(&b,
params[1] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
params[2] = spa_pod_builder_object(&b,
params[2] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoDamage),
SPA_PARAM_META_size, &SPA_POD_CHOICE_RANGE_Int(
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoDamage),
SPA_PARAM_META_size, SPA_POD_CHOICE_RANGE_Int(
sizeof(struct spa_meta_region) * 16,
sizeof(struct spa_meta_region) * 1,
sizeof(struct spa_meta_region) * 16),
0);
params[3] = spa_pod_builder_object(&b,
sizeof(struct spa_meta_region) * 16));
params[3] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoCrop),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_region)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoCrop),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_region)));
#define CURSOR_META_SIZE(w,h) (sizeof(struct spa_meta_cursor) + \
sizeof(struct spa_meta_bitmap) + w * h * CURSOR_BPP)
params[4] = spa_pod_builder_object(&b,
params[4] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Cursor),
SPA_PARAM_META_size, &SPA_POD_Int(
CURSOR_META_SIZE(CURSOR_WIDTH,CURSOR_HEIGHT)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Cursor),
SPA_PARAM_META_size, SPA_POD_Int(
CURSOR_META_SIZE(CURSOR_WIDTH,CURSOR_HEIGHT)));
pw_stream_finish_format(stream, 0, params, 5);
}
@ -295,30 +290,16 @@ static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remo
"media.class", "Video/Source",
NULL));
#if 0
params[0] = spa_pod_builder_object(&b,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_video),
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
SPA_FORMAT_VIDEO_format, &SPA_POD_Id(SPA_VIDEO_FORMAT_RGB),
SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
SPA_RECTANGLE(320, 240),
SPA_RECTANGLE(1, 1),
SPA_RECTANGLE(4096, 4096)),
SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(SPA_FRACTION(25, 1)),
0);
#else
params[0] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video,
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_VIDEO_format, "I", SPA_VIDEO_FORMAT_RGB,
":", SPA_FORMAT_VIDEO_size, "?rR", 3,
&SPA_RECTANGLE(320, 240),
&SPA_RECTANGLE(1, 1),
&SPA_RECTANGLE(4096, 4096),
":", SPA_FORMAT_VIDEO_framerate, "F", &SPA_FRACTION(25, 1));
#endif
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
SPA_FORMAT_VIDEO_format, SPA_POD_Id(SPA_VIDEO_FORMAT_RGB),
SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE(320, 240),
&SPA_RECTANGLE(1, 1),
&SPA_RECTANGLE(4096, 4096)),
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&SPA_FRACTION(25, 1)));
pw_stream_add_listener(data->stream,
&data->stream_listener,

View file

@ -237,25 +237,26 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink)
spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_push_object (&b, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers);
if (size == 0)
spa_pod_builder_props (&b,
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX), 0);
spa_pod_builder_add (&b,
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
0);
else
spa_pod_builder_props (&b,
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(size, size, INT32_MAX), 0);
spa_pod_builder_add (&b,
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(size, size, INT32_MAX),
0);
spa_pod_builder_props (&b,
SPA_PARAM_BUFFERS_stride, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(min_buffers, min_buffers,
spa_pod_builder_add (&b,
SPA_PARAM_BUFFERS_stride, SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(min_buffers, min_buffers,
max_buffers ? max_buffers : INT32_MAX),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16),
0);
port_params[0] = spa_pod_builder_pop (&b);
port_params[1] = spa_pod_builder_object (&b,
port_params[1] = spa_pod_builder_add_object (&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Int(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof (struct spa_meta_header)),
0);
SPA_PARAM_META_type, SPA_POD_Int(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof (struct spa_meta_header)));
pw_thread_loop_lock (sink->main_loop);

View file

@ -706,20 +706,18 @@ on_format_changed (void *data,
uint8_t buffer[512];
spa_pod_builder_init (&b, buffer, sizeof (buffer));
params[0] = spa_pod_builder_object (&b,
params[0] = spa_pod_builder_add_object (&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(16, 1, INT32_MAX),
SPA_PARAM_BUFFERS_blocks, &SPA_POD_CHOICE_RANGE_Int(0, 1, INT32_MAX),
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
SPA_PARAM_BUFFERS_stride, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(16, 1, INT32_MAX),
SPA_PARAM_BUFFERS_blocks, SPA_POD_CHOICE_RANGE_Int(0, 1, INT32_MAX),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
params[1] = spa_pod_builder_object (&b,
params[1] = spa_pod_builder_add_object (&b,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof (struct spa_meta_header)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof (struct spa_meta_header)));
GST_DEBUG_OBJECT (pwsrc, "doing finish format");
pw_stream_finish_format (pwsrc->stream, 0, params, 2);

View file

@ -336,14 +336,13 @@ static int port_enum_formats(struct spa_node *node,
*param = spa_format_audio_raw_build(builder, SPA_PARAM_EnumFormat,
&this->format.info.raw);
} else {
*param = spa_pod_builder_object(builder,
*param = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32P),
SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(1),
0);
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_F32P),
SPA_FORMAT_AUDIO_rate, SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
SPA_FORMAT_AUDIO_channels, SPA_POD_Int(1));
}
break;
default:
@ -390,10 +389,9 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO };
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
SPA_PARAM_LIST_id, SPA_POD_Id(list[*index]));
else
return 0;
break;
@ -418,17 +416,16 @@ impl_node_port_enum_params(struct spa_node *node,
if (*index > 0)
return 0;
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, id,
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
1024 * this->stride,
16 * this->stride,
INT32_MAX / this->stride),
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(this->stride),
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
0);
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
1024 * this->stride,
16 * this->stride,
INT32_MAX / this->stride),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(this->stride),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(16));
break;
case SPA_PARAM_Meta:
@ -437,11 +434,10 @@ impl_node_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamMeta, id,
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
0);
SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header),
SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header)));
break;
default:
return 0;
@ -451,25 +447,22 @@ impl_node_port_enum_params(struct spa_node *node,
case SPA_PARAM_IO:
switch (*index) {
case 0:
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0);
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_buffers)));
break;
case 1:
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
0);
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Range),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_range)));
break;
case 2:
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamIO, id,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0);
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Control),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_sequence)));
break;
default:
return 0;

View file

@ -138,10 +138,9 @@ static int impl_node_enum_params(struct spa_node *node,
SPA_PARAM_Format };
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
0);
SPA_PARAM_LIST_id, SPA_POD_Id(list[*index]));
else
return 0;
break;
@ -602,12 +601,12 @@ static int negotiate_buffers(struct impl *impl)
in_alloc = false;
}
if (spa_pod_object_parse(param,
":", SPA_PARAM_BUFFERS_buffers, "i", &buffers,
":", SPA_PARAM_BUFFERS_blocks, "i", &blocks,
":", SPA_PARAM_BUFFERS_size, "i", &size,
":", SPA_PARAM_BUFFERS_align, "i", &align,
NULL) < 0)
if (spa_pod_parse_object(param,
SPA_TYPE_OBJECT_ParamBuffers, NULL,
SPA_PARAM_BUFFERS_buffers, SPA_POD_Int(&buffers),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(&blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(&size),
SPA_PARAM_BUFFERS_align, SPA_POD_Int(&align)) < 0)
return -EINVAL;
spa_log_debug(this->log, "%p: buffers %d, blocks %d, size %d, align %d",

View file

@ -40,8 +40,8 @@ client_node_marshal_done(void *object, int seq, int res)
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DONE);
spa_pod_builder_add_struct(b,
"i", seq,
"i", res);
SPA_POD_Int(seq),
SPA_POD_Int(res));
pw_protocol_native_end_proxy(proxy, b);
}
@ -64,20 +64,21 @@ client_node_marshal_update(void *object,
spa_pod_builder_add(b,
"[",
"i", change_mask,
"i", max_input_ports,
"i", max_output_ports,
"i", n_params, NULL);
SPA_POD_Int(change_mask),
SPA_POD_Int(max_input_ports),
SPA_POD_Int(max_output_ports),
SPA_POD_Int(n_params), NULL);
for (i = 0; i < n_params; i++)
spa_pod_builder_add(b, "P", params[i], NULL);
spa_pod_builder_add(b, SPA_POD_Pod(params[i]), NULL);
n_items = props ? props->n_items : 0;
spa_pod_builder_add(b, "i", n_items, NULL);
spa_pod_builder_add(b,
SPA_POD_Int(n_items), NULL);
for (i = 0; i < n_items; i++) {
spa_pod_builder_add(b,
"s", props->items[i].key,
"s", props->items[i].value, NULL);
SPA_POD_String(props->items[i].key),
SPA_POD_String(props->items[i].value), NULL);
}
spa_pod_builder_add(b, "]", NULL);
@ -101,30 +102,33 @@ client_node_marshal_port_update(void *object,
spa_pod_builder_add(b,
"[",
"i", direction,
"i", port_id,
"i", change_mask,
"i", n_params, NULL);
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Int(change_mask),
SPA_POD_Int(n_params), NULL);
for (i = 0; i < n_params; i++)
spa_pod_builder_add(b, "P", params[i], NULL);
spa_pod_builder_add(b,
SPA_POD_Pod(params[i]), NULL);
if (info) {
n_items = info->props ? info->props->n_items : 0;
spa_pod_builder_add(b,
"[",
"i", info->flags,
"i", info->rate,
"i", n_items, NULL);
SPA_POD_Int(info->flags),
SPA_POD_Int(info->rate),
SPA_POD_Int(n_items), NULL);
for (i = 0; i < n_items; i++) {
spa_pod_builder_add(b,
"s", info->props->items[i].key,
"s", info->props->items[i].value, NULL);
SPA_POD_String(info->props->items[i].key),
SPA_POD_String(info->props->items[i].value), NULL);
}
spa_pod_builder_add(b, "]", NULL);
spa_pod_builder_add(b,
"]", NULL);
} else {
spa_pod_builder_add(b, "P", NULL, NULL);
spa_pod_builder_add(b,
SPA_POD_Pod(NULL), NULL);
}
spa_pod_builder_add(b, "]", NULL);
@ -138,7 +142,8 @@ static void client_node_marshal_set_active(void *object, bool active)
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_SET_ACTIVE);
spa_pod_builder_add_struct(b, "b", active);
spa_pod_builder_add_struct(b,
SPA_POD_Bool(active));
pw_protocol_native_end_proxy(proxy, b);
}
@ -150,7 +155,8 @@ static void client_node_marshal_event_method(void *object, struct spa_event *eve
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_EVENT);
spa_pod_builder_add_struct(b, "P", event);
spa_pod_builder_add_struct(b,
SPA_POD_Pod(event));
pw_protocol_native_end_proxy(proxy, b);
}
@ -163,12 +169,11 @@ static int client_node_demarshal_add_mem(void *object, void *data, size_t size)
int memfd;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &mem_id,
"I", &type,
"i", &memfd_idx,
"i", &flags, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&mem_id),
SPA_POD_Id(&type),
SPA_POD_Int(&memfd_idx),
SPA_POD_Int(&flags)) < 0)
return -EINVAL;
memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
@ -188,11 +193,10 @@ static int client_node_demarshal_transport(void *object, void *data, size_t size
int readfd, writefd;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &node_id,
"i", &ridx,
"i", &widx, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&node_id),
SPA_POD_Int(&ridx),
SPA_POD_Int(&widx)) < 0)
return -EINVAL;
readfd = pw_protocol_native_get_proxy_fd(proxy, ridx);
@ -214,12 +218,11 @@ static int client_node_demarshal_set_param(void *object, void *data, size_t size
const struct spa_pod *param = NULL;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"I", &id,
"i", &flags,
"O", &param, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Id(&id),
SPA_POD_Int(&flags),
SPA_POD_PodObject(&param)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, 0, seq, id, flags, param);
@ -233,7 +236,8 @@ static int client_node_demarshal_event_event(void *object, void *data, size_t si
const struct spa_event *event;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs, "[ O", &event, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_PodObject(&event)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, event, 0, event);
@ -248,10 +252,9 @@ static int client_node_demarshal_command(void *object, void *data, size_t size)
uint32_t seq;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"O", &command, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_PodObject(&command)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, 0, seq, command);
@ -265,11 +268,10 @@ static int client_node_demarshal_add_port(void *object, void *data, size_t size)
int32_t seq, direction, port_id;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"i", &direction,
"i", &port_id, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, 0, seq, direction, port_id);
@ -283,11 +285,10 @@ static int client_node_demarshal_remove_port(void *object, void *data, size_t si
int32_t seq, direction, port_id;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"i", &direction,
"i", &port_id, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, 0, seq, direction, port_id);
@ -302,14 +303,13 @@ static int client_node_demarshal_port_set_param(void *object, void *data, size_t
const struct spa_pod *param = NULL;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"i", &direction,
"i", &port_id,
"I", &id,
"i", &flags,
"O", &param, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_Id(&id),
SPA_POD_Int(&flags),
SPA_POD_PodObject(&param)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param, 0,
@ -328,11 +328,11 @@ static int client_node_demarshal_port_use_buffers(void *object, void *data, size
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"i", &direction,
"i", &port_id,
"i", &mix_id,
"i", &n_buffers, NULL) < 0)
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_Int(&mix_id),
SPA_POD_Int(&n_buffers), NULL) < 0)
return -EINVAL;
buffers = alloca(sizeof(struct pw_client_node_buffer) * n_buffers);
@ -340,10 +340,10 @@ static int client_node_demarshal_port_use_buffers(void *object, void *data, size
struct spa_buffer *buf = buffers[i].buffer = alloca(sizeof(struct spa_buffer));
if (spa_pod_parser_get(&prs,
"i", &buffers[i].mem_id,
"i", &buffers[i].offset,
"i", &buffers[i].size,
"i", &buf->n_metas, NULL) < 0)
SPA_POD_Int(&buffers[i].mem_id),
SPA_POD_Int(&buffers[i].offset),
SPA_POD_Int(&buffers[i].size),
SPA_POD_Int(&buf->n_metas), NULL) < 0)
return -EINVAL;
buf->metas = alloca(sizeof(struct spa_meta) * buf->n_metas);
@ -351,11 +351,12 @@ static int client_node_demarshal_port_use_buffers(void *object, void *data, size
struct spa_meta *m = &buf->metas[j];
if (spa_pod_parser_get(&prs,
"I", &m->type,
"i", &m->size, NULL) < 0)
SPA_POD_Id(&m->type),
SPA_POD_Int(&m->size), NULL) < 0)
return -EINVAL;
}
if (spa_pod_parser_get(&prs, "i", &buf->n_datas, NULL) < 0)
if (spa_pod_parser_get(&prs,
SPA_POD_Int(&buf->n_datas), NULL) < 0)
return -EINVAL;
buf->datas = alloca(sizeof(struct spa_data) * buf->n_datas);
@ -363,11 +364,11 @@ static int client_node_demarshal_port_use_buffers(void *object, void *data, size
struct spa_data *d = &buf->datas[j];
if (spa_pod_parser_get(&prs,
"I", &d->type,
"i", &data_id,
"i", &d->flags,
"i", &d->mapoffset,
"i", &d->maxsize, NULL) < 0)
SPA_POD_Id(&d->type),
SPA_POD_Int(&data_id),
SPA_POD_Int(&d->flags),
SPA_POD_Int(&d->mapoffset),
SPA_POD_Int(&d->maxsize), NULL) < 0)
return -EINVAL;
d->data = SPA_UINT32_TO_PTR(data_id);
@ -389,11 +390,10 @@ static int client_node_demarshal_port_command(void *object, void *data, size_t s
uint32_t direction, port_id;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &direction,
"i", &port_id,
"O", &command, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_PodObject(&command)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_command, 0, direction,
@ -409,16 +409,15 @@ static int client_node_demarshal_port_set_io(void *object, void *data, size_t si
uint32_t seq, direction, port_id, mix_id, id, memid, off, sz;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"i", &direction,
"i", &port_id,
"i", &mix_id,
"I", &id,
"i", &memid,
"i", &off,
"i", &sz, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_Int(&mix_id),
SPA_POD_Id(&id),
SPA_POD_Int(&memid),
SPA_POD_Int(&off),
SPA_POD_Int(&sz)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_io, 0,
@ -436,12 +435,11 @@ static int client_node_demarshal_set_io(void *object, void *data, size_t size)
uint32_t id, memid, off, sz;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"I", &id,
"i", &memid,
"i", &off,
"i", &sz, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Id(&id),
SPA_POD_Int(&memid),
SPA_POD_Int(&off),
SPA_POD_Int(&sz)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_io, 0,
@ -461,10 +459,10 @@ client_node_marshal_add_mem(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_MEM);
spa_pod_builder_add_struct(b,
"i", mem_id,
"I", type,
"i", pw_protocol_native_add_resource_fd(resource, memfd),
"i", flags);
SPA_POD_Int(mem_id),
SPA_POD_Id(type),
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, memfd)),
SPA_POD_Int(flags));
pw_protocol_native_end_resource(resource, b);
}
@ -477,9 +475,9 @@ static void client_node_marshal_transport(void *object, uint32_t node_id, int re
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT);
spa_pod_builder_add_struct(b,
"i", node_id,
"i", pw_protocol_native_add_resource_fd(resource, readfd),
"i", pw_protocol_native_add_resource_fd(resource, writefd));
SPA_POD_Int(node_id),
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, readfd)),
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, writefd)));
pw_protocol_native_end_resource(resource, b);
}
@ -494,10 +492,10 @@ client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM);
spa_pod_builder_add_struct(b,
"i", seq,
"I", id,
"i", flags,
"P", param);
SPA_POD_Int(seq),
SPA_POD_Id(id),
SPA_POD_Int(flags),
SPA_POD_Pod(param));
pw_protocol_native_end_resource(resource, b);
}
@ -509,7 +507,8 @@ static void client_node_marshal_event_event(void *object, const struct spa_event
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_EVENT);
spa_pod_builder_add_struct(b, "P", event);
spa_pod_builder_add_struct(b,
SPA_POD_Pod(event));
pw_protocol_native_end_resource(resource, b);
}
@ -522,7 +521,9 @@ client_node_marshal_command(void *object, uint32_t seq, const struct spa_command
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND);
spa_pod_builder_add_struct(b, "i", seq, "P", command);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Pod(command));
pw_protocol_native_end_resource(resource, b);
}
@ -537,9 +538,9 @@ client_node_marshal_add_port(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT);
spa_pod_builder_add_struct(b,
"i", seq,
"i", direction,
"i", port_id);
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id));
pw_protocol_native_end_resource(resource, b);
}
@ -554,9 +555,9 @@ client_node_marshal_remove_port(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT);
spa_pod_builder_add_struct(b,
"i", seq,
"i", direction,
"i", port_id);
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id));
pw_protocol_native_end_resource(resource, b);
}
@ -576,12 +577,12 @@ client_node_marshal_port_set_param(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM);
spa_pod_builder_add_struct(b,
"i", seq,
"i", direction,
"i", port_id,
"I", id,
"i", flags,
"P", param);
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Id(id),
SPA_POD_Int(flags),
SPA_POD_Pod(param));
pw_protocol_native_end_resource(resource, b);
}
@ -602,36 +603,37 @@ client_node_marshal_port_use_buffers(void *object,
spa_pod_builder_add(b,
"[",
"i", seq,
"i", direction,
"i", port_id,
"i", mix_id,
"i", n_buffers, NULL);
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Int(mix_id),
SPA_POD_Int(n_buffers), NULL);
for (i = 0; i < n_buffers; i++) {
struct spa_buffer *buf = buffers[i].buffer;
spa_pod_builder_add(b,
"i", buffers[i].mem_id,
"i", buffers[i].offset,
"i", buffers[i].size,
"i", buf->n_metas, NULL);
SPA_POD_Int(buffers[i].mem_id),
SPA_POD_Int(buffers[i].offset),
SPA_POD_Int(buffers[i].size),
SPA_POD_Int(buf->n_metas), NULL);
for (j = 0; j < buf->n_metas; j++) {
struct spa_meta *m = &buf->metas[j];
spa_pod_builder_add(b,
"I", m->type,
"i", m->size, NULL);
SPA_POD_Id(m->type),
SPA_POD_Int(m->size), NULL);
}
spa_pod_builder_add(b, "i", buf->n_datas, NULL);
spa_pod_builder_add(b,
SPA_POD_Int(buf->n_datas), NULL);
for (j = 0; j < buf->n_datas; j++) {
struct spa_data *d = &buf->datas[j];
spa_pod_builder_add(b,
"I", d->type,
"i", SPA_PTR_TO_UINT32(d->data),
"i", d->flags,
"i", d->mapoffset,
"i", d->maxsize, NULL);
SPA_POD_Id(d->type),
SPA_POD_Int(SPA_PTR_TO_UINT32(d->data)),
SPA_POD_Int(d->flags),
SPA_POD_Int(d->mapoffset),
SPA_POD_Int(d->maxsize), NULL);
}
}
spa_pod_builder_add(b, "]", NULL);
@ -651,9 +653,9 @@ client_node_marshal_port_command(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_COMMAND);
spa_pod_builder_add_struct(b,
"i", direction,
"i", port_id,
"P", command);
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Pod(command));
pw_protocol_native_end_resource(resource, b);
}
@ -675,14 +677,14 @@ client_node_marshal_port_set_io(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_IO);
spa_pod_builder_add_struct(b,
"i", seq,
"i", direction,
"i", port_id,
"i", mix_id,
"I", id,
"i", memid,
"i", offset,
"i", size);
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Int(mix_id),
SPA_POD_Id(id),
SPA_POD_Int(memid),
SPA_POD_Int(offset),
SPA_POD_Int(size));
pw_protocol_native_end_resource(resource, b);
}
@ -699,10 +701,10 @@ client_node_marshal_set_io(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_IO);
spa_pod_builder_add_struct(b,
"I", id,
"i", memid,
"i", offset,
"i", size);
SPA_POD_Id(id),
SPA_POD_Int(memid),
SPA_POD_Int(offset),
SPA_POD_Int(size));
pw_protocol_native_end_resource(resource, b);
}
@ -713,10 +715,9 @@ static int client_node_demarshal_done(void *object, void *data, size_t size)
uint32_t seq, res;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"i", &res, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&res)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_client_node_proxy_methods, done, 0, seq, res);
@ -735,27 +736,27 @@ static int client_node_demarshal_update(void *object, void *data, size_t size)
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &change_mask,
"i", &max_input_ports,
"i", &max_output_ports,
"i", &n_params, NULL) < 0)
SPA_POD_Int(&change_mask),
SPA_POD_Int(&max_input_ports),
SPA_POD_Int(&max_output_ports),
SPA_POD_Int(&n_params), NULL) < 0)
return -EINVAL;
params = alloca(n_params * sizeof(struct spa_pod *));
for (i = 0; i < n_params; i++)
if (spa_pod_parser_get(&prs, "O", &params[i], NULL) < 0)
if (spa_pod_parser_get(&prs,
SPA_POD_PodObject(&params[i]), NULL) < 0)
return -EINVAL;
if (spa_pod_parser_get(&prs,
"i", &props.n_items, NULL) < 0)
SPA_POD_Int(&props.n_items), NULL) < 0)
return -EINVAL;
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
for (i = 0; i < props.n_items; i++) {
if (spa_pod_parser_get(&prs,
"s", &props.items[i].key,
"s", &props.items[i].value,
NULL) < 0)
SPA_POD_String(&props.items[i].key),
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
@ -782,18 +783,20 @@ static int client_node_demarshal_port_update(void *object, void *data, size_t si
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &direction,
"i", &port_id,
"i", &change_mask,
"i", &n_params, NULL) < 0)
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_Int(&change_mask),
SPA_POD_Int(&n_params), NULL) < 0)
return -EINVAL;
params = alloca(n_params * sizeof(struct spa_pod *));
for (i = 0; i < n_params; i++)
if (spa_pod_parser_get(&prs, "O", &params[i], NULL) < 0)
if (spa_pod_parser_get(&prs,
SPA_POD_PodObject(&params[i]), NULL) < 0)
return -EINVAL;
if (spa_pod_parser_get(&prs, "T", &ipod, NULL) < 0)
if (spa_pod_parser_get(&prs,
SPA_POD_PodStruct(&ipod), NULL) < 0)
return -EINVAL;
if (ipod) {
@ -803,9 +806,9 @@ static int client_node_demarshal_port_update(void *object, void *data, size_t si
spa_pod_parser_pod(&p2, ipod);
if (spa_pod_parser_get(&p2,
"["
"i", &info.flags,
"i", &info.rate,
"i", &props.n_items, NULL) < 0)
SPA_POD_Int(&info.flags),
SPA_POD_Int(&info.rate),
SPA_POD_Int(&props.n_items), NULL) < 0)
return -EINVAL;
if (props.n_items > 0) {
@ -814,9 +817,8 @@ static int client_node_demarshal_port_update(void *object, void *data, size_t si
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
for (i = 0; i < props.n_items; i++) {
if (spa_pod_parser_get(&p2,
"s", &props.items[i].key,
"s", &props.items[i].value,
NULL) < 0)
SPA_POD_String(&props.items[i].key),
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
}
@ -837,9 +839,8 @@ static int client_node_demarshal_set_active(void *object, void *data, size_t siz
int active;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"b", &active, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Bool(&active)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_client_node_proxy_methods, set_active, 0, active);
@ -853,9 +854,8 @@ static int client_node_demarshal_event_method(void *object, void *data, size_t s
struct spa_event *event;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"O", &event, NULL) < 0)
if (spa_pod_parser_get_struct(&prs,
SPA_POD_PodObject(&event)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_client_node_proxy_methods, event, 0, event);

File diff suppressed because it is too large Load diff

View file

@ -80,16 +80,17 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
enum spa_monitor_item_state state;
struct spa_pod *info = NULL;
const struct spa_support *support;
uint32_t n_support, type;
uint32_t n_support, type, ftype;
if (spa_pod_object_parse(item,
":", SPA_MONITOR_ITEM_id, "s", &id,
":", SPA_MONITOR_ITEM_state, "I", &state,
":", SPA_MONITOR_ITEM_name, "s", &name,
":", SPA_MONITOR_ITEM_class, "s", &klass,
":", SPA_MONITOR_ITEM_factory, "p", &factory,
":", SPA_MONITOR_ITEM_type, "I", &type,
":", SPA_MONITOR_ITEM_info, "T", &info, NULL) < 0) {
if (spa_pod_parse_object(item,
SPA_TYPE_OBJECT_MonitorItem, NULL,
SPA_MONITOR_ITEM_id, SPA_POD_String(&id),
SPA_MONITOR_ITEM_state, SPA_POD_Id(&state),
SPA_MONITOR_ITEM_name, SPA_POD_String(&name),
SPA_MONITOR_ITEM_class, SPA_POD_String(&klass),
SPA_MONITOR_ITEM_factory, SPA_POD_Pointer(&ftype, &factory),
SPA_MONITOR_ITEM_type, SPA_POD_Id(&type),
SPA_MONITOR_ITEM_info, SPA_POD_Pod(&info)) < 0) {
pw_log_warn("monitor %p: could not parse item", this);
spa_debug_pod(0, NULL, item);
return NULL;
@ -195,9 +196,10 @@ static void remove_item(struct pw_spa_monitor *this, struct spa_pod *item, uint6
struct monitor_item *mitem;
const char *name, *id;
if (spa_pod_object_parse(item,
":", SPA_MONITOR_ITEM_name, "s", &name,
":", SPA_MONITOR_ITEM_id, "s", &id, NULL) < 0)
if (spa_pod_parse_object(item,
SPA_TYPE_OBJECT_MonitorItem, NULL,
SPA_MONITOR_ITEM_name, SPA_POD_String(&name),
SPA_MONITOR_ITEM_id, SPA_POD_String(&id)) < 0)
return;
pw_log_debug("monitor %p: remove: \"%s\" (%s)", this, name, id);
@ -212,10 +214,11 @@ static void change_item(struct pw_spa_monitor *this, struct spa_pod *item, uint6
const char *name, *id;
enum spa_monitor_item_state state;
if (spa_pod_object_parse(item,
":", SPA_MONITOR_ITEM_name, "s", &name,
":", SPA_MONITOR_ITEM_state, "I", &state,
":", SPA_MONITOR_ITEM_id, "s", &id, NULL) < 0)
if (spa_pod_parse_object(item,
SPA_TYPE_OBJECT_MonitorItem, NULL,
SPA_MONITOR_ITEM_name, SPA_POD_String(&name),
SPA_MONITOR_ITEM_state, SPA_POD_Id(&state),
SPA_MONITOR_ITEM_id, SPA_POD_String(&id)) < 0)
return;
pw_log_debug("monitor %p: change: \"%s\" (%s)", this, name, id);

View file

@ -442,9 +442,10 @@ static int alloc_buffers(struct pw_link *this,
if (spa_pod_is_object_type (params[i], SPA_TYPE_OBJECT_ParamMeta)) {
uint32_t type, size;
if (spa_pod_object_parse(params[i],
":", SPA_PARAM_META_type, "I", &type,
":", SPA_PARAM_META_size, "i", &size, NULL) < 0)
if (spa_pod_parse_object(params[i],
SPA_TYPE_OBJECT_ParamMeta, NULL,
SPA_PARAM_META_type, SPA_POD_Id(&type),
SPA_PARAM_META_size, SPA_POD_Int(&size)) < 0)
continue;
pw_log_debug("link %p: enable meta %d %d", this, type, size);
@ -724,10 +725,11 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
uint32_t qmax_buffers = max_buffers,
qminsize = minsize, qstride = stride;
spa_pod_object_parse(param,
":", SPA_PARAM_BUFFERS_size, "i", &qminsize,
":", SPA_PARAM_BUFFERS_stride, "i", &qstride,
":", SPA_PARAM_BUFFERS_buffers, "i", &qmax_buffers, NULL);
spa_pod_parse_object(param,
SPA_TYPE_OBJECT_ParamBuffers, NULL,
SPA_PARAM_BUFFERS_size, SPA_POD_Int(&qminsize),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(&qstride),
SPA_PARAM_BUFFERS_buffers, SPA_POD_Int(&qmax_buffers));
max_buffers =
qmax_buffers == 0 ? max_buffers : SPA_MIN(qmax_buffers,

View file

@ -389,9 +389,10 @@ static int check_param_io(void *data, uint32_t id, uint32_t index, uint32_t next
struct pw_node *node = port->node;
uint32_t pid, psize;
if (spa_pod_object_parse(param,
":", SPA_PARAM_IO_id, "I", &pid,
":", SPA_PARAM_IO_size, "i", &psize) < 0)
if (spa_pod_parse_object(param,
SPA_TYPE_OBJECT_ParamIO, NULL,
SPA_PARAM_IO_id, SPA_POD_Id(&pid),
SPA_PARAM_IO_size, SPA_POD_Int(&psize)) < 0)
return 0;
switch (pid) {

View file

@ -757,8 +757,9 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32
NULL, &param, &b) <= 0)
break;
spa_pod_object_parse(param,
":", SPA_PARAM_LIST_id, "I", &id, NULL);
spa_pod_parse_object(param,
SPA_TYPE_OBJECT_ParamList, NULL,
SPA_PARAM_LIST_id, SPA_POD_Id(&id));
params = realloc(params, sizeof(struct spa_pod *) * (n_params + 1));
params[n_params++] = pw_spa_pod_copy(param);

View file

@ -426,10 +426,9 @@ static int impl_port_enum_params(struct spa_node *node,
uint32_t new_id = ((struct spa_pod_object *) param)->body.id;
if (last_id == SPA_ID_INVALID){
*result = spa_pod_builder_object(builder,
*result = spa_pod_builder_add_object(builder,
SPA_TYPE_OBJECT_ParamList, id,
SPA_PARAM_LIST_id, &SPA_POD_Id(new_id),
0);
SPA_PARAM_LIST_id, SPA_POD_Id(new_id));
last_id = new_id;
}
else if (last_id != new_id) {
@ -1065,23 +1064,20 @@ static void add_controls(struct pw_stream *stream)
spa_pod_builder_init(&b, buffer, 4096);
add_param(stream, PARAM_TYPE_INIT,
spa_pod_builder_object(&b,
spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
0));
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Buffers),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_buffers))));
add_param(stream, PARAM_TYPE_INIT,
spa_pod_builder_object(&b,
spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
0));
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Notify),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024)));
add_param(stream, PARAM_TYPE_INIT,
spa_pod_builder_object(&b,
spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO,
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
0));
SPA_PARAM_IO_id, SPA_POD_Id(SPA_IO_Control),
SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_sequence))));
}
int