mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05:00
parser: add more parser helpers
This commit is contained in:
parent
a41624d48b
commit
3480765561
1 changed files with 41 additions and 0 deletions
|
|
@ -359,6 +359,19 @@ static inline int spa_pod_get_double(struct spa_pod *pod, double *value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int spa_pod_is_id(struct spa_pod *pod)
|
||||||
|
{
|
||||||
|
return (SPA_POD_TYPE(pod) == SPA_TYPE_Id && SPA_POD_BODY_SIZE(pod) >= sizeof(uint32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int spa_pod_get_id(struct spa_pod *pod, uint32_t *value)
|
||||||
|
{
|
||||||
|
if (!spa_pod_is_id(pod))
|
||||||
|
return -EINVAL;
|
||||||
|
*value = SPA_POD_VALUE(struct spa_pod_id, pod);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int spa_pod_is_int(struct spa_pod *pod)
|
static inline int spa_pod_is_int(struct spa_pod *pod)
|
||||||
{
|
{
|
||||||
return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
|
return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
|
||||||
|
|
@ -386,6 +399,34 @@ static inline int spa_pod_dup_string(struct spa_pod *pod, size_t maxlen, char *d
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int spa_pod_is_rectangle(struct spa_pod *pod)
|
||||||
|
{
|
||||||
|
return (SPA_POD_TYPE(pod) == SPA_TYPE_Rectangle &&
|
||||||
|
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_rectangle));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int spa_pod_get_rectangle(struct spa_pod *pod, struct spa_rectangle *value)
|
||||||
|
{
|
||||||
|
if (!spa_pod_is_rectangle(pod))
|
||||||
|
return -EINVAL;
|
||||||
|
*value = SPA_POD_VALUE(struct spa_pod_rectangle, pod);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int spa_pod_is_fraction(struct spa_pod *pod)
|
||||||
|
{
|
||||||
|
return (SPA_POD_TYPE(pod) == SPA_TYPE_Fraction &&
|
||||||
|
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_fraction));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int spa_pod_get_fraction(struct spa_pod *pod, struct spa_fraction *value)
|
||||||
|
{
|
||||||
|
if (!spa_pod_is_fraction(pod))
|
||||||
|
return -EINVAL;
|
||||||
|
*value = SPA_POD_VALUE(struct spa_pod_fraction, pod);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue