mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
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:
parent
281b65934e
commit
90c1a95eef
117 changed files with 1198 additions and 1272 deletions
|
|
@ -98,13 +98,13 @@ static void fill_item(struct impl *this, struct item *item, struct udev_device *
|
|||
name = "Unknown";
|
||||
|
||||
spa_pod_builder_add(builder,
|
||||
"<", 0, SPA_ID_OBJECT_MonitorItem,
|
||||
"<", SPA_TYPE_OBJECT_MonitorItem, 0,
|
||||
":", SPA_MONITOR_ITEM_id, "s", udev_device_get_syspath(item->udevice),
|
||||
":", SPA_MONITOR_ITEM_flags, "I", SPA_MONITOR_ITEM_FLAG_NONE,
|
||||
":", SPA_MONITOR_ITEM_state, "I", SPA_MONITOR_ITEM_STATE_AVAILABLE,
|
||||
":", SPA_MONITOR_ITEM_name, "s", name,
|
||||
":", SPA_MONITOR_ITEM_class, "s", "Video/Source",
|
||||
":", SPA_MONITOR_ITEM_factory, "p", SPA_ID_INTERFACE_HandleFactory, &spa_v4l2_source_factory,
|
||||
":", SPA_MONITOR_ITEM_factory, "p", SPA_TYPE_INTERFACE_HandleFactory, &spa_v4l2_source_factory,
|
||||
":", SPA_MONITOR_ITEM_info, "[",
|
||||
NULL);
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ static void impl_on_fd_events(struct spa_source *source)
|
|||
struct udev_device *dev;
|
||||
struct spa_event *event;
|
||||
const char *action;
|
||||
uint32_t type;
|
||||
uint32_t id;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
uint8_t buffer[4096];
|
||||
struct spa_pod *item;
|
||||
|
|
@ -178,16 +178,16 @@ static void impl_on_fd_events(struct spa_source *source)
|
|||
action = "change";
|
||||
|
||||
if (strcmp(action, "add") == 0) {
|
||||
type = SPA_MONITOR_EVENT_Added;
|
||||
id = SPA_MONITOR_EVENT_Added;
|
||||
} else if (strcmp(action, "change") == 0) {
|
||||
type = SPA_MONITOR_EVENT_Changed;
|
||||
id = SPA_MONITOR_EVENT_Changed;
|
||||
} else if (strcmp(action, "remove") == 0) {
|
||||
type = SPA_MONITOR_EVENT_Removed;
|
||||
id = SPA_MONITOR_EVENT_Removed;
|
||||
} else
|
||||
return;
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
event = spa_pod_builder_object(&b, type, SPA_ID_EVENT_Monitor);
|
||||
event = spa_pod_builder_object(&b, SPA_TYPE_EVENT_Monitor, id);
|
||||
fill_item(this, &this->uitem, dev, &item, &b);
|
||||
|
||||
this->callbacks->event(this->callbacks_data, event);
|
||||
|
|
@ -291,7 +291,7 @@ static const struct spa_monitor impl_monitor = {
|
|||
impl_monitor_enum_items,
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == SPA_ID_INTERFACE_Monitor)
|
||||
if (type == SPA_TYPE_INTERFACE_Monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return -ENOENT;
|
||||
|
|
@ -350,9 +350,9 @@ 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;
|
||||
else if (support[i].type == SPA_ID_INTERFACE_MainLoop)
|
||||
else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop)
|
||||
this->main_loop = support[i].data;
|
||||
}
|
||||
if (this->main_loop == NULL) {
|
||||
|
|
@ -366,7 +366,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_ID_INTERFACE_Monitor,},
|
||||
{SPA_TYPE_INTERFACE_Monitor,},
|
||||
};
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
SPA_PARAM_Props };
|
||||
|
||||
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;
|
||||
|
|
@ -175,21 +175,21 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
switch (*index) {
|
||||
case 0:
|
||||
param = spa_pod_builder_object(&b,
|
||||
id, SPA_ID_OBJECT_PropInfo,
|
||||
SPA_TYPE_OBJECT_PropInfo, id,
|
||||
":", SPA_PROP_INFO_id, "I", SPA_PROP_device,
|
||||
":", SPA_PROP_INFO_name, "s", "The V4L2 device",
|
||||
":", SPA_PROP_INFO_type, "S", p->device, sizeof(p->device));
|
||||
break;
|
||||
case 1:
|
||||
param = spa_pod_builder_object(&b,
|
||||
id, SPA_ID_OBJECT_PropInfo,
|
||||
SPA_TYPE_OBJECT_PropInfo, id,
|
||||
":", SPA_PROP_INFO_id, "I", SPA_PROP_deviceName,
|
||||
":", SPA_PROP_INFO_name, "s", "The V4L2 device name",
|
||||
":", SPA_PROP_INFO_type, "S-r", p->device_name, sizeof(p->device_name));
|
||||
break;
|
||||
case 2:
|
||||
param = spa_pod_builder_object(&b,
|
||||
id, SPA_ID_OBJECT_PropInfo,
|
||||
SPA_TYPE_OBJECT_PropInfo, id,
|
||||
":", SPA_PROP_INFO_id, "I", SPA_PROP_deviceFd,
|
||||
":", SPA_PROP_INFO_name, "s", "The V4L2 fd",
|
||||
":", SPA_PROP_INFO_type, "i-r", p->device_fd);
|
||||
|
|
@ -206,7 +206,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
switch (*index) {
|
||||
case 0:
|
||||
param = spa_pod_builder_object(&b,
|
||||
id, SPA_ID_OBJECT_Props,
|
||||
SPA_TYPE_OBJECT_Props, id,
|
||||
":", SPA_PROP_device, "S", p->device, sizeof(p->device),
|
||||
":", SPA_PROP_deviceName, "S-r", p->device_name, sizeof(p->device_name),
|
||||
":", SPA_PROP_deviceFd, "i-r", p->device_fd);
|
||||
|
|
@ -392,7 +392,7 @@ static int port_get_format(struct spa_node *node,
|
|||
if (*index > 0)
|
||||
return 0;
|
||||
|
||||
spa_pod_builder_push_object(builder, SPA_PARAM_Format, SPA_ID_OBJECT_Format);
|
||||
spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_Format);
|
||||
|
||||
spa_pod_builder_add(builder,
|
||||
"I", port->current_format.media_type,
|
||||
|
|
@ -465,7 +465,7 @@ static int 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;
|
||||
|
|
@ -488,7 +488,7 @@ static int 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", MAX_BUFFERS,
|
||||
SPA_POD_PROP_MIN_MAX(2, MAX_BUFFERS),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
|
||||
|
|
@ -501,7 +501,7 @@ static int 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;
|
||||
|
|
@ -518,13 +518,13 @@ static int 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_Clock,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_clock));
|
||||
break;
|
||||
|
|
@ -872,7 +872,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;
|
||||
|
||||
|
|
@ -881,7 +881,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;
|
||||
|
|
@ -923,11 +923,11 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
port = GET_OUT_PORT(this, 0);
|
||||
|
||||
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;
|
||||
else if (support[i].type == SPA_ID_INTERFACE_MainLoop)
|
||||
else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop)
|
||||
port->main_loop = support[i].data;
|
||||
else if (support[i].type == SPA_ID_INTERFACE_DataLoop)
|
||||
else if (support[i].type == SPA_TYPE_INTERFACE_DataLoop)
|
||||
port->data_loop = support[i].data;
|
||||
}
|
||||
if (port->main_loop == NULL) {
|
||||
|
|
@ -963,7 +963,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 impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ enum_filter_format(uint32_t media_type, int32_t media_subtype,
|
|||
if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_format)))
|
||||
return SPA_VIDEO_FORMAT_UNKNOWN;
|
||||
|
||||
if (p->body.value.type != SPA_ID_Enum)
|
||||
if (p->body.value.type != SPA_TYPE_Enum)
|
||||
return SPA_VIDEO_FORMAT_UNKNOWN;
|
||||
|
||||
values = SPA_POD_BODY_CONST(&p->body.value);
|
||||
|
|
@ -596,7 +596,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_size)))
|
||||
goto do_frmsize;
|
||||
|
||||
if (p->body.value.type != SPA_ID_Rectangle) {
|
||||
if (p->body.value.type != SPA_TYPE_Rectangle) {
|
||||
goto enum_end;
|
||||
}
|
||||
|
||||
|
|
@ -675,7 +675,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
}
|
||||
}
|
||||
|
||||
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_add(builder,
|
||||
"I", info->media_type,
|
||||
"I", info->media_subtype, 0);
|
||||
|
|
@ -717,7 +717,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
if (!(p = spa_pod_find_prop(filter, SPA_FORMAT_VIDEO_framerate)))
|
||||
goto have_framerate;
|
||||
|
||||
if (p->body.value.type != SPA_ID_Fraction)
|
||||
if (p->body.value.type != SPA_TYPE_Fraction)
|
||||
goto enum_end;
|
||||
|
||||
range = p->body.flags & SPA_POD_PROP_RANGE_MASK;
|
||||
|
|
@ -1052,7 +1052,7 @@ spa_v4l2_enum_controls(struct impl *this,
|
|||
switch (queryctrl.type) {
|
||||
case V4L2_CTRL_TYPE_INTEGER:
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_PARAM_PropInfo, SPA_ID_OBJECT_PropInfo,
|
||||
SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
|
||||
":", SPA_PROP_INFO_id, "I", prop_id,
|
||||
":", SPA_PROP_INFO_type, "isu", queryctrl.default_value,
|
||||
SPA_POD_PROP_STEP(queryctrl.minimum,
|
||||
|
|
@ -1062,7 +1062,7 @@ spa_v4l2_enum_controls(struct impl *this,
|
|||
break;
|
||||
case V4L2_CTRL_TYPE_BOOLEAN:
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_PARAM_PropInfo, SPA_ID_OBJECT_PropInfo,
|
||||
SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo,
|
||||
":", SPA_PROP_INFO_id, "I", prop_id,
|
||||
":", SPA_PROP_INFO_type, "b-u", queryctrl.default_value,
|
||||
":", SPA_PROP_INFO_name, "s", queryctrl.name);
|
||||
|
|
@ -1071,7 +1071,7 @@ spa_v4l2_enum_controls(struct impl *this,
|
|||
{
|
||||
struct v4l2_querymenu querymenu;
|
||||
|
||||
spa_pod_builder_push_object(&b, SPA_PARAM_PropInfo, SPA_ID_OBJECT_PropInfo);
|
||||
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_PropInfo, SPA_PARAM_PropInfo);
|
||||
spa_pod_builder_add(&b,
|
||||
":", SPA_PROP_INFO_id, "I", prop_id,
|
||||
":", SPA_PROP_INFO_type, "i-u", queryctrl.default_value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue