mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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:
parent
fca3e1d85d
commit
805e3bb6c1
82 changed files with 812 additions and 924 deletions
|
|
@ -99,16 +99,16 @@ static void monitor_event(void *_data, struct spa_event *event)
|
|||
{
|
||||
struct data *data = _data;
|
||||
|
||||
switch (SPA_EVENT_TYPE(event)) {
|
||||
case SPA_ID_EVENT_MONITOR_Added:
|
||||
switch (SPA_MONITOR_EVENT_ID(event)) {
|
||||
case SPA_MONITOR_EVENT_Added:
|
||||
fprintf(stderr, "added:\n");
|
||||
inspect_item(data, SPA_POD_CONTENTS(struct spa_event, event));
|
||||
break;
|
||||
case SPA_ID_EVENT_MONITOR_Removed:
|
||||
case SPA_MONITOR_EVENT_Removed:
|
||||
fprintf(stderr, "removed:\n");
|
||||
inspect_item(data, SPA_POD_CONTENTS(struct spa_event, event));
|
||||
break;
|
||||
case SPA_ID_EVENT_MONITOR_Changed:
|
||||
case SPA_MONITOR_EVENT_Changed:
|
||||
fprintf(stderr, "changed:\n");
|
||||
inspect_item(data, SPA_POD_CONTENTS(struct spa_event, event));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ static void run_async_sink(struct data *data)
|
|||
int err;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
printf("got source error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
|
|
@ -503,7 +503,7 @@ static void run_async_sink(struct data *data)
|
|||
}
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
printf("got error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ static void run_convert(struct data *data)
|
|||
int res;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
if ((res = spa_node_send_command(data->conv, &cmd)) < 0)
|
||||
printf("got convert error %d\n", res);
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ static void run_convert(struct data *data)
|
|||
spa_debug_mem(0, data->out_buffers[0]->datas[1].data, BUFFER_SIZE);
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
if ((res = spa_node_send_command(data->conv, &cmd)) < 0)
|
||||
printf("got convert error %d\n", res);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ static void run_convert(struct data *data)
|
|||
int res, i, j;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
for (i = 0; i < 4; i++) {
|
||||
if ((res = spa_node_send_command(data->nodes[i].node, &cmd)) < 0)
|
||||
printf("got command error %d\n", res);
|
||||
|
|
@ -468,7 +468,7 @@ static void run_convert(struct data *data)
|
|||
spa_debug_mem(0, b->datas[i].data, b->datas[i].maxsize);
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
for (i = 0; i < 4; i++) {
|
||||
if ((res = spa_node_send_command(data->nodes[i].node, &cmd)) < 0)
|
||||
printf("got command error %d\n", res);
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ static void run_async_sink(struct data *data)
|
|||
int err;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
printf("got source error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->volume, &cmd)) < 0)
|
||||
|
|
@ -494,7 +494,7 @@ static void run_async_sink(struct data *data)
|
|||
}
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
printf("got error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->volume, &cmd)) < 0)
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ static void run_async_sink(struct data *data)
|
|||
int err;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
if ((res = spa_node_send_command(data->source1, &cmd)) < 0)
|
||||
printf("got source1 error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->source2, &cmd)) < 0)
|
||||
|
|
@ -643,7 +643,7 @@ static void run_async_sink(struct data *data)
|
|||
}
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
printf("got error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->mix, &cmd)) < 0)
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ static void run_graph(struct data *data)
|
|||
int64_t start, stop;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
printf("got source error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
|
|
@ -486,7 +486,7 @@ static void run_graph(struct data *data)
|
|||
printf("stopping, elapsed %" PRIi64 "\n", stop - start);
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
printf("got error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ static void do_static_struct(void)
|
|||
sizeof(struct spa_pod_prop_body),
|
||||
SPA_FORMAT_VIDEO_format,
|
||||
SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET,
|
||||
sizeof(uint32_t), SPA_POD_TYPE_ID),
|
||||
sizeof(uint32_t), SPA_ID_Enum),
|
||||
{
|
||||
SPA_VIDEO_FORMAT_I420,
|
||||
{ SPA_VIDEO_FORMAT_I420, SPA_VIDEO_FORMAT_YUY2 }
|
||||
|
|
@ -213,7 +213,7 @@ static void do_static_struct(void)
|
|||
sizeof(struct spa_pod_prop_body),
|
||||
SPA_FORMAT_VIDEO_size,
|
||||
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
|
||||
sizeof(struct spa_rectangle), SPA_POD_TYPE_RECTANGLE),
|
||||
sizeof(struct spa_rectangle), SPA_ID_Rectangle),
|
||||
|
||||
{
|
||||
SPA_RECTANGLE(320,243),
|
||||
|
|
@ -223,7 +223,7 @@ static void do_static_struct(void)
|
|||
sizeof(struct spa_pod_prop_body),
|
||||
SPA_FORMAT_VIDEO_framerate,
|
||||
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
|
||||
sizeof(struct spa_fraction), SPA_POD_TYPE_FRACTION),
|
||||
sizeof(struct spa_fraction), SPA_ID_Fraction),
|
||||
{
|
||||
SPA_FRACTION(25,1),
|
||||
SPA_FRACTION(0,1), SPA_FRACTION(INT32_MAX,1)
|
||||
|
|
|
|||
|
|
@ -258,49 +258,49 @@ static inline int spa_pod_id_to_type(char id)
|
|||
{
|
||||
switch (id) {
|
||||
case 'n':
|
||||
return SPA_POD_TYPE_NONE;
|
||||
return SPA_ID_None;
|
||||
case 'b':
|
||||
return SPA_POD_TYPE_BOOL;
|
||||
return SPA_ID_Bool;
|
||||
case 'I':
|
||||
return SPA_POD_TYPE_ID;
|
||||
return SPA_ID_Enum;
|
||||
case 'i':
|
||||
return SPA_POD_TYPE_INT;
|
||||
return SPA_ID_INT;
|
||||
case 'l':
|
||||
return SPA_POD_TYPE_LONG;
|
||||
return SPA_ID_LONG;
|
||||
case 'f':
|
||||
return SPA_POD_TYPE_FLOAT;
|
||||
return SPA_ID_FLOAT;
|
||||
case 'd':
|
||||
return SPA_POD_TYPE_DOUBLE;
|
||||
return SPA_ID_DOUBLE;
|
||||
case 's':
|
||||
return SPA_POD_TYPE_STRING;
|
||||
return SPA_ID_STRING;
|
||||
case 'k':
|
||||
return SPA_POD_TYPE_KEY;
|
||||
return SPA_ID_KEY;
|
||||
case 'z':
|
||||
return SPA_POD_TYPE_BYTES;
|
||||
return SPA_ID_BYTES;
|
||||
case 'R':
|
||||
return SPA_POD_TYPE_RECTANGLE;
|
||||
return SPA_ID_RECTANGLE;
|
||||
case 'F':
|
||||
return SPA_POD_TYPE_FRACTION;
|
||||
return SPA_ID_FRACTION;
|
||||
case 'B':
|
||||
return SPA_POD_TYPE_BITMASK;
|
||||
return SPA_ID_BITMASK;
|
||||
case 'A':
|
||||
return SPA_POD_TYPE_ARRAY;
|
||||
return SPA_ID_ARRAY;
|
||||
case 'S':
|
||||
return SPA_POD_TYPE_STRUCT;
|
||||
return SPA_ID_STRUCT;
|
||||
case 'O':
|
||||
return SPA_POD_TYPE_OBJECT;
|
||||
return SPA_ID_OBJECT;
|
||||
case 'M':
|
||||
return SPA_POD_TYPE_MAP;
|
||||
return SPA_ID_MAP;
|
||||
case 'p':
|
||||
return SPA_POD_TYPE_POINTER;
|
||||
return SPA_ID_POINTER;
|
||||
case 'h':
|
||||
return SPA_POD_TYPE_FD;
|
||||
return SPA_ID_FD;
|
||||
case 'V': case 'v':
|
||||
return SPA_POD_TYPE_PROP;
|
||||
return SPA_ID_PROP;
|
||||
case 'P':
|
||||
return SPA_POD_TYPE_POD;
|
||||
return SPA_ID_POD;
|
||||
default:
|
||||
return SPA_POD_TYPE_INVALID;
|
||||
return SPA_ID_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ spa_pod_parse_prop(struct spa_pod *pod, enum spa_pod_type type, struct spa_pod_p
|
|||
{
|
||||
int res;
|
||||
|
||||
if (SPA_POD_TYPE(pod) == SPA_POD_TYPE_STRUCT) {
|
||||
if (SPA_POD_TYPE(pod) == SPA_ID_STRUCT) {
|
||||
const char *flags;
|
||||
char ch;
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ spa_pod_parse_prop(struct spa_pod *pod, enum spa_pod_type type, struct spa_pod_p
|
|||
return res;
|
||||
}
|
||||
prop->type = spa_pod_id_to_type(*flags++);
|
||||
if (type != SPA_POD_TYPE_POD && type != SPA_POD_TYPE(prop->value)) {
|
||||
if (type != SPA_ID_POD && type != SPA_POD_TYPE(prop->value)) {
|
||||
printf("prop chunk of wrong type %d != %d\n", SPA_POD_TYPE(prop->value), type);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -374,7 +374,7 @@ spa_pod_parse_prop(struct spa_pod *pod, enum spa_pod_type type, struct spa_pod_p
|
|||
}
|
||||
else {
|
||||
/* a single value */
|
||||
if (type != SPA_POD_TYPE_POD && type != SPA_POD_TYPE(pod)) {
|
||||
if (type != SPA_ID_POD && type != SPA_POD_TYPE(pod)) {
|
||||
printf("prop chunk of wrong type %d != %d\n", SPA_POD_TYPE(prop->value), type);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -434,13 +434,13 @@ spa_pod_match(struct spa_pod *pod,
|
|||
return -1;
|
||||
templ += strspn(templ, " \t\r\n");
|
||||
if (*templ == ':') {
|
||||
if (SPA_POD_TYPE(it[depth].data) != SPA_POD_TYPE_MAP)
|
||||
if (SPA_POD_TYPE(it[depth].data) != SPA_ID_MAP)
|
||||
return -1;
|
||||
it[depth].offset = sizeof(struct spa_pod_map);
|
||||
/* move to key */
|
||||
while (spa_pod_iter_has_next(&it[depth])) {
|
||||
current = spa_pod_iter_next(&it[depth]);
|
||||
if (SPA_POD_TYPE(current) == SPA_POD_TYPE_KEY &&
|
||||
if (SPA_POD_TYPE(current) == SPA_ID_KEY &&
|
||||
strncmp(SPA_POD_CONTENTS_CONST(struct spa_pod_key, current),
|
||||
start, len) == 0)
|
||||
break;
|
||||
|
|
@ -448,7 +448,7 @@ spa_pod_match(struct spa_pod *pod,
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (current == NULL || SPA_POD_TYPE(current) != SPA_POD_TYPE_STRING ||
|
||||
if (current == NULL || SPA_POD_TYPE(current) != SPA_ID_STRING ||
|
||||
strncmp(SPA_POD_CONTENTS_CONST(struct spa_pod_string, current),
|
||||
start, len) != 0)
|
||||
goto done;
|
||||
|
|
@ -499,7 +499,7 @@ spa_pod_match(struct spa_pod *pod,
|
|||
|
||||
no_current:
|
||||
type = spa_pod_id_to_type(*templ);
|
||||
if (current == NULL || (type != SPA_POD_TYPE_POD && type != SPA_POD_TYPE(current))) {
|
||||
if (current == NULL || (type != SPA_ID_POD && type != SPA_POD_TYPE(current))) {
|
||||
if (!maybe)
|
||||
return -1;
|
||||
if (store)
|
||||
|
|
@ -572,13 +572,13 @@ spa_pod_match(struct spa_pod *pod,
|
|||
doubleval = strtod(start, (char **) &templ);
|
||||
if (*templ == 'f') {
|
||||
if (current == NULL ||
|
||||
SPA_POD_TYPE(current) != SPA_POD_TYPE_FLOAT ||
|
||||
SPA_POD_TYPE(current) != SPA_ID_FLOAT ||
|
||||
doubleval != SPA_POD_VALUE(struct spa_pod_float, current))
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
else if (current == NULL ||
|
||||
SPA_POD_TYPE(current) != SPA_POD_TYPE_DOUBLE ||
|
||||
SPA_POD_TYPE(current) != SPA_ID_DOUBLE ||
|
||||
doubleval != SPA_POD_VALUE(struct spa_pod_double, current))
|
||||
goto done;
|
||||
goto next;
|
||||
|
|
@ -586,7 +586,7 @@ spa_pod_match(struct spa_pod *pod,
|
|||
switch (*templ) {
|
||||
case 'x':
|
||||
if (current == NULL ||
|
||||
SPA_POD_TYPE(current) != SPA_POD_TYPE_RECTANGLE)
|
||||
SPA_POD_TYPE(current) != SPA_ID_RECTANGLE)
|
||||
goto done;
|
||||
|
||||
rectval = &SPA_POD_VALUE(struct spa_pod_rectangle, current);
|
||||
|
|
@ -596,7 +596,7 @@ spa_pod_match(struct spa_pod *pod,
|
|||
goto next;
|
||||
case '/':
|
||||
if (current == NULL ||
|
||||
SPA_POD_TYPE(current) != SPA_POD_TYPE_FRACTION)
|
||||
SPA_POD_TYPE(current) != SPA_ID_FRACTION)
|
||||
goto done;
|
||||
|
||||
fracval = &SPA_POD_VALUE(struct spa_pod_fraction, current);
|
||||
|
|
@ -606,13 +606,13 @@ spa_pod_match(struct spa_pod *pod,
|
|||
goto next;
|
||||
case 'l':
|
||||
if (current == NULL ||
|
||||
SPA_POD_TYPE(current) != SPA_POD_TYPE_LONG ||
|
||||
SPA_POD_TYPE(current) != SPA_ID_LONG ||
|
||||
SPA_POD_VALUE(struct spa_pod_long, current) != intval)
|
||||
goto done;
|
||||
break;
|
||||
default:
|
||||
if (current == NULL ||
|
||||
SPA_POD_TYPE(current) != SPA_POD_TYPE_INT ||
|
||||
SPA_POD_TYPE(current) != SPA_ID_INT ||
|
||||
SPA_POD_VALUE(struct spa_pod_int, current) != intval)
|
||||
goto done;
|
||||
break;
|
||||
|
|
@ -752,7 +752,7 @@ int main(int argc, char *argv[])
|
|||
" \"foz\": %h, "
|
||||
" } "
|
||||
"] ", format, rate, channels,
|
||||
sizeof(struct spa_rectangle), SPA_POD_TYPE_RECTANGLE, 3, rects,
|
||||
sizeof(struct spa_rectangle), SPA_ID_RECTANGLE, 3, rects,
|
||||
&pod,
|
||||
bytes, sizeof(bytes),
|
||||
fmt,
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ static void run_async_sink(struct data *data)
|
|||
int err;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
printf("got source error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
|
|
@ -404,7 +404,7 @@ static void run_async_sink(struct data *data)
|
|||
}
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
if ((res = spa_node_send_command(data->sink, &cmd)) < 0)
|
||||
printf("got sink error %d\n", res);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ static void run_async_source(struct data *data)
|
|||
int err;
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
printf("got error %d\n", res);
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ static void run_async_source(struct data *data)
|
|||
}
|
||||
|
||||
{
|
||||
struct spa_command cmd = SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause);
|
||||
struct spa_command cmd = SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause);
|
||||
if ((res = spa_node_send_command(data->source, &cmd)) < 0)
|
||||
printf("got error %d\n", res);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue