More type cleanups

SPA_ID_* -> SPA_TYPE_*. We use 'type' for all registered types.
ID refers to either a registered type or an enum.
Improve introspection of object ids. Make 0 an invalid enum and
use it to look up the object id type.
Move some type-info files together.
Swap type and id of the object, we first specify the type and then
the id because the meaning of the id depends on the object type.
This commit is contained in:
Wim Taymans 2018-08-27 15:03:11 +02:00
parent 281b65934e
commit 90c1a95eef
117 changed files with 1198 additions and 1272 deletions

View file

@ -113,7 +113,7 @@ int main(int argc, char *argv[])
data.remote = pw_stream_get_remote(data.stream);
params[0] = spa_pod_builder_object(&b,
SPA_PARAM_EnumFormat, SPA_ID_OBJECT_Format,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
"I", SPA_MEDIA_TYPE_audio,
"I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32,

View file

@ -218,7 +218,7 @@ static int port_get_format(struct spa_node *node,
return 0;
*result = spa_pod_builder_object(builder,
SPA_PARAM_Format, SPA_ID_OBJECT_Format,
SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
"I", SPA_MEDIA_TYPE_video,
"I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_VIDEO_format, "I", d->format.format,
@ -251,7 +251,7 @@ static int impl_port_enum_params(struct spa_node *node,
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamList,
SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", list[*index]);
else
return 0;
@ -268,7 +268,7 @@ static int impl_port_enum_params(struct spa_node *node,
return 0;
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamBuffers,
SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 2,
SPA_POD_PROP_MIN_MAX(2, MAX_BUFFERS),
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
@ -281,13 +281,13 @@ static int impl_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header,
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
break;
case 1:
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_VideoDamage,
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_region));
break;

View file

@ -181,7 +181,7 @@ static int port_enum_formats(struct spa_node *node,
return 0;
*param = spa_pod_builder_object(builder,
SPA_PARAM_EnumFormat, SPA_ID_OBJECT_Format,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
"I", SPA_MEDIA_TYPE_audio,
"I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_S16,
@ -216,7 +216,7 @@ static int port_get_format(struct spa_node *node,
return 0;
*param = spa_pod_builder_object(builder,
SPA_PARAM_Format, SPA_ID_OBJECT_Format,
SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
"I", SPA_MEDIA_TYPE_audio,
"I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_AUDIO_format, "I", d->format.format,
@ -249,7 +249,7 @@ static int impl_port_enum_params(struct spa_node *node,
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamList,
SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", list[*index]);
else
return 0;
@ -266,7 +266,7 @@ static int impl_port_enum_params(struct spa_node *node,
return 0;
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamBuffers,
SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1,
SPA_POD_PROP_MIN_MAX(1, 32),
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
@ -279,7 +279,7 @@ static int impl_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header,
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
break;
@ -291,7 +291,7 @@ static int impl_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
param = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamIO,
SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers,
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers));
break;

View file

@ -60,7 +60,7 @@ static int make_node(struct data *data)
data->node = pw_factory_create_object(factory,
NULL,
PW_ID_INTERFACE_Node,
PW_TYPE_INTERFACE_Node,
PW_VERSION_NODE,
props, SPA_ID_INVALID);

View file

@ -225,7 +225,7 @@ static int port_enum_formats(struct spa_node *node,
SDL_GetRendererInfo(d->renderer, &info);
spa_pod_builder_push_object(builder, SPA_PARAM_EnumFormat, SPA_ID_OBJECT_Format);
spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_enum(builder, SPA_MEDIA_TYPE_video);
spa_pod_builder_enum(builder, SPA_MEDIA_SUBTYPE_raw);
@ -281,7 +281,7 @@ static int impl_port_enum_params(struct spa_node *node,
return 0;
*result = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamBuffers,
SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 2,
SPA_POD_PROP_MIN_MAX(1, 32),
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
@ -295,7 +295,7 @@ static int impl_port_enum_params(struct spa_node *node,
return 0;
*result = spa_pod_builder_object(builder,
id, SPA_ID_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamMeta, id,
":", SPA_PARAM_META_type, "I", SPA_META_Header,
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
break;
@ -458,7 +458,7 @@ static void make_nodes(struct data *data)
"spa.factory.name", "v4l2-source", NULL);
data->v4l2 = pw_factory_create_object(factory,
NULL,
PW_ID_INTERFACE_Node,
PW_TYPE_INTERFACE_Node,
PW_VERSION_NODE,
props,
SPA_ID_INVALID);

View file

@ -272,10 +272,10 @@ registry_global(void *data,uint32_t id, uint32_t parent_id,
clock_gettime(CLOCK_MONOTONIC, &impl->now);
if (type == PW_ID_INTERFACE_Node) {
if (type == PW_TYPE_INTERFACE_Node) {
handle_node(impl, id, parent_id, type, props);
}
else if (type == PW_ID_INTERFACE_Port) {
else if (type == PW_TYPE_INTERFACE_Port) {
handle_port(impl, id, parent_id, type, props);
}
schedule_rescan(impl);
@ -313,7 +313,7 @@ static void rescan_session(struct impl *impl)
sess->dsp = pw_core_proxy_create_object(impl->core_proxy,
"audio-dsp",
PW_ID_INTERFACE_Node,
PW_TYPE_INTERFACE_Node,
PW_VERSION_NODE,
&props->dict,
0);
@ -334,7 +334,7 @@ static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remo
case PW_REMOTE_STATE_CONNECTED:
impl->core_proxy = pw_remote_get_core_proxy(impl->remote);
impl->registry_proxy = pw_core_proxy_get_registry(impl->core_proxy,
PW_ID_INTERFACE_Registry,
PW_TYPE_INTERFACE_Registry,
PW_VERSION_REGISTRY, 0);
pw_registry_proxy_add_listener(impl->registry_proxy,
&impl->registry_listener,

View file

@ -97,7 +97,7 @@ static struct spa_pod *sdl_build_formats(SDL_RendererInfo *info, struct spa_pod_
{
int i, c;
spa_pod_builder_push_object(b, SPA_PARAM_EnumFormat, SPA_ID_OBJECT_Format);
spa_pod_builder_push_object(b, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_enum(b, SPA_MEDIA_TYPE_video);
spa_pod_builder_enum(b, SPA_MEDIA_SUBTYPE_raw);

View file

@ -169,7 +169,7 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
SDL_UnlockTexture(data->texture);
params[0] = spa_pod_builder_object(&b,
SPA_PARAM_Buffers, SPA_ID_OBJECT_ParamBuffers,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
":", SPA_PARAM_BUFFERS_buffers, "iru", 8,
SPA_POD_PROP_MIN_MAX(2, 16),
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
@ -178,7 +178,7 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
":", SPA_PARAM_BUFFERS_align, "i", 16);
params[1] = spa_pod_builder_object(&b,
SPA_PARAM_Meta, SPA_ID_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_Header,
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));

View file

@ -168,7 +168,7 @@ 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,
SPA_PARAM_Buffers, SPA_ID_OBJECT_ParamBuffers,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
":", SPA_PARAM_BUFFERS_buffers, "iru", 2,
SPA_POD_PROP_MIN_MAX(1, 32),
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
@ -177,12 +177,12 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
":", SPA_PARAM_BUFFERS_align, "i", 16);
params[1] = spa_pod_builder_object(&b,
SPA_PARAM_Meta, SPA_ID_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_Header,
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
params[2] = spa_pod_builder_object(&b,
SPA_PARAM_Meta, SPA_ID_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
":", SPA_PARAM_META_type, "I", SPA_META_VideoDamage,
":", SPA_PARAM_META_size, "iru", sizeof(struct spa_meta_region) * 16,
SPA_POD_PROP_MIN_MAX(sizeof(struct spa_meta_region) * 1,
@ -223,7 +223,7 @@ static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remo
NULL));
params[0] = spa_pod_builder_object(&b,
SPA_PARAM_EnumFormat, SPA_ID_OBJECT_Format,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
"I", SPA_MEDIA_TYPE_video,
"I", SPA_MEDIA_SUBTYPE_raw,
":", SPA_FORMAT_VIDEO_format, "I", SPA_VIDEO_FORMAT_RGB,