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;