Use types with known sizes where we can, easier to serialize

Add iterator for POD and use it to implement some demarshalling.
This commit is contained in:
Wim Taymans 2017-03-07 11:56:43 +01:00
parent 23d09d5b60
commit f92b68c3c3
77 changed files with 839 additions and 695 deletions

View file

@ -24,89 +24,6 @@
#include <spa/props.h>
#if 0
SpaResult
spa_props_set_value (SpaProps *props,
unsigned int index,
const SpaPropValue *value)
{
const SpaPropInfo *info;
if (props == NULL || value == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
if (index >= props->n_prop_info)
return SPA_RESULT_INVALID_PROPERTY_INDEX;
info = &props->prop_info[index];
if ((info->flags & SPA_PROP_FLAG_WRITABLE) == 0)
return SPA_RESULT_INVALID_PROPERTY_ACCESS;
if (info->maxsize < value->size)
return SPA_RESULT_WRONG_PROPERTY_SIZE;
memcpy (SPA_MEMBER (props, info->offset, void), value->value, value->size);
SPA_PROPS_INDEX_SET (props, index);
return SPA_RESULT_OK;
}
SpaResult
spa_props_get_value (const SpaProps *props,
unsigned int index,
SpaPropValue *value)
{
const SpaPropInfo *info;
if (props == NULL || value == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
if (index >= props->n_prop_info)
return SPA_RESULT_INVALID_PROPERTY_INDEX;
info = &props->prop_info[index];
if ((info->flags & SPA_PROP_FLAG_READABLE) == 0)
return SPA_RESULT_INVALID_PROPERTY_ACCESS;
if (SPA_PROPS_INDEX_IS_UNSET (props, index))
return SPA_RESULT_PROPERTY_UNSET;
value->size = info->maxsize;
value->value = SPA_MEMBER (props, info->offset, void);
return SPA_RESULT_OK;
}
SpaResult
spa_props_copy_values (const SpaProps *src,
SpaProps *dest)
{
int i;
if (src == dest)
return SPA_RESULT_OK;
for (i = 0; i < dest->n_prop_info; i++) {
const SpaPropInfo *dinfo = &dest->prop_info[i];
const SpaPropInfo *sinfo;
unsigned int idx;
if (!(dinfo->flags & SPA_PROP_FLAG_WRITABLE))
continue;
if ((idx = spa_props_index_for_id (src, dinfo->id)) == SPA_IDX_INVALID)
continue;
sinfo = &src->prop_info[idx];
if (sinfo->maxsize > dinfo->maxsize)
return SPA_RESULT_WRONG_PROPERTY_SIZE;
memcpy (SPA_MEMBER (dest, dinfo->offset, void), SPA_MEMBER (src, sinfo->offset, void), sinfo->maxsize);
if (!SPA_PROPS_INDEX_IS_UNSET (src, idx))
SPA_PROPS_INDEX_SET (dest, i);
}
return SPA_RESULT_OK;
}
#endif
static int
compare_value (SpaPODType type, const void *r1, const void *r2)
{