mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
pod: add support for maybe-NULL types
This commit is contained in:
parent
3dba9f0fd4
commit
f613240b66
3 changed files with 36 additions and 23 deletions
|
|
@ -484,13 +484,13 @@ client_node_marshal_port_update (void *object,
|
|||
PinosProxy *proxy = object;
|
||||
PinosConnection *connection = proxy->context->protocol_private;
|
||||
Builder b = { { NULL, 0, 0, NULL, write_pod }, connection };
|
||||
SpaPODFrame f;
|
||||
SpaPODFrame f[2];
|
||||
int i, n_items;
|
||||
|
||||
core_update_map (proxy->context);
|
||||
|
||||
spa_pod_builder_add (&b.b,
|
||||
SPA_POD_TYPE_STRUCT, &f,
|
||||
SPA_POD_TYPE_STRUCT, &f[0],
|
||||
SPA_POD_TYPE_INT, direction,
|
||||
SPA_POD_TYPE_INT, port_id,
|
||||
SPA_POD_TYPE_INT, change_mask,
|
||||
|
|
@ -505,9 +505,9 @@ client_node_marshal_port_update (void *object,
|
|||
SPA_POD_TYPE_POD, props,
|
||||
0);
|
||||
|
||||
spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, info ? 1 : 0, 0);
|
||||
if (info) {
|
||||
spa_pod_builder_add (&b.b,
|
||||
SPA_POD_TYPE_STRUCT, &f[1],
|
||||
SPA_POD_TYPE_INT, info->flags,
|
||||
SPA_POD_TYPE_LONG, info->maxbuffering,
|
||||
SPA_POD_TYPE_LONG, info->latency,
|
||||
|
|
@ -526,8 +526,11 @@ client_node_marshal_port_update (void *object,
|
|||
SPA_POD_TYPE_STRING, info->extra->items[i].value,
|
||||
0);
|
||||
}
|
||||
spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f[1], 0);
|
||||
} else {
|
||||
spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, NULL, 0);
|
||||
}
|
||||
spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f, 0);
|
||||
spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f[0], 0);
|
||||
|
||||
pinos_connection_end_write (connection, proxy->id, 1, b.b.offset);
|
||||
}
|
||||
|
|
@ -680,7 +683,7 @@ client_node_demarshal_set_format (void *object,
|
|||
SPA_POD_TYPE_INT, &direction,
|
||||
SPA_POD_TYPE_INT, &port_id,
|
||||
SPA_POD_TYPE_INT, &flags,
|
||||
SPA_POD_TYPE_OBJECT, &format,
|
||||
-SPA_POD_TYPE_OBJECT, &format,
|
||||
0))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -811,7 +811,7 @@ client_node_demarshal_update (void *object,
|
|||
SPA_POD_TYPE_INT, &change_mask,
|
||||
SPA_POD_TYPE_INT, &max_input_ports,
|
||||
SPA_POD_TYPE_INT, &max_output_ports,
|
||||
SPA_POD_TYPE_OBJECT, &props,
|
||||
-SPA_POD_TYPE_OBJECT, &props,
|
||||
0))
|
||||
return false;
|
||||
|
||||
|
|
@ -826,10 +826,11 @@ client_node_demarshal_port_update (void *object,
|
|||
{
|
||||
PinosResource *resource = object;
|
||||
SpaPODIter it;
|
||||
uint32_t i, t, direction, port_id, change_mask, n_possible_formats;
|
||||
uint32_t i, direction, port_id, change_mask, n_possible_formats;
|
||||
const SpaProps *props = NULL;
|
||||
const SpaFormat **possible_formats = NULL, *format = NULL;
|
||||
SpaPortInfo info, *infop = NULL;
|
||||
SpaPOD *ipod;
|
||||
|
||||
if (!spa_pod_iter_struct (&it, data, size) ||
|
||||
!spa_pod_iter_get (&it,
|
||||
|
|
@ -842,23 +843,23 @@ client_node_demarshal_port_update (void *object,
|
|||
|
||||
possible_formats = alloca (n_possible_formats * sizeof (SpaFormat*));
|
||||
for (i = 0; i < n_possible_formats; i++)
|
||||
if (!spa_pod_iter_get (&it,SPA_POD_TYPE_OBJECT, &possible_formats[i], 0))
|
||||
if (!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &possible_formats[i], 0))
|
||||
return false;
|
||||
|
||||
if (!spa_pod_iter_get (&it,
|
||||
SPA_POD_TYPE_OBJECT, &format,
|
||||
SPA_POD_TYPE_OBJECT, &props,
|
||||
-SPA_POD_TYPE_OBJECT, &format,
|
||||
-SPA_POD_TYPE_OBJECT, &props,
|
||||
-SPA_POD_TYPE_STRUCT, &ipod,
|
||||
0))
|
||||
return false;
|
||||
|
||||
if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &t, 0))
|
||||
return false;
|
||||
|
||||
if (t) {
|
||||
if (ipod) {
|
||||
SpaDict dict;
|
||||
SpaPODIter it2;
|
||||
infop = &info;
|
||||
|
||||
if (!spa_pod_iter_get (&it,
|
||||
if (!spa_pod_iter_pod (&it2, ipod) ||
|
||||
!spa_pod_iter_get (&it2,
|
||||
SPA_POD_TYPE_INT, &info.flags,
|
||||
SPA_POD_TYPE_LONG, &info.maxbuffering,
|
||||
SPA_POD_TYPE_LONG, &info.latency,
|
||||
|
|
@ -868,16 +869,16 @@ client_node_demarshal_port_update (void *object,
|
|||
|
||||
info.params = alloca (info.n_params * sizeof (SpaAllocParam *));
|
||||
for (i = 0; i < info.n_params; i++)
|
||||
if (!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &info.params[i], 0))
|
||||
if (!spa_pod_iter_get (&it2, SPA_POD_TYPE_OBJECT, &info.params[i], 0))
|
||||
return false;
|
||||
|
||||
if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &dict.n_items, 0))
|
||||
if (!spa_pod_iter_get (&it2, SPA_POD_TYPE_INT, &dict.n_items, 0))
|
||||
return false;
|
||||
|
||||
info.extra = &dict;
|
||||
dict.items = alloca (dict.n_items * sizeof (SpaDictItem));
|
||||
for (i = 0; i < dict.n_items; i++) {
|
||||
if (!spa_pod_iter_get (&it,
|
||||
if (!spa_pod_iter_get (&it2,
|
||||
SPA_POD_TYPE_STRING, &dict.items[i].key,
|
||||
SPA_POD_TYPE_STRING, &dict.items[i].value,
|
||||
0))
|
||||
|
|
|
|||
|
|
@ -97,16 +97,16 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
|
|||
*(va_arg (args, SpaPOD **)) = pod; \
|
||||
} else if ((pod)->type == SPA_POD_TYPE_NONE) { \
|
||||
switch (type) { \
|
||||
case SPA_POD_TYPE_ARRAY: \
|
||||
case SPA_POD_TYPE_STRUCT: \
|
||||
case SPA_POD_TYPE_OBJECT: \
|
||||
case SPA_POD_TYPE_PROP: \
|
||||
case -SPA_POD_TYPE_ARRAY: \
|
||||
case -SPA_POD_TYPE_STRUCT: \
|
||||
case -SPA_POD_TYPE_OBJECT: \
|
||||
case -SPA_POD_TYPE_PROP: \
|
||||
*(va_arg (args, SpaPOD **)) = NULL; \
|
||||
break; \
|
||||
default: \
|
||||
goto error; \
|
||||
} \
|
||||
} else if ((pod)->type == type) { \
|
||||
} else if ((pod)->type == type || (pod)->type == -type) { \
|
||||
switch (type) { \
|
||||
case SPA_POD_TYPE_BOOL: \
|
||||
case SPA_POD_TYPE_URI: \
|
||||
|
|
@ -155,6 +155,10 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
|
|||
case SPA_POD_TYPE_STRUCT: \
|
||||
case SPA_POD_TYPE_OBJECT: \
|
||||
case SPA_POD_TYPE_PROP: \
|
||||
case -SPA_POD_TYPE_ARRAY: \
|
||||
case -SPA_POD_TYPE_STRUCT: \
|
||||
case -SPA_POD_TYPE_OBJECT: \
|
||||
case -SPA_POD_TYPE_PROP: \
|
||||
*(va_arg (args, SpaPOD **)) = pod; \
|
||||
break; \
|
||||
default: \
|
||||
|
|
@ -177,6 +181,7 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
|
|||
case SPA_POD_TYPE_FLOAT: \
|
||||
case SPA_POD_TYPE_DOUBLE: \
|
||||
case SPA_POD_TYPE_STRING: \
|
||||
case -SPA_POD_TYPE_STRING: \
|
||||
case SPA_POD_TYPE_RECTANGLE: \
|
||||
case SPA_POD_TYPE_FRACTION: \
|
||||
case SPA_POD_TYPE_BITMASK: \
|
||||
|
|
@ -185,6 +190,10 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
|
|||
case SPA_POD_TYPE_OBJECT: \
|
||||
case SPA_POD_TYPE_PROP: \
|
||||
case SPA_POD_TYPE_POD: \
|
||||
case -SPA_POD_TYPE_ARRAY: \
|
||||
case -SPA_POD_TYPE_STRUCT: \
|
||||
case -SPA_POD_TYPE_OBJECT: \
|
||||
case -SPA_POD_TYPE_PROP: \
|
||||
va_arg (args, void*); \
|
||||
default: \
|
||||
break; \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue