prop-builder: remove propbuilder

Replaced by more flexible POD
This commit is contained in:
Wim Taymans 2017-02-24 09:53:40 +01:00
parent 16b62de53a
commit 47714886c0
4 changed files with 3 additions and 225 deletions

View file

@ -1,7 +1,6 @@
spalib_sources = ['audio-raw.c',
'debug.c',
'mapper.c',
'prop-builder.c',
'props.c',
'video-raw.c']

View file

@ -1,142 +0,0 @@
/* Simple Plugin API
* Copyright (C) 2017 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "prop-builder.h"
void
spa_prop_builder_init (SpaPropBuilder *b,
size_t struct_size,
off_t prop_offset)
{
memset (b, 0, sizeof (*b));
b->size = struct_size;
b->struct_size = struct_size;
b->prop_offset = prop_offset;
}
void
spa_prop_builder_add_info (SpaPropBuilder *b,
SpaPropBuilderInfo *i)
{
if (b->info)
b->info->next = i;
if (b->head == NULL)
b->head = i;
b->info = i;
b->n_prop_info++;
i->info.n_range_values = 0;
i->value = NULL;
i->ranges = NULL;
i->next = NULL;
b->size += sizeof (SpaPropInfo);
b->size += i->info.name ? strlen (i->info.name) + 1 : 0;
}
void
spa_prop_builder_add_range (SpaPropBuilder *b,
SpaPropBuilderRange *r)
{
if (b->range)
b->range->next = r;
b->range = r;
if (b->info->ranges == NULL)
b->info->ranges = r;
r->next = NULL;
b->info->info.n_range_values++;
b->n_range_info++;
b->size += sizeof (SpaPropRangeInfo);
b->size += r->info.name ? strlen (r->info.name) + 1 : 0;
b->size += r->info.val.size;
}
void *
spa_prop_builder_finish (SpaPropBuilder *b)
{
int i, j, c, slen;
void *p;
SpaProps *tp;
SpaPropInfo *pi;
SpaPropRangeInfo *ri;
SpaPropBuilderInfo *ppi;
SpaPropBuilderRange *pri;
if (b->dest == NULL && b->finish)
b->finish (b);
if (b->dest == NULL)
return NULL;
tp = SPA_MEMBER (b->dest, b->prop_offset, SpaProps);
pi = SPA_MEMBER (b->dest, b->struct_size, SpaPropInfo);
ri = SPA_MEMBER (pi, sizeof(SpaPropInfo) * b->n_prop_info, SpaPropRangeInfo);
p = SPA_MEMBER (ri, sizeof(SpaPropRangeInfo) * b->n_range_info, void);
tp->n_prop_info = b->n_prop_info;
tp->prop_info = pi;
tp->unset_mask = 0;
ppi = b->head;
for (i = 0, c = 0; i < tp->n_prop_info; i++) {
memcpy (&pi[i], &ppi->info, sizeof (SpaPropInfo));
pi[i].range_values = &ri[c];
if (pi[i].name) {
slen = strlen (pi[i].name) + 1;
memcpy (p, pi[i].name, slen);
pi[i].name = p;
p += slen;
}
if (pi[i].n_range_values == 1) {
memcpy (SPA_MEMBER (tp, pi[i].offset, void), ppi->ranges[0].info.val.value, ppi->ranges[0].info.val.size);
ppi->value = ppi->ranges[0].info.val.value;
} else if (pi[i].n_range_values > 1) {
tp->unset_mask |= (1 << i);
}
if (ppi->value) {
memcpy (SPA_MEMBER (tp, pi[i].offset, void), ppi->value, ppi->info.maxsize);
}
pri = ppi->ranges;
for (j = 0; j < pi[i].n_range_values; j++, c++) {
memcpy (&ri[c], &pri->info, sizeof (SpaPropRangeInfo));
if (ri[c].name) {
slen = strlen (ri[c].name) + 1;
memcpy (p, ri[c].name, slen);
ri[c].name = p;
p += slen;
}
if (ri[c].val.size) {
memcpy (p, ri[c].val.value, ri[c].val.size);
ri[c].val.value = p;
p += ri[c].val.size;
}
pri = pri->next;
}
ppi = ppi->next;
}
return b->dest;
}

View file

@ -1,80 +0,0 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_PROP_BUILDER_H__
#define __SPA_PROP_BUILDER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/props.h>
typedef struct SpaPropBuilderRange SpaPropBuilderRange;
typedef struct SpaPropBuilderInfo SpaPropBuilderInfo;
typedef struct SpaPropBuilder SpaPropBuilder;
struct SpaPropBuilderRange {
SpaPropBuilderRange *next;
SpaPropRangeInfo info;
};
struct SpaPropBuilderInfo {
SpaPropBuilderInfo *next;
SpaPropInfo info;
const void *value;
SpaPropBuilderRange *ranges;
};
struct SpaPropBuilder {
SpaPropBuilderInfo *head;
SpaPropBuilderInfo *info;
SpaPropBuilderRange *range;
size_t n_prop_info;
size_t n_range_info;
size_t size;
size_t struct_size;
off_t prop_offset;
void *dest;
void *userdata;
void (*finish) (SpaPropBuilder *b);
};
void spa_prop_builder_init (SpaPropBuilder *b,
size_t struct_size,
off_t prop_offset);
void spa_prop_builder_add_info (SpaPropBuilder *b,
SpaPropBuilderInfo *i);
void spa_prop_builder_add_range (SpaPropBuilder *b,
SpaPropBuilderRange *r);
void * spa_prop_builder_finish (SpaPropBuilder *b);
SpaResult spa_props_filter (SpaPropBuilder *b,
const SpaProps *props,
const SpaProps *filter);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_PROP_BUILDER_H__ */

View file

@ -23,7 +23,6 @@
#include <string.h>
#include <spa/props.h>
#include <lib/prop-builder.h>
SpaResult
spa_props_set_value (SpaProps *props,
@ -106,6 +105,8 @@ spa_props_copy_values (const SpaProps *src,
return SPA_RESULT_OK;
}
#if 0
static int
compare_value (SpaPropType type, const SpaPropRangeInfo *r1, const SpaPropRangeInfo *r2)
{
@ -159,7 +160,6 @@ compare_value (SpaPropType type, const SpaPropRangeInfo *r1, const SpaPropRangeI
return 0;
}
SpaResult
spa_props_filter (SpaPropBuilder *b,
const SpaProps *props,
@ -347,3 +347,4 @@ spa_props_filter (SpaPropBuilder *b,
return SPA_RESULT_OK;
}
#endif