types: work on types

Move static pod types to type system
work on type info for types
Move the event and command ids to an enum to make it easier to extend
later.
This commit is contained in:
Wim Taymans 2018-08-24 10:53:09 +02:00
parent fca3e1d85d
commit 805e3bb6c1
82 changed files with 812 additions and 924 deletions

View file

@ -347,7 +347,7 @@ static void impl_on_fd_events(struct spa_source *source)
struct impl *this = source->data;
struct udev_device *dev;
const char *action;
uint32_t type;
uint32_t id;
struct card *card;
struct spa_event *event;
@ -357,18 +357,18 @@ static void impl_on_fd_events(struct spa_source *source)
action = "change";
if (strcmp(action, "add") == 0) {
type = SPA_ID_EVENT_MONITOR_Added;
id = SPA_MONITOR_EVENT_Added;
} else if (strcmp(action, "change") == 0) {
type = SPA_ID_EVENT_MONITOR_Changed;
id = SPA_MONITOR_EVENT_Changed;
} else if (strcmp(action, "remove") == 0) {
type = SPA_ID_EVENT_MONITOR_Removed;
id = SPA_MONITOR_EVENT_Removed;
} else
return;
if ((card = find_card(this, dev)) == NULL)
return;
if (type == SPA_ID_EVENT_MONITOR_Removed) {
if (id == SPA_MONITOR_EVENT_Removed) {
int i;
for (i = 0; i < MAX_DEVICES; i++) {
@ -380,7 +380,7 @@ static void impl_on_fd_events(struct spa_source *source)
if (SPA_FLAG_CHECK(device->flags, DEVICE_FLAG_PLAYBACK)) {
snprintf(id, 64, "%s,%d/P", card->name, device->id);
event = spa_pod_builder_object(&b, 0, type);
event = spa_pod_builder_object(&b, id, SPA_ID_EVENT_Monitor);
spa_pod_builder_object(&b,
0, SPA_ID_OBJECT_MonitorItem,
":", SPA_MONITOR_ITEM_id, "s", id,
@ -389,7 +389,7 @@ static void impl_on_fd_events(struct spa_source *source)
}
if (SPA_FLAG_CHECK(device->flags, DEVICE_FLAG_RECORD)) {
snprintf(id, 64, "%s,%d/C", card->name, device->id);
event = spa_pod_builder_object(&b, 0, type);
event = spa_pod_builder_object(&b, id, SPA_ID_EVENT_Monitor);
spa_pod_builder_object(&b,
0, SPA_ID_OBJECT_MonitorItem,
":", SPA_MONITOR_ITEM_id, "s", id,
@ -408,7 +408,7 @@ static void impl_on_fd_events(struct spa_source *source)
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct spa_pod *item;
event = spa_pod_builder_object(&b, 0, type);
event = spa_pod_builder_object(&b, id, SPA_ID_EVENT_Monitor);
if (get_next_device(this, card, &item, &b) < 0)
break;

View file

@ -190,8 +190,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct state, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
if (!this->have_format)
return -EIO;
if (this->n_buffers == 0)
@ -200,7 +200,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
if ((res = spa_alsa_start(this, false)) < 0)
return res;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if ((res = spa_alsa_pause(this, false)) < 0)
return res;
break;

View file

@ -192,8 +192,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct state, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
if (!this->have_format)
return -EIO;
if (this->n_buffers == 0)
@ -202,7 +202,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
if ((res = spa_alsa_start(this, false)) < 0)
return res;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if ((res = spa_alsa_pause(this, false)) < 0)
return res;
break;

View file

@ -431,14 +431,14 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
if ((res = setup_convert(this)) < 0)
goto error;
setup_buffers(this, SPA_DIRECTION_INPUT);
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -198,11 +198,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -224,11 +224,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -127,11 +127,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -168,11 +168,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -127,11 +127,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -145,11 +145,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -388,8 +388,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
{
struct timespec now;
@ -413,7 +413,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
set_timer(this, true);
break;
}
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if (!this->have_format)
return -EIO;
if (this->n_buffers == 0)

View file

@ -811,8 +811,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
if (!this->have_format)
return -EIO;
if (this->n_buffers == 0)
@ -821,7 +821,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
if ((res = do_start(this)) < 0)
return res;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if ((res = do_stop(this)) < 0)
return res;
break;

View file

@ -640,7 +640,7 @@ static struct spa_bt_node *node_create(struct spa_bt_monitor *monitor, struct sp
struct spa_pod *item;
spa_pod_builder_init(&b, buffer, sizeof(buffer));
event = spa_pod_builder_object(&b, 0, SPA_ID_EVENT_MONITOR_Added);
event = spa_pod_builder_object(&b, SPA_MONITOR_EVENT_Added, SPA_ID_EVENT_Monitor);
fill_item(monitor, transport, &item, &b);
monitor->callbacks->event(monitor->callbacks_data, event);
@ -656,7 +656,7 @@ static struct spa_bt_node *node_destroy(struct spa_bt_monitor *monitor, struct s
struct spa_pod *item;
spa_pod_builder_init(&b, buffer, sizeof(buffer));
event = spa_pod_builder_object(&b, 0, SPA_ID_EVENT_MONITOR_Removed);
event = spa_pod_builder_object(&b, SPA_MONITOR_EVENT_Removed, SPA_ID_EVENT_Monitor);
fill_item(monitor, transport, &item, &b);
monitor->callbacks->event(monitor->callbacks_data, event);

View file

@ -92,11 +92,11 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -94,11 +94,11 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default:

View file

@ -268,8 +268,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
{
struct timespec now;
@ -293,7 +293,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
set_timer(this, true);
break;
}
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if (!this->have_format)
return -EIO;
if (this->n_buffers == 0)

View file

@ -285,8 +285,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
{
struct timespec now;
@ -311,7 +311,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
set_timer(this, true);
break;
}
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if (!this->have_format)
return -EIO;
if (this->n_buffers == 0)

View file

@ -178,16 +178,16 @@ static void impl_on_fd_events(struct spa_source *source)
action = "change";
if (strcmp(action, "add") == 0) {
type = SPA_ID_EVENT_MONITOR_Added;
type = SPA_MONITOR_EVENT_Added;
} else if (strcmp(action, "change") == 0) {
type = SPA_ID_EVENT_MONITOR_Changed;
type = SPA_MONITOR_EVENT_Changed;
} else if (strcmp(action, "remove") == 0) {
type = SPA_ID_EVENT_MONITOR_Removed;
type = SPA_MONITOR_EVENT_Removed;
} else
return;
spa_pod_builder_init(&b, buffer, sizeof(buffer));
event = spa_pod_builder_object(&b, 0, type);
event = spa_pod_builder_object(&b, type, SPA_ID_EVENT_Monitor);
fill_item(this, &this->uitem, dev, &item, &b);
this->callbacks->event(this->callbacks_data, event);

View file

@ -269,8 +269,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
{
struct port *port = GET_OUT_PORT(this, 0);
@ -283,7 +283,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
return res;
break;
}
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if ((res = spa_v4l2_stream_off(this)) < 0)
return res;
break;

View file

@ -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_POD_TYPE_ID)
if (p->body.value.type != SPA_ID_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_POD_TYPE_RECTANGLE) {
if (p->body.value.type != SPA_ID_Rectangle) {
goto enum_end;
}
@ -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_POD_TYPE_FRACTION)
if (p->body.value.type != SPA_ID_Fraction)
goto enum_end;
range = p->body.flags & SPA_POD_PROP_RANGE_MASK;

View file

@ -327,8 +327,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
{
struct timespec now;
@ -352,7 +352,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
set_timer(this, true);
break;
}
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
if (!this->have_format)
return -EIO;
if (this->n_buffers == 0)

View file

@ -217,11 +217,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_COMMAND_TYPE(command)) {
case SPA_ID_COMMAND_NODE_Start:
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
break;
case SPA_ID_COMMAND_NODE_Pause:
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
default: