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

@ -327,7 +327,7 @@ static int port_enum_formats(struct spa_node *node,
case 0:
if (this->have_format) {
*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, "I", this->format.info.raw.format,
@ -335,7 +335,7 @@ static int port_enum_formats(struct spa_node *node,
":", SPA_FORMAT_AUDIO_channels, "i", this->format.info.raw.channels);
} else {
*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,
@ -368,7 +368,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", this->format.info.raw.format,
@ -416,7 +416,7 @@ impl_node_port_enum_params(struct spa_node *node,
SPA_PARAM_IO, };
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, id, SPA_ID_OBJECT_ParamList,
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id,
":", SPA_PARAM_LIST_id, "I", list[*index]);
else
return 0;
@ -437,7 +437,7 @@ impl_node_port_enum_params(struct spa_node *node,
return 0;
param = spa_pod_builder_object(&b,
id, SPA_ID_OBJECT_ParamBuffers,
SPA_TYPE_OBJECT_ParamBuffers, id,
":", SPA_PARAM_BUFFERS_buffers, "iru", 1,
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS),
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
@ -453,7 +453,7 @@ impl_node_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
param = spa_pod_builder_object(&b,
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;
@ -465,13 +465,13 @@ impl_node_port_enum_params(struct spa_node *node,
switch (*index) {
case 0:
param = spa_pod_builder_object(&b,
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;
case 1:
param = spa_pod_builder_object(&b,
id, SPA_ID_OBJECT_ParamIO,
SPA_TYPE_OBJECT_ParamIO, id,
":", SPA_PARAM_IO_id, "I", SPA_IO_ControlRange,
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_control_range));
break;
@ -971,7 +971,7 @@ static const struct spa_node impl_node = {
impl_node_process,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
{
struct impl *this;
@ -980,7 +980,7 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
this = (struct impl *) handle;
if (interface_id == SPA_ID_INTERFACE_Node)
if (type == SPA_TYPE_INTERFACE_Node)
*interface = &this->node;
else
return -ENOENT;
@ -1020,7 +1020,7 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
for (i = 0; i < n_support; i++) {
if (support[i].type == SPA_ID_INTERFACE_Log)
if (support[i].type == SPA_TYPE_INTERFACE_Log)
this->log = support[i].data;
}
@ -1039,7 +1039,7 @@ impl_init(const struct spa_handle_factory *factory,
}
static const struct spa_interface_info impl_interfaces[] = {
{SPA_ID_INTERFACE_Node,},
{SPA_TYPE_INTERFACE_Node,},
};
static int