mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-15 05:34:03 -04:00
pod: add support for vararg building and parsing of pod+body
This commit is contained in:
parent
f7ae61cb1e
commit
77494086c1
3 changed files with 36 additions and 0 deletions
|
|
@ -595,6 +595,17 @@ do { \
|
||||||
spa_pod_builder_primitive(builder, pod); \
|
spa_pod_builder_primitive(builder, pod); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
|
case 'Q': \
|
||||||
|
case 'N': \
|
||||||
|
case 'U': \
|
||||||
|
case 'W': \
|
||||||
|
{ \
|
||||||
|
struct spa_pod *pod = va_arg(args, struct spa_pod *); \
|
||||||
|
const void *body = va_arg(args, const void *); \
|
||||||
|
spa_pod_builder_primitive_body(builder, pod, \
|
||||||
|
body, pod->size, NULL, 0); \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
} while(false)
|
} while(false)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -540,6 +540,7 @@ SPA_API_POD_PARSER bool spa_pod_parser_body_can_collect(const struct spa_pod *po
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'P':
|
case 'P':
|
||||||
|
case 'Q':
|
||||||
return true;
|
return true;
|
||||||
case 'b':
|
case 'b':
|
||||||
return spa_pod_is_bool(pod);
|
return spa_pod_is_bool(pod);
|
||||||
|
|
@ -572,10 +573,13 @@ SPA_API_POD_PARSER bool spa_pod_parser_body_can_collect(const struct spa_pod *po
|
||||||
case 'h':
|
case 'h':
|
||||||
return spa_pod_is_fd(pod);
|
return spa_pod_is_fd(pod);
|
||||||
case 'T':
|
case 'T':
|
||||||
|
case 'U':
|
||||||
return spa_pod_is_struct(pod) || spa_pod_is_none(pod);
|
return spa_pod_is_struct(pod) || spa_pod_is_none(pod);
|
||||||
|
case 'N':
|
||||||
case 'O':
|
case 'O':
|
||||||
return spa_pod_is_object(pod) || spa_pod_is_none(pod);
|
return spa_pod_is_object(pod) || spa_pod_is_none(pod);
|
||||||
case 'V':
|
case 'V':
|
||||||
|
case 'W':
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -673,6 +677,17 @@ do { \
|
||||||
NULL : SPA_PTROFF((body), -sizeof(struct spa_pod), const struct spa_pod); \
|
NULL : SPA_PTROFF((body), -sizeof(struct spa_pod), const struct spa_pod); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
|
case 'Q': \
|
||||||
|
case 'U': \
|
||||||
|
case 'N': \
|
||||||
|
case 'W': \
|
||||||
|
{ \
|
||||||
|
struct spa_pod *p = va_arg(args, struct spa_pod*); \
|
||||||
|
const void **v = va_arg(args, const void **); \
|
||||||
|
*p = *pod; \
|
||||||
|
*v = body; \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
default: \
|
default: \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
|
|
@ -807,6 +822,10 @@ SPA_API_POD_PARSER int spa_pod_parser_get(struct spa_pod_parser *parser, ...)
|
||||||
#define SPA_POD_OPT_PodObject(val) "?" SPA_POD_PodObject(val)
|
#define SPA_POD_OPT_PodObject(val) "?" SPA_POD_PodObject(val)
|
||||||
#define SPA_POD_OPT_PodStruct(val) "?" SPA_POD_PodStruct(val)
|
#define SPA_POD_OPT_PodStruct(val) "?" SPA_POD_PodStruct(val)
|
||||||
#define SPA_POD_OPT_PodChoice(val) "?" SPA_POD_PodChoice(val)
|
#define SPA_POD_OPT_PodChoice(val) "?" SPA_POD_PodChoice(val)
|
||||||
|
#define SPA_POD_OPT_PodBody(val,body) "?" SPA_POD_PodBody(val,body)
|
||||||
|
#define SPA_POD_OPT_PodBodyObject(val,body) "?" SPA_POD_PodBodyObject(val,body)
|
||||||
|
#define SPA_POD_OPT_PodBodyStruct(val,body) "?" SPA_POD_PodBodyStruct(val,body)
|
||||||
|
#define SPA_POD_OPT_PodBodyChoice(val,body) "?" SPA_POD_PodBodyChoice(val,body)
|
||||||
|
|
||||||
#define spa_pod_parser_get_object(p,type,id,...) \
|
#define spa_pod_parser_get_object(p,type,id,...) \
|
||||||
({ \
|
({ \
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,12 @@ extern "C" {
|
||||||
#define SPA_POD_PodStruct(val) "T", val
|
#define SPA_POD_PodStruct(val) "T", val
|
||||||
#define SPA_POD_PodChoice(val) "V", val
|
#define SPA_POD_PodChoice(val) "V", val
|
||||||
|
|
||||||
|
#define SPA_POD_PodBody(val,body) "Q", val, body
|
||||||
|
#define SPA_POD_PodBodyObject(val,body) "N", val, body
|
||||||
|
#define SPA_POD_PodBodyStruct(val,body) "U", val, body
|
||||||
|
#define SPA_POD_PodBodyChoice(val,body) "W", val, body
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \}
|
* \}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue