Reorganize serialization code a bit

Move the proxy plugin to the client-node
Move serialization code to pinos because its specific to pinos
Move some functions to the .h files
Make the mapper dynamic
This commit is contained in:
Wim Taymans 2016-10-17 12:20:49 +02:00
parent 8520246a1b
commit d8903b708d
25 changed files with 1950 additions and 3858 deletions

View file

@ -25,8 +25,8 @@
#include <unistd.h>
#include <sys/socket.h>
#include <spa/control.h>
#include <spa/debug.h>
#include "control.h"
#include "serialize.h"
#if 0
#define SPA_DEBUG_CONTROL(format,args...) fprintf(stderr,format,##args)
@ -34,12 +34,6 @@
#define SPA_DEBUG_CONTROL(format,args...)
#endif
typedef struct {
uint32_t version;
uint32_t flags;
uint32_t length;
} SpaStackHeader;
typedef struct {
void *data;
size_t size;
@ -94,27 +88,6 @@ spa_control_init_data (SpaControl *control,
return SPA_RESULT_OK;
}
/**
* spa_control_get_version
* @control: a #SpaControl
*
* Get the control version
*
* Returns: the control version.
*/
uint32_t
spa_control_get_version (SpaControl *control)
{
SpaStackControl *sc = SSC (control);
SpaStackHeader *hdr;
if (!is_valid_control (control))
return -1;
hdr = sc->data;
return hdr->version;
}
/**
* spa_control_get_fd:
* @control: a #SpaControl
@ -180,7 +153,6 @@ spa_control_clear (SpaControl *control)
*/
struct stack_iter {
size_t magic;
uint32_t version;
SpaStackControl *control;
size_t offset;
@ -202,9 +174,8 @@ struct stack_iter {
* Initialize @iter to iterate the packets in @control.
*/
SpaResult
spa_control_iter_init_full (SpaControlIter *iter,
SpaControl *control,
uint32_t version)
spa_control_iter_init (SpaControlIter *iter,
SpaControl *control)
{
struct stack_iter *si = SCSI (iter);
@ -212,11 +183,10 @@ spa_control_iter_init_full (SpaControlIter *iter,
return SPA_RESULT_INVALID_ARGUMENTS;
si->magic = SCSI_MAGIC;
si->version = version;
si->control = SSC (control);
si->offset = 0;
si->cmd = SPA_CONTROL_CMD_INVALID;
si->size = sizeof (SpaStackHeader);
si->size = 0;
si->data = NULL;
return SPA_RESULT_OK;
@ -272,6 +242,7 @@ spa_control_iter_next (SpaControlIter *iter)
/* now read packet */
data = si->control->data;
size = si->control->size;
if (si->offset >= size)
return SPA_RESULT_ERROR;
@ -345,7 +316,7 @@ iter_parse_node_update (struct stack_iter *si, SpaControlCmdNodeUpdate *nu)
{
memcpy (nu, si->data, sizeof (SpaControlCmdNodeUpdate));
if (nu->props)
nu->props = spa_props_deserialize (si->data, SPA_PTR_TO_INT (nu->props));
nu->props = spa_serialize_props_deserialize (si->data, SPA_PTR_TO_INT (nu->props));
}
static void
@ -363,16 +334,16 @@ iter_parse_port_update (struct stack_iter *si, SpaControlCmdPortUpdate *pu)
SPA_PTR_TO_INT (pu->possible_formats), SpaFormat *);
for (i = 0; i < pu->n_possible_formats; i++) {
if (pu->possible_formats[i]) {
pu->possible_formats[i] = spa_format_deserialize (p,
pu->possible_formats[i] = spa_serialize_format_deserialize (p,
SPA_PTR_TO_INT (pu->possible_formats[i]));
}
}
if (pu->format)
pu->format = spa_format_deserialize (p, SPA_PTR_TO_INT (pu->format));
pu->format = spa_serialize_format_deserialize (p, SPA_PTR_TO_INT (pu->format));
if (pu->props)
pu->props = spa_props_deserialize (p, SPA_PTR_TO_INT (pu->props));
pu->props = spa_serialize_props_deserialize (p, SPA_PTR_TO_INT (pu->props));
if (pu->info)
pu->info = spa_port_info_deserialize (p, SPA_PTR_TO_INT (pu->info));
pu->info = spa_serialize_port_info_deserialize (p, SPA_PTR_TO_INT (pu->info));
}
static void
@ -380,7 +351,7 @@ iter_parse_set_format (struct stack_iter *si, SpaControlCmdSetFormat *cmd)
{
memcpy (cmd, si->data, sizeof (SpaControlCmdSetFormat));
if (cmd->format)
cmd->format = spa_format_deserialize (si->data, SPA_PTR_TO_INT (cmd->format));
cmd->format = spa_serialize_format_deserialize (si->data, SPA_PTR_TO_INT (cmd->format));
}
static void
@ -526,7 +497,7 @@ spa_control_iter_parse_cmd (SpaControlIter *iter,
struct stack_builder {
size_t magic;
SpaStackHeader *sh;
void *data;
SpaStackControl control;
SpaControlCmd cmd;
@ -540,34 +511,31 @@ struct stack_builder {
/**
* spa_control_builder_init_full:
* spa_control_builder_init_into:
* @builder: a #SpaControlBuilder
* @version: a version
* @data: data to build into or %NULL to allocate
* @max_data: allocated size of @data
* @fds: memory for fds
* @max_fds: maximum number of fds in @fds
*
* Initialize a stack allocated @builder and set the @version.
* Initialize a stack allocated @builder
*/
SpaResult
spa_control_builder_init_full (SpaControlBuilder *builder,
uint32_t version,
spa_control_builder_init_into (SpaControlBuilder *builder,
void *data,
size_t max_data,
int *fds,
unsigned int max_fds)
{
struct stack_builder *sb = SCSB (builder);
SpaStackHeader *sh;
if (builder == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
sb->magic = SCSB_MAGIC;
if (max_data < sizeof (SpaStackHeader) || data == NULL) {
sb->control.max_size = sizeof (SpaStackHeader) + 128;
if (max_data < 8 || data == NULL) {
sb->control.max_size = 128;
sb->control.data = malloc (sb->control.max_size);
sb->control.free_data = sb->control.data;
fprintf (stderr, "builder %p: alloc control memory %zd -> %zd\n",
@ -577,18 +545,13 @@ spa_control_builder_init_full (SpaControlBuilder *builder,
sb->control.data = data;
sb->control.free_data = NULL;
}
sb->control.size = sizeof (SpaStackHeader);
sb->control.size = 0;
sb->control.fds = fds;
sb->control.max_fds = max_fds;
sb->control.n_fds = 0;
sb->control.free_fds = NULL;
sh = sb->sh = sb->control.data;
sh->version = version;
sh->flags = 0;
sh->length = 0;
sb->cmd = 0;
sb->offset = 0;
@ -642,7 +605,6 @@ spa_control_builder_end (SpaControlBuilder *builder,
return SPA_RESULT_INVALID_ARGUMENTS;
sb->magic = 0;
sb->sh->length = sb->control.size - sizeof (SpaStackHeader);
sc->magic = SSC_MAGIC;
sc->data = sb->control.data;
@ -718,7 +680,7 @@ builder_ensure_size (struct stack_builder *sb, size_t size)
} else {
sb->control.free_data = realloc (sb->control.free_data, new_size);
}
sb->sh = sb->control.data = sb->control.free_data;
sb->control.data = sb->control.free_data;
}
return (uint8_t *) sb->control.data + sb->control.size;
}
@ -758,7 +720,7 @@ builder_add_node_update (struct stack_builder *sb, SpaControlCmdNodeUpdate *nu)
/* calc len */
len = sizeof (SpaControlCmdNodeUpdate);
len += spa_props_get_size (nu->props);
len += spa_serialize_props_get_size (nu->props);
p = builder_add_cmd (sb, SPA_CONTROL_CMD_NODE_UPDATE, len);
memcpy (p, nu, sizeof (SpaControlCmdNodeUpdate));
@ -766,7 +728,7 @@ builder_add_node_update (struct stack_builder *sb, SpaControlCmdNodeUpdate *nu)
p = SPA_MEMBER (d, sizeof (SpaControlCmdNodeUpdate), void);
if (nu->props) {
len = spa_props_serialize (p, nu->props);
len = spa_serialize_props_serialize (p, nu->props);
d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
} else {
d->props = 0;
@ -786,12 +748,12 @@ builder_add_port_update (struct stack_builder *sb, SpaControlCmdPortUpdate *pu)
len = sizeof (SpaControlCmdPortUpdate);
len += pu->n_possible_formats * sizeof (SpaFormat *);
for (i = 0; i < pu->n_possible_formats; i++) {
len += spa_format_get_size (pu->possible_formats[i]);
len += spa_serialize_format_get_size (pu->possible_formats[i]);
}
len += spa_format_get_size (pu->format);
len += spa_props_get_size (pu->props);
len += spa_serialize_format_get_size (pu->format);
len += spa_serialize_props_get_size (pu->props);
if (pu->info)
len += spa_port_info_get_size (pu->info);
len += spa_serialize_port_info_get_size (pu->info);
p = builder_add_cmd (sb, SPA_CONTROL_CMD_PORT_UPDATE, len);
memcpy (p, pu, sizeof (SpaControlCmdPortUpdate));
@ -807,26 +769,26 @@ builder_add_port_update (struct stack_builder *sb, SpaControlCmdPortUpdate *pu)
p = SPA_MEMBER (p, sizeof (SpaFormat*) * pu->n_possible_formats, void);
for (i = 0; i < pu->n_possible_formats; i++) {
len = spa_format_serialize (p, pu->possible_formats[i]);
len = spa_serialize_format_serialize (p, pu->possible_formats[i]);
bfa[i] = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
p = SPA_MEMBER (p, len, void);
}
if (pu->format) {
len = spa_format_serialize (p, pu->format);
len = spa_serialize_format_serialize (p, pu->format);
d->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
p = SPA_MEMBER (p, len, void);
} else {
d->format = 0;
}
if (pu->props) {
len = spa_props_serialize (p, pu->props);
len = spa_serialize_props_serialize (p, pu->props);
d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
p = SPA_MEMBER (p, len, void);
} else {
d->props = 0;
}
if (pu->info) {
len = spa_port_info_serialize (p, pu->info);
len = spa_serialize_port_info_serialize (p, pu->info);
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
p = SPA_MEMBER (p, len, void);
} else {
@ -842,14 +804,14 @@ builder_add_set_format (struct stack_builder *sb, SpaControlCmdSetFormat *sf)
/* calculate length */
/* port_id + format + mask */
len = sizeof (SpaControlCmdSetFormat) + spa_format_get_size (sf->format);
len = sizeof (SpaControlCmdSetFormat) + spa_serialize_format_get_size (sf->format);
p = builder_add_cmd (sb, SPA_CONTROL_CMD_SET_FORMAT, len);
memcpy (p, sf, sizeof (SpaControlCmdSetFormat));
sf = p;
p = SPA_MEMBER (sf, sizeof (SpaControlCmdSetFormat), void);
if (sf->format) {
len = spa_format_serialize (p, sf->format);
len = spa_serialize_format_serialize (p, sf->format);
sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf));
} else
sf->format = 0;
@ -1040,9 +1002,7 @@ spa_control_read (SpaControl *control,
unsigned int max_fds)
{
ssize_t len;
SpaStackHeader *hdr;
SpaStackControl *sc = (SpaStackControl *) control;
size_t need;
struct cmsghdr *cmsg;
struct msghdr msg = {0};
struct iovec iov[1];
@ -1056,11 +1016,10 @@ spa_control_read (SpaControl *control,
sc->max_fds = max_fds;
sc->n_fds = 0;
sc->free_fds = NULL;
hdr = sc->data;
/* read header and control messages first */
iov[0].iov_base = hdr;
iov[0].iov_len = sizeof (SpaStackHeader);;
iov[0].iov_base = sc->data;
iov[0].iov_len = sc->max_size;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_control = cmsgbuf;
@ -1077,24 +1036,18 @@ spa_control_read (SpaControl *control,
}
break;
}
if (len != sizeof (SpaStackHeader))
if (len < 4)
return SPA_RESULT_ERROR;
/* now we know the total length */
need = sizeof (SpaStackHeader) + hdr->length;
sc->size = len;
#if 0
if (sc->max_size < need) {
fprintf (stderr, "control: realloc receive memory %zd -> %zd\n", sc->max_size, need);
sc->max_size = need;
if (sc->free_data == NULL) {
sc->free_data = malloc (need);
memcpy (sc->free_data, sc->data, len);
} else {
sc->free_data = realloc (sc->free_data, need);
}
sc->free_data = realloc (sc->free_data, need);
hdr = sc->data = sc->free_data;
}
sc->size = need;
if (hdr->length > 0) {
/* read data */
@ -1111,6 +1064,7 @@ spa_control_read (SpaControl *control,
if (len != hdr->length)
goto wrong_length;
}
#endif
/* handle control messages */
for (cmsg = CMSG_FIRSTHDR (&msg); cmsg != NULL; cmsg = CMSG_NXTHDR (&msg, cmsg)) {
@ -1132,11 +1086,6 @@ recv_error:
fprintf (stderr, "could not recvmsg: %s\n", strerror (errno));
return SPA_RESULT_ERROR;
}
wrong_length:
{
fprintf (stderr, "wrong header length %zd != %u\n", len, hdr->length);
return SPA_RESULT_ERROR;
}
}

View file

@ -48,7 +48,6 @@ SpaResult spa_control_init_data (SpaControl *control,
SpaResult spa_control_clear (SpaControl *control);
uint32_t spa_control_get_version (SpaControl *control);
int spa_control_get_fd (SpaControl *control,
unsigned int index,
bool close);
@ -206,10 +205,8 @@ struct _SpaControlIter {
size_t x[16];
};
SpaResult spa_control_iter_init_full (SpaControlIter *iter,
SpaControl *control,
uint32_t version);
#define spa_control_iter_init(i,b) spa_control_iter_init_full(i,b, SPA_CONTROL_VERSION);
SpaResult spa_control_iter_init (SpaControlIter *iter,
SpaControl *control);
SpaResult spa_control_iter_next (SpaControlIter *iter);
SpaResult spa_control_iter_end (SpaControlIter *iter);
@ -232,13 +229,11 @@ struct _SpaControlBuilder {
size_t x[16];
};
SpaResult spa_control_builder_init_full (SpaControlBuilder *builder,
uint32_t version,
SpaResult spa_control_builder_init_into (SpaControlBuilder *builder,
void *data,
size_t max_data,
int *fds,
unsigned int max_fds);
#define spa_control_builder_init_into(b,d,md,f,mf) spa_control_builder_init_full(b, SPA_CONTROL_VERSION,d,md,f,mf);
#define spa_control_builder_init(b) spa_control_builder_init_into(b, NULL, 0, NULL, 0);
SpaResult spa_control_builder_clear (SpaControlBuilder *builder);

View file

@ -19,6 +19,7 @@
#include <pinos/client/pinos.h>
#include <pinos/client/format.h>
#include <pinos/client/serialize.h>
static SpaFormat *
format_copy (SpaFormat *format)
@ -29,9 +30,9 @@ format_copy (SpaFormat *format)
if (format == NULL)
return NULL;
size = spa_format_get_size (format);
size = spa_serialize_format_get_size (format);
p = malloc (size);
return spa_format_copy_into (p, format);
return spa_serialize_format_copy_into (p, format);
}
static void

View file

@ -12,10 +12,12 @@ pinos_headers = [
pinos_sources = [
'context.c',
'control.c',
'format.c',
'introspect.c',
'mainloop.c',
'properties.c',
'serialize.c',
'stream.c',
'pinos.c',
'ringbuffer.c',

354
pinos/client/serialize.c Normal file
View file

@ -0,0 +1,354 @@
/* 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.
*/
#include "serialize.h"
size_t
spa_serialize_buffer_get_size (const SpaBuffer *buffer)
{
size_t size;
unsigned int i;
if (buffer == NULL)
return 0;
size = sizeof (SpaBuffer);
for (i = 0; i < buffer->n_metas; i++)
size += sizeof (SpaMeta) + buffer->metas[i].size;
for (i = 0; i < buffer->n_datas; i++)
size += sizeof (SpaData);
return size;
}
size_t
spa_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
{
SpaBuffer *tb;
SpaMeta *mp;
SpaData *dp;
void *p;
unsigned int i;
if (buffer == NULL)
return 0;
tb = dest;
memcpy (tb, buffer, sizeof (SpaBuffer));
mp = SPA_MEMBER (tb, sizeof(SpaBuffer), SpaMeta);
dp = SPA_MEMBER (mp, sizeof(SpaMeta) * tb->n_metas, SpaData);
p = SPA_MEMBER (dp, sizeof(SpaData) * tb->n_datas, void);
tb->metas = SPA_INT_TO_PTR (SPA_PTRDIFF (mp, tb));
tb->datas = SPA_INT_TO_PTR (SPA_PTRDIFF (dp, tb));
for (i = 0; i < tb->n_metas; i++) {
memcpy (&mp[i], &buffer->metas[i], sizeof (SpaMeta));
memcpy (p, mp[i].data, mp[i].size);
mp[i].data = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tb));
p += mp[i].size;
}
for (i = 0; i < tb->n_datas; i++)
memcpy (&dp[i], &buffer->datas[i], sizeof (SpaData));
return SPA_PTRDIFF (p, tb);
}
SpaBuffer *
spa_serialize_buffer_deserialize (void *src, off_t offset)
{
SpaBuffer *b;
unsigned int i;
b = SPA_MEMBER (src, offset, SpaBuffer);
if (b->metas)
b->metas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->metas), SpaMeta);
for (i = 0; i < b->n_metas; i++) {
SpaMeta *m = &b->metas[i];
if (m->data)
m->data = SPA_MEMBER (b, SPA_PTR_TO_INT (m->data), void);
}
if (b->datas)
b->datas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->datas), SpaData);
return b;
}
size_t
spa_serialize_format_get_size (const SpaFormat *format)
{
if (format == NULL)
return 0;
return spa_serialize_props_get_size (&format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
}
size_t
spa_serialize_format_serialize (void *dest, const SpaFormat *format)
{
SpaFormat *tf;
size_t size;
if (format == NULL)
return 0;
tf = dest;
tf->media_type = format->media_type;
tf->media_subtype = format->media_subtype;
dest = SPA_MEMBER (tf, offsetof (SpaFormat, props), void);
size = spa_serialize_props_serialize (dest, &format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
return size;
}
SpaFormat *
spa_serialize_format_deserialize (void *src, off_t offset)
{
SpaFormat *f;
f = SPA_MEMBER (src, offset, SpaFormat);
spa_serialize_props_deserialize (f, offsetof (SpaFormat, props));
return f;
}
SpaFormat *
spa_serialize_format_copy_into (void *dest, const SpaFormat *format)
{
if (format == NULL)
return NULL;
spa_serialize_format_serialize (dest, format);
return spa_serialize_format_deserialize (dest, 0);
}
size_t
spa_serialize_port_info_get_size (const SpaPortInfo *info)
{
size_t len;
unsigned int i;
if (info == NULL)
return 0;
len = sizeof (SpaPortInfo);
len += info->n_params * sizeof (SpaAllocParam *);
for (i = 0; i < info->n_params; i++)
len += info->params[i]->size;
return len;
}
size_t
spa_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
{
SpaPortInfo *pi;
SpaAllocParam **ap;
int i;
size_t len;
if (info == NULL)
return 0;
pi = p;
memcpy (pi, info, sizeof (SpaPortInfo));
ap = SPA_MEMBER (pi, sizeof (SpaPortInfo), SpaAllocParam *);
if (info->n_params)
pi->params = SPA_INT_TO_PTR (SPA_PTRDIFF (ap, pi));
else
pi->params = 0;
pi->extra = 0;
p = SPA_MEMBER (ap, sizeof (SpaAllocParam*) * info->n_params, void);
for (i = 0; i < info->n_params; i++) {
len = info->params[i]->size;
memcpy (p, info->params[i], len);
ap[i] = SPA_INT_TO_PTR (SPA_PTRDIFF (p, pi));
p = SPA_MEMBER (p, len, void);
}
return SPA_PTRDIFF (p, pi);
}
SpaPortInfo *
spa_serialize_port_info_deserialize (void *p, off_t offset)
{
SpaPortInfo *pi;
unsigned int i;
pi = SPA_MEMBER (p, offset, SpaPortInfo);
if (pi->params)
pi->params = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->params), SpaAllocParam *);
for (i = 0; i < pi->n_params; i++) {
pi->params[i] = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->params[i]), SpaAllocParam);
}
return pi;
}
SpaPortInfo *
spa_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info)
{
if (info == NULL)
return NULL;
spa_serialize_port_info_serialize (dest, info);
return spa_serialize_port_info_deserialize (dest, 0);
}
size_t
spa_serialize_props_get_size (const SpaProps *props)
{
size_t len;
unsigned int i, j;
SpaPropInfo *pi;
SpaPropRangeInfo *ri;
if (props == NULL)
return 0;
len = sizeof (SpaProps);
for (i = 0; i < props->n_prop_info; i++) {
pi = (SpaPropInfo *) &props->prop_info[i];
len += sizeof (SpaPropInfo);
len += pi->name ? strlen (pi->name) + 1 : 0;
/* for the value */
len += pi->maxsize;
for (j = 0; j < pi->n_range_values; j++) {
ri = (SpaPropRangeInfo *)&pi->range_values[j];
len += sizeof (SpaPropRangeInfo);
len += ri->name ? strlen (ri->name) + 1 : 0;
/* the size of the range value */
len += ri->val.size;
}
}
return len;
}
size_t
spa_serialize_props_serialize (void *p, const SpaProps *props)
{
size_t len, slen;
unsigned int i, j, c;
SpaProps *tp;
SpaPropInfo *pi;
SpaPropRangeInfo *ri;
if (props == NULL)
return 0;
tp = p;
memcpy (tp, props, sizeof (SpaProps));
pi = SPA_MEMBER (tp, sizeof(SpaProps), SpaPropInfo);
ri = SPA_MEMBER (pi, sizeof(SpaPropInfo) * tp->n_prop_info, SpaPropRangeInfo);
tp->prop_info = SPA_INT_TO_PTR (SPA_PTRDIFF (pi, tp));
/* write propinfo array */
for (i = 0, c = 0; i < tp->n_prop_info; i++) {
memcpy (&pi[i], &props->prop_info[i], sizeof (SpaPropInfo));
pi[i].range_values = SPA_INT_TO_PTR (SPA_PTRDIFF (&ri[c], tp));
for (j = 0; j < pi[i].n_range_values; j++, c++) {
memcpy (&ri[c], &props->prop_info[i].range_values[j], sizeof (SpaPropRangeInfo));
}
}
p = &ri[c];
/* strings and default values from props and ranges */
for (i = 0, c = 0; i < tp->n_prop_info; i++) {
if (pi[i].name) {
slen = strlen (pi[i].name) + 1;
memcpy (p, pi[i].name, slen);
pi[i].name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += slen;
} else {
pi[i].name = 0;
}
for (j = 0; j < pi[i].n_range_values; j++, c++) {
if (ri[c].name) {
slen = strlen (ri[c].name) + 1;
memcpy (p, ri[c].name, slen);
ri[c].name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += slen;
} else {
ri[c].name = 0;
}
if (ri[c].val.size) {
memcpy (p, ri[c].val.value, ri[c].val.size);
ri[c].val.value = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += ri[c].val.size;
} else {
ri[c].val.value = 0;
}
}
}
/* and the actual values */
for (i = 0; i < tp->n_prop_info; i++) {
if (pi[i].offset) {
memcpy (p, SPA_MEMBER (props, pi[i].offset, void), pi[i].maxsize);
pi[i].offset = SPA_PTRDIFF (p, tp);
p += pi[i].maxsize;
} else {
pi[i].offset = 0;
}
}
len = SPA_PTRDIFF (p, tp);
return len;
}
SpaProps *
spa_serialize_props_deserialize (void *p, off_t offset)
{
SpaProps *tp;
unsigned int i, j;
SpaPropInfo *pi;
SpaPropRangeInfo *ri;
tp = SPA_MEMBER (p, offset, SpaProps);
if (tp->prop_info)
tp->prop_info = SPA_MEMBER (tp, SPA_PTR_TO_INT (tp->prop_info), SpaPropInfo);
/* now fix all the pointers */
for (i = 0; i < tp->n_prop_info; i++) {
pi = (SpaPropInfo *) &tp->prop_info[i];
if (pi->name)
pi->name = SPA_MEMBER (tp, SPA_PTR_TO_INT (pi->name), char);
if (pi->range_values)
pi->range_values = SPA_MEMBER (tp, SPA_PTR_TO_INT (pi->range_values), SpaPropRangeInfo);
for (j = 0; j < pi->n_range_values; j++) {
ri = (SpaPropRangeInfo *) &pi->range_values[j];
if (ri->name)
ri->name = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->name), char);
if (ri->val.value)
ri->val.value = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->val.value), void);
}
}
return tp;
}
SpaProps *
spa_serialize_props_copy_into (void *dest, const SpaProps *props)
{
if (props == NULL)
return NULL;
spa_serialize_props_serialize (dest, props);
return spa_serialize_props_deserialize (dest, 0);
}

55
pinos/client/serialize.h Normal file
View file

@ -0,0 +1,55 @@
/* 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_SERIALIZE_H__
#define __SPA_SERIALIZE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/include/spa/buffer.h>
#include <spa/include/spa/format.h>
#include <spa/include/spa/props.h>
#include <spa/include/spa/port.h>
size_t spa_serialize_buffer_get_size (const SpaBuffer *buffer);
size_t spa_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer);
SpaBuffer * spa_serialize_buffer_deserialize (void *src, off_t offset);
size_t spa_serialize_format_get_size (const SpaFormat *format);
size_t spa_serialize_format_serialize (void *dest, const SpaFormat *format);
SpaFormat * spa_serialize_format_deserialize (void *src, off_t offset);
SpaFormat * spa_serialize_format_copy_into (void *dest, const SpaFormat *format);
size_t spa_serialize_port_info_get_size (const SpaPortInfo *info);
size_t spa_serialize_port_info_serialize (void *dest, const SpaPortInfo *info);
SpaPortInfo * spa_serialize_port_info_deserialize (void *src, off_t offset);
SpaPortInfo * spa_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info);
size_t spa_serialize_props_get_size (const SpaProps *props);
size_t spa_serialize_props_serialize (void *dest, const SpaProps *props);
SpaProps * spa_serialize_props_deserialize (void *src, off_t offset);
SpaProps * spa_serialize_props_copy_into (void *dest, const SpaProps *props);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_SERIALIZE_H__ */

View file

@ -22,7 +22,6 @@
#include <sys/mman.h>
#include <errno.h>
#include "spa/include/spa/control.h"
#include "spa/include/spa/debug.h"
#include <gio/gio.h>
@ -32,11 +31,13 @@
#include "pinos/dbus/org-pinos.h"
#include "pinos/server/daemon.h"
#include "pinos/client/pinos.h"
#include "pinos/client/control.h"
#include "pinos/client/context.h"
#include "pinos/client/stream.h"
#include "pinos/client/enumtypes.h"
#include "pinos/client/format.h"
#include "pinos/client/private.h"
#include "pinos/client/serialize.h"
#define MAX_BUFFER_SIZE 4096
#define MAX_FDS 32
@ -1048,8 +1049,8 @@ parse_control (PinosStream *stream,
if (priv->format)
g_free (priv->format);
mem = malloc (spa_format_get_size (p.format));
priv->format = spa_format_copy_into (mem, p.format);
mem = malloc (spa_serialize_format_get_size (p.format));
priv->format = spa_serialize_format_copy_into (mem, p.format);
spa_debug_format (p.format);
priv->pending_seq = p.seq;

File diff suppressed because it is too large Load diff

View file

@ -36,9 +36,6 @@
#include "pinos/dbus/org-pinos.h"
#include "spa/include/spa/control.h"
struct _PinosDBusClientNodePrivate
{
int fd;

View file

@ -174,7 +174,7 @@ struct _SpaBuffer {
SpaData *datas;
};
inline void *
static inline void *
spa_buffer_find_meta (SpaBuffer *b, SpaMetaType type)
{
unsigned int i;
@ -185,11 +185,20 @@ spa_buffer_find_meta (SpaBuffer *b, SpaMetaType type)
return NULL;
}
size_t spa_buffer_get_size (const SpaBuffer *buffer);
size_t spa_buffer_serialize (void *dest, const SpaBuffer *buffer);
SpaBuffer * spa_buffer_deserialize (void *src, off_t offset);
size_t spa_meta_type_get_size (SpaMetaType type);
static inline size_t
spa_meta_type_get_size (SpaMetaType type)
{
static const size_t header_sizes[] = {
0,
sizeof (SpaMetaHeader),
sizeof (SpaMetaPointer),
sizeof (SpaMetaVideoCrop),
sizeof (SpaMetaRingbuffer),
};
if (type <= 0 || type >= SPA_N_ELEMENTS (header_sizes))
return 0;
return header_sizes[type];
}
#ifdef __cplusplus
} /* extern "C" */

View file

@ -98,14 +98,15 @@ typedef enum {
} SpaFormatProps;
SpaResult spa_format_fixate (SpaFormat *format);
size_t spa_format_get_size (const SpaFormat *format);
size_t spa_format_serialize (void *dest, const SpaFormat *format);
SpaFormat * spa_format_deserialize (void *src, off_t offset);
SpaFormat * spa_format_copy_into (void *dest, const SpaFormat *format);
static inline SpaResult
spa_format_fixate (SpaFormat *format)
{
if (format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
format->props.unset_mask = 0;
return SPA_RESULT_OK;
}
#ifdef __cplusplus
} /* extern "C" */

View file

@ -107,6 +107,8 @@ struct _SpaLog {
va_list args) SPA_PRINTF_FUNC(6, 0);
};
#define spa_log_level_enabled(l,lev) ((l) && (l)->level >= (lev))
#if __STDC_VERSION__ >= 199901L
#define spa_log_log(l,lev,...) \
@ -124,7 +126,7 @@ struct _SpaLog {
#define SPA_LOG_FUNC(name,lev) \
static inline void spa_log_##name (SpaLog *l, const char *format, ...) \
{ \
if ((l) && (l)->level >= lev) { \
if (spa_log_level_enabled (l, lev)) { \
va_list varargs; \
va_start (varargs, format); \
(l)->logv((l),lev,__FILE__,__LINE__,__func__,format,varargs); \

View file

@ -124,12 +124,6 @@ typedef struct {
} SpaPortInfo;
size_t spa_port_info_get_size (const SpaPortInfo *info);
size_t spa_port_info_serialize (void *dest, const SpaPortInfo *info);
SpaPortInfo * spa_port_info_deserialize (void *src, off_t offset);
SpaPortInfo * spa_port_info_copy_into (void *dest, const SpaPortInfo *info);
/**
* SpaPortStatusFlags:
* @SPA_PORT_STATUS_FLAG_NONE: no status flags

View file

@ -235,13 +235,6 @@ SpaResult spa_props_copy_values (const SpaProps *src,
SpaProps *dest);
size_t spa_props_get_size (const SpaProps *props);
size_t spa_props_serialize (void *dest, const SpaProps *props);
SpaProps * spa_props_deserialize (void *src, off_t offset);
SpaProps * spa_props_copy_into (void *dest, const SpaProps *props);
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -1,113 +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.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <spa/buffer.h>
#include <spa/port.h>
static const size_t header_sizes[] = {
0,
sizeof (SpaMetaHeader),
sizeof (SpaMetaPointer),
sizeof (SpaMetaVideoCrop),
sizeof (SpaMetaRingbuffer),
};
size_t
spa_meta_type_get_size (SpaMetaType type)
{
if (type <= 0 || type >= SPA_N_ELEMENTS (header_sizes))
return 0;
return header_sizes[type];
}
size_t
spa_buffer_get_size (const SpaBuffer *buffer)
{
size_t size;
unsigned int i;
if (buffer == NULL)
return 0;
size = sizeof (SpaBuffer);
for (i = 0; i < buffer->n_metas; i++)
size += sizeof (SpaMeta) + buffer->metas[i].size;
for (i = 0; i < buffer->n_datas; i++)
size += sizeof (SpaData);
return size;
}
size_t
spa_buffer_serialize (void *dest, const SpaBuffer *buffer)
{
SpaBuffer *tb;
SpaMeta *mp;
SpaData *dp;
void *p;
unsigned int i;
if (buffer == NULL)
return 0;
tb = dest;
memcpy (tb, buffer, sizeof (SpaBuffer));
mp = SPA_MEMBER (tb, sizeof(SpaBuffer), SpaMeta);
dp = SPA_MEMBER (mp, sizeof(SpaMeta) * tb->n_metas, SpaData);
p = SPA_MEMBER (dp, sizeof(SpaData) * tb->n_datas, void);
tb->metas = SPA_INT_TO_PTR (SPA_PTRDIFF (mp, tb));
tb->datas = SPA_INT_TO_PTR (SPA_PTRDIFF (dp, tb));
for (i = 0; i < tb->n_metas; i++) {
memcpy (&mp[i], &buffer->metas[i], sizeof (SpaMeta));
memcpy (p, mp[i].data, mp[i].size);
mp[i].data = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tb));
p += mp[i].size;
}
for (i = 0; i < tb->n_datas; i++)
memcpy (&dp[i], &buffer->datas[i], sizeof (SpaData));
return SPA_PTRDIFF (p, tb);
}
SpaBuffer *
spa_buffer_deserialize (void *src, off_t offset)
{
SpaBuffer *b;
unsigned int i;
b = SPA_MEMBER (src, offset, SpaBuffer);
if (b->metas)
b->metas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->metas), SpaMeta);
for (i = 0; i < b->n_metas; i++) {
SpaMeta *m = &b->metas[i];
if (m->data)
m->data = SPA_MEMBER (b, SPA_PTR_TO_INT (m->data), void);
}
if (b->datas)
b->datas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->datas), SpaData);
return b;
}

View file

@ -1,87 +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.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <spa/format.h>
#include <spa/debug.h>
SpaResult
spa_format_fixate (SpaFormat *format)
{
if (format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
format->props.unset_mask = 0;
return SPA_RESULT_OK;
}
size_t
spa_format_get_size (const SpaFormat *format)
{
if (format == NULL)
return 0;
return spa_props_get_size (&format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
}
size_t
spa_format_serialize (void *dest, const SpaFormat *format)
{
SpaFormat *tf;
size_t size;
if (format == NULL)
return 0;
tf = dest;
tf->media_type = format->media_type;
tf->media_subtype = format->media_subtype;
dest = SPA_MEMBER (tf, offsetof (SpaFormat, props), void);
size = spa_props_serialize (dest, &format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
return size;
}
SpaFormat *
spa_format_deserialize (void *src, off_t offset)
{
SpaFormat *f;
f = SPA_MEMBER (src, offset, SpaFormat);
spa_props_deserialize (f, offsetof (SpaFormat, props));
return f;
}
SpaFormat *
spa_format_copy_into (void *dest, const SpaFormat *format)
{
if (format == NULL)
return NULL;
spa_format_serialize (dest, format);
return spa_format_deserialize (dest, 0);
}

View file

@ -38,54 +38,53 @@
#include <spa/ringbuffer.h>
#include <spa/debug.h>
static const char *uris[] = {
NULL,
SPA_ID_MAP_URI,
SPA_LOG_URI,
SPA_BUFFER_URI,
SPA_CLOCK_URI,
SPA_MONITOR_URI,
SPA_NODE_URI,
SPA_NODE_COMMAND_URI,
SPA_NODE_EVENT_URI,
SPA_ALLOC_PARAM_URI,
SPA_PROPS_URI,
SPA_QUEUE_URI,
SPA_RINGBUFFER_URI,
SPA_POLL__MainLoop,
SPA_POLL__DataLoop,
};
#define MAX_URIS 4096
typedef struct {
SpaIDMap map;
char *uris[MAX_URIS];
unsigned int n_uris;
} IDMap;
static uint32_t
id_map_get_id (SpaIDMap *map, const char *uri)
{
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map);
unsigned int i = 0;
if (uri != NULL) {
unsigned int i;
for (i = 1; i < SPA_N_ELEMENTS (uris); i++) {
if (strcmp (uris[i], uri) == 0)
for (i = 1; i <= this->n_uris; i++) {
if (strcmp (this->uris[i], uri) == 0)
return i;
}
this->uris[i] = (char *)uri;
this->n_uris++;
}
return 0;
return i;
}
static const char *
id_map_get_uri (SpaIDMap *map, uint32_t id)
{
if (id < SPA_N_ELEMENTS (uris))
return uris[id];
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map);
if (id < this->n_uris)
return this->uris[id];
return 0;
}
static const SpaIDMap default_map = {
sizeof (SpaIDMap),
NULL,
id_map_get_id,
id_map_get_uri,
static IDMap default_id_map = {
{ sizeof (SpaIDMap),
NULL,
id_map_get_id,
id_map_get_uri,
},
{ NULL, },
0
};
SpaIDMap *
spa_id_map_get_default (void)
{
return (SpaIDMap *) &default_map;
return &default_id_map.map;
}

View file

@ -1,10 +1,6 @@
spalib_sources = ['audio-raw.c',
'buffer.c',
'control.c',
'debug.c',
'format.c',
'mapper.c',
'port.c',
'props.c',
'video-raw.c']

View file

@ -1,101 +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.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <spa/port.h>
#include <spa/debug.h>
size_t
spa_port_info_get_size (const SpaPortInfo *info)
{
size_t len;
unsigned int i;
if (info == NULL)
return 0;
len = sizeof (SpaPortInfo);
len += info->n_params * sizeof (SpaAllocParam *);
for (i = 0; i < info->n_params; i++)
len += info->params[i]->size;
return len;
}
size_t
spa_port_info_serialize (void *p, const SpaPortInfo *info)
{
SpaPortInfo *pi;
SpaAllocParam **ap;
int i;
size_t len;
if (info == NULL)
return 0;
pi = p;
memcpy (pi, info, sizeof (SpaPortInfo));
ap = SPA_MEMBER (pi, sizeof (SpaPortInfo), SpaAllocParam *);
if (info->n_params)
pi->params = SPA_INT_TO_PTR (SPA_PTRDIFF (ap, pi));
else
pi->params = 0;
pi->extra = 0;
p = SPA_MEMBER (ap, sizeof (SpaAllocParam*) * info->n_params, void);
for (i = 0; i < info->n_params; i++) {
len = info->params[i]->size;
memcpy (p, info->params[i], len);
ap[i] = SPA_INT_TO_PTR (SPA_PTRDIFF (p, pi));
p = SPA_MEMBER (p, len, void);
}
return SPA_PTRDIFF (p, pi);
}
SpaPortInfo *
spa_port_info_deserialize (void *p, off_t offset)
{
SpaPortInfo *pi;
unsigned int i;
pi = SPA_MEMBER (p, offset, SpaPortInfo);
if (pi->params)
pi->params = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->params), SpaAllocParam *);
for (i = 0; i < pi->n_params; i++) {
pi->params[i] = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->params[i]), SpaAllocParam);
}
return pi;
}
SpaPortInfo *
spa_port_info_copy_into (void *dest, const SpaPortInfo *info)
{
if (info == NULL)
return NULL;
spa_port_info_serialize (dest, info);
return spa_port_info_deserialize (dest, 0);
}

View file

@ -102,143 +102,3 @@ spa_props_copy_values (const SpaProps *src,
}
return SPA_RESULT_OK;
}
size_t
spa_props_get_size (const SpaProps *props)
{
size_t len;
unsigned int i, j;
SpaPropInfo *pi;
SpaPropRangeInfo *ri;
if (props == NULL)
return 0;
len = sizeof (SpaProps);
for (i = 0; i < props->n_prop_info; i++) {
pi = (SpaPropInfo *) &props->prop_info[i];
len += sizeof (SpaPropInfo);
len += pi->name ? strlen (pi->name) + 1 : 0;
/* for the value */
len += pi->maxsize;
for (j = 0; j < pi->n_range_values; j++) {
ri = (SpaPropRangeInfo *)&pi->range_values[j];
len += sizeof (SpaPropRangeInfo);
len += ri->name ? strlen (ri->name) + 1 : 0;
/* the size of the range value */
len += ri->val.size;
}
}
return len;
}
size_t
spa_props_serialize (void *p, const SpaProps *props)
{
size_t len, slen;
unsigned int i, j, c;
SpaProps *tp;
SpaPropInfo *pi;
SpaPropRangeInfo *ri;
if (props == NULL)
return 0;
tp = p;
memcpy (tp, props, sizeof (SpaProps));
pi = SPA_MEMBER (tp, sizeof(SpaProps), SpaPropInfo);
ri = SPA_MEMBER (pi, sizeof(SpaPropInfo) * tp->n_prop_info, SpaPropRangeInfo);
tp->prop_info = SPA_INT_TO_PTR (SPA_PTRDIFF (pi, tp));
/* write propinfo array */
for (i = 0, c = 0; i < tp->n_prop_info; i++) {
memcpy (&pi[i], &props->prop_info[i], sizeof (SpaPropInfo));
pi[i].range_values = SPA_INT_TO_PTR (SPA_PTRDIFF (&ri[c], tp));
for (j = 0; j < pi[i].n_range_values; j++, c++) {
memcpy (&ri[c], &props->prop_info[i].range_values[j], sizeof (SpaPropRangeInfo));
}
}
p = &ri[c];
/* strings and default values from props and ranges */
for (i = 0, c = 0; i < tp->n_prop_info; i++) {
if (pi[i].name) {
slen = strlen (pi[i].name) + 1;
memcpy (p, pi[i].name, slen);
pi[i].name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += slen;
} else {
pi[i].name = 0;
}
for (j = 0; j < pi[i].n_range_values; j++, c++) {
if (ri[c].name) {
slen = strlen (ri[c].name) + 1;
memcpy (p, ri[c].name, slen);
ri[c].name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += slen;
} else {
ri[c].name = 0;
}
if (ri[c].val.size) {
memcpy (p, ri[c].val.value, ri[c].val.size);
ri[c].val.value = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += ri[c].val.size;
} else {
ri[c].val.value = 0;
}
}
}
/* and the actual values */
for (i = 0; i < tp->n_prop_info; i++) {
if (pi[i].offset) {
memcpy (p, SPA_MEMBER (props, pi[i].offset, void), pi[i].maxsize);
pi[i].offset = SPA_PTRDIFF (p, tp);
p += pi[i].maxsize;
} else {
pi[i].offset = 0;
}
}
len = SPA_PTRDIFF (p, tp);
return len;
}
SpaProps *
spa_props_deserialize (void *p, off_t offset)
{
SpaProps *tp;
unsigned int i, j;
SpaPropInfo *pi;
SpaPropRangeInfo *ri;
tp = SPA_MEMBER (p, offset, SpaProps);
if (tp->prop_info)
tp->prop_info = SPA_MEMBER (tp, SPA_PTR_TO_INT (tp->prop_info), SpaPropInfo);
/* now fix all the pointers */
for (i = 0; i < tp->n_prop_info; i++) {
pi = (SpaPropInfo *) &tp->prop_info[i];
if (pi->name)
pi->name = SPA_MEMBER (tp, SPA_PTR_TO_INT (pi->name), char);
if (pi->range_values)
pi->range_values = SPA_MEMBER (tp, SPA_PTR_TO_INT (pi->range_values), SpaPropRangeInfo);
for (j = 0; j < pi->n_range_values; j++) {
ri = (SpaPropRangeInfo *) &pi->range_values[j];
if (ri->name)
ri->name = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->name), char);
if (ri->val.value)
ri->val.value = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->val.value), void);
}
}
return tp;
}
SpaProps *
spa_props_copy_into (void *dest, const SpaProps *props)
{
if (props == NULL)
return NULL;
spa_props_serialize (dest, props);
return spa_props_deserialize (dest, 0);
}

View file

@ -2,7 +2,6 @@ subdir('alsa')
subdir('audiomixer')
subdir('audiotestsrc')
subdir('ffmpeg')
subdir('remote')
#subdir('libva')
subdir('videotestsrc')
subdir('volume')

File diff suppressed because it is too large Load diff

View file

@ -1,10 +0,0 @@
remote_sources = ['proxy.c',
'dbus-proxy.c',
'plugin.c']
remotelib = shared_library('spa-remote',
remote_sources,
include_directories : spa_inc,
link_with : spalib,
install : true,
install_dir : '@0@/spa'.format(get_option('libdir')))

View file

@ -1,50 +0,0 @@
/* Spa Volume plugin
* 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.
*/
#include <spa/plugin.h>
#include <spa/node.h>
extern const SpaHandleFactory spa_proxy_factory;
extern const SpaHandleFactory spa_dbus_proxy_factory;
SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
void **state)
{
int index;
if (factory == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
index = (*state == NULL ? 0 : *(int*)state);
switch (index) {
case 0:
*factory = &spa_proxy_factory;
break;
case 1:
*factory = &spa_dbus_proxy_factory;
break;
default:
return SPA_RESULT_ENUM_END;
}
*(int*)state = ++index;
return SPA_RESULT_OK;
}

File diff suppressed because it is too large Load diff