spa_serialize -> pinos_serialize
Improve PinosPort, move links to the object and make it part of
PinosNode
Work on improving signals to react to changes in the graph
Error when a client-node becomes unlinked, like when removing a camera.
This commit is contained in:
Wim Taymans 2016-10-19 17:18:30 +02:00
parent 70fb53cdc6
commit 98dbb6424d
13 changed files with 350 additions and 339 deletions

View file

@ -84,7 +84,7 @@ connection_parse_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *
{
memcpy (nu, conn->in.data, sizeof (PinosControlCmdNodeUpdate));
if (nu->props)
nu->props = spa_serialize_props_deserialize (conn->in.data, SPA_PTR_TO_INT (nu->props));
nu->props = pinos_serialize_props_deserialize (conn->in.data, SPA_PTR_TO_INT (nu->props));
}
static void
@ -102,16 +102,16 @@ connection_parse_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *
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_serialize_format_deserialize (p,
pu->possible_formats[i] = pinos_serialize_format_deserialize (p,
SPA_PTR_TO_INT (pu->possible_formats[i]));
}
}
if (pu->format)
pu->format = spa_serialize_format_deserialize (p, SPA_PTR_TO_INT (pu->format));
pu->format = pinos_serialize_format_deserialize (p, SPA_PTR_TO_INT (pu->format));
if (pu->props)
pu->props = spa_serialize_props_deserialize (p, SPA_PTR_TO_INT (pu->props));
pu->props = pinos_serialize_props_deserialize (p, SPA_PTR_TO_INT (pu->props));
if (pu->info)
pu->info = spa_serialize_port_info_deserialize (p, SPA_PTR_TO_INT (pu->info));
pu->info = pinos_serialize_port_info_deserialize (p, SPA_PTR_TO_INT (pu->info));
}
static void
@ -119,7 +119,7 @@ connection_parse_set_format (PinosConnection *conn, PinosControlCmdSetFormat *cm
{
memcpy (cmd, conn->in.data, sizeof (PinosControlCmdSetFormat));
if (cmd->format)
cmd->format = spa_serialize_format_deserialize (conn->in.data, SPA_PTR_TO_INT (cmd->format));
cmd->format = pinos_serialize_format_deserialize (conn->in.data, SPA_PTR_TO_INT (cmd->format));
}
static void
@ -161,7 +161,7 @@ connection_ensure_size (PinosConnection *conn, ConnectionBuffer *buf, size_t siz
if (buf->buffer_size + size > buf->buffer_maxsize) {
buf->buffer_maxsize = buf->buffer_size + MAX_BUFFER_SIZE * ((size + MAX_BUFFER_SIZE-1) / MAX_BUFFER_SIZE);
buf->buffer_data = realloc (buf->buffer_data, buf->buffer_maxsize);
g_warning ("connection %p: resize buffer to %zd\n", conn, buf->buffer_maxsize);
g_debug ("connection %p: resize buffer to %zd", conn, buf->buffer_maxsize);
}
return (uint8_t *) buf->buffer_data + buf->buffer_size;
}
@ -202,7 +202,7 @@ connection_add_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *nu
/* calc len */
len = sizeof (PinosControlCmdNodeUpdate);
len += spa_serialize_props_get_size (nu->props);
len += pinos_serialize_props_get_size (nu->props);
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_UPDATE, len);
memcpy (p, nu, sizeof (PinosControlCmdNodeUpdate));
@ -210,7 +210,7 @@ connection_add_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *nu
p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeUpdate), void);
if (nu->props) {
len = spa_serialize_props_serialize (p, nu->props);
len = pinos_serialize_props_serialize (p, nu->props);
d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
} else {
d->props = 0;
@ -230,12 +230,12 @@ connection_add_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *pu
len = sizeof (PinosControlCmdPortUpdate);
len += pu->n_possible_formats * sizeof (SpaFormat *);
for (i = 0; i < pu->n_possible_formats; i++) {
len += spa_serialize_format_get_size (pu->possible_formats[i]);
len += pinos_serialize_format_get_size (pu->possible_formats[i]);
}
len += spa_serialize_format_get_size (pu->format);
len += spa_serialize_props_get_size (pu->props);
len += pinos_serialize_format_get_size (pu->format);
len += pinos_serialize_props_get_size (pu->props);
if (pu->info)
len += spa_serialize_port_info_get_size (pu->info);
len += pinos_serialize_port_info_get_size (pu->info);
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_PORT_UPDATE, len);
memcpy (p, pu, sizeof (PinosControlCmdPortUpdate));
@ -251,26 +251,26 @@ connection_add_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *pu
p = SPA_MEMBER (p, sizeof (SpaFormat*) * pu->n_possible_formats, void);
for (i = 0; i < pu->n_possible_formats; i++) {
len = spa_serialize_format_serialize (p, pu->possible_formats[i]);
len = pinos_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_serialize_format_serialize (p, pu->format);
len = pinos_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_serialize_props_serialize (p, pu->props);
len = pinos_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_serialize_port_info_serialize (p, pu->info);
len = pinos_serialize_port_info_serialize (p, pu->info);
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
p = SPA_MEMBER (p, len, void);
} else {
@ -286,14 +286,14 @@ connection_add_set_format (PinosConnection *conn, PinosControlCmdSetFormat *sf)
/* calculate length */
/* port_id + format + mask */
len = sizeof (PinosControlCmdSetFormat) + spa_serialize_format_get_size (sf->format);
len = sizeof (PinosControlCmdSetFormat) + pinos_serialize_format_get_size (sf->format);
p = connection_add_cmd (conn, PINOS_CONTROL_CMD_SET_FORMAT, len);
memcpy (p, sf, sizeof (PinosControlCmdSetFormat));
sf = p;
p = SPA_MEMBER (sf, sizeof (PinosControlCmdSetFormat), void);
if (sf->format) {
len = spa_serialize_format_serialize (p, sf->format);
len = pinos_serialize_format_serialize (p, sf->format);
sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf));
} else
sf->format = 0;
@ -428,7 +428,7 @@ refill_buffer (PinosConnection *conn, ConnectionBuffer *buf)
/* ERRORS */
recv_error:
{
g_warning ("could not recvmsg on fd %d: %s\n", conn->fd, strerror (errno));
g_warning ("could not recvmsg on fd %d: %s", conn->fd, strerror (errno));
return FALSE;
}
}
@ -557,7 +557,7 @@ pinos_connection_parse_cmd (PinosConnection *conn,
break;
case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
g_warning ("implement iter of %d\n", conn->in.cmd);
g_warning ("implement iter of %d", conn->in.cmd);
break;
case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
@ -584,7 +584,7 @@ pinos_connection_parse_cmd (PinosConnection *conn,
break;
case PINOS_CONTROL_CMD_SET_PROPERTY:
g_warning ("implement iter of %d\n", conn->in.cmd);
g_warning ("implement iter of %d", conn->in.cmd);
break;
/* bidirectional */
@ -739,7 +739,7 @@ pinos_connection_add_cmd (PinosConnection *conn,
break;
case PINOS_CONTROL_CMD_SET_PROPERTY:
g_warning ("implement builder of %d\n", cmd);
g_warning ("implement builder of %d", cmd);
break;
/* bidirectional */
@ -837,7 +837,7 @@ pinos_connection_flush (PinosConnection *conn)
/* ERRORS */
send_error:
{
g_warning ("could not sendmsg: %s\n", strerror (errno));
g_warning ("could not sendmsg: %s", strerror (errno));
return FALSE;
}
}

View file

@ -30,9 +30,9 @@ format_copy (SpaFormat *format)
if (format == NULL)
return NULL;
size = spa_serialize_format_get_size (format);
size = pinos_serialize_format_get_size (format);
p = malloc (size);
return spa_serialize_format_copy_into (p, format);
return pinos_serialize_format_copy_into (p, format);
}
static void

View file

@ -20,7 +20,7 @@
#include "serialize.h"
size_t
spa_serialize_buffer_get_size (const SpaBuffer *buffer)
pinos_serialize_buffer_get_size (const SpaBuffer *buffer)
{
size_t size;
unsigned int i;
@ -37,7 +37,7 @@ spa_serialize_buffer_get_size (const SpaBuffer *buffer)
}
size_t
spa_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
pinos_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
{
SpaBuffer *tb;
SpaMeta *mp;
@ -70,7 +70,7 @@ spa_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
}
SpaBuffer *
spa_serialize_buffer_deserialize (void *src, off_t offset)
pinos_serialize_buffer_deserialize (void *src, off_t offset)
{
SpaBuffer *b;
unsigned int i;
@ -91,16 +91,16 @@ spa_serialize_buffer_deserialize (void *src, off_t offset)
size_t
spa_serialize_format_get_size (const SpaFormat *format)
pinos_serialize_format_get_size (const SpaFormat *format)
{
if (format == NULL)
return 0;
return spa_serialize_props_get_size (&format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
return pinos_serialize_props_get_size (&format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
}
size_t
spa_serialize_format_serialize (void *dest, const SpaFormat *format)
pinos_serialize_format_serialize (void *dest, const SpaFormat *format)
{
SpaFormat *tf;
size_t size;
@ -113,34 +113,34 @@ spa_serialize_format_serialize (void *dest, const SpaFormat *format)
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);
size = pinos_serialize_props_serialize (dest, &format->props) - sizeof (SpaProps) + sizeof (SpaFormat);
return size;
}
SpaFormat *
spa_serialize_format_deserialize (void *src, off_t offset)
pinos_serialize_format_deserialize (void *src, off_t offset)
{
SpaFormat *f;
f = SPA_MEMBER (src, offset, SpaFormat);
spa_serialize_props_deserialize (f, offsetof (SpaFormat, props));
pinos_serialize_props_deserialize (f, offsetof (SpaFormat, props));
return f;
}
SpaFormat *
spa_serialize_format_copy_into (void *dest, const SpaFormat *format)
pinos_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);
pinos_serialize_format_serialize (dest, format);
return pinos_serialize_format_deserialize (dest, 0);
}
size_t
spa_serialize_port_info_get_size (const SpaPortInfo *info)
pinos_serialize_port_info_get_size (const SpaPortInfo *info)
{
size_t len;
unsigned int i;
@ -157,7 +157,7 @@ spa_serialize_port_info_get_size (const SpaPortInfo *info)
}
size_t
spa_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
pinos_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
{
SpaPortInfo *pi;
SpaAllocParam **ap;
@ -189,7 +189,7 @@ spa_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
}
SpaPortInfo *
spa_serialize_port_info_deserialize (void *p, off_t offset)
pinos_serialize_port_info_deserialize (void *p, off_t offset)
{
SpaPortInfo *pi;
unsigned int i;
@ -204,17 +204,17 @@ spa_serialize_port_info_deserialize (void *p, off_t offset)
}
SpaPortInfo *
spa_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info)
pinos_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);
pinos_serialize_port_info_serialize (dest, info);
return pinos_serialize_port_info_deserialize (dest, 0);
}
size_t
spa_serialize_props_get_size (const SpaProps *props)
pinos_serialize_props_get_size (const SpaProps *props)
{
size_t len;
unsigned int i, j;
@ -243,7 +243,7 @@ spa_serialize_props_get_size (const SpaProps *props)
}
size_t
spa_serialize_props_serialize (void *p, const SpaProps *props)
pinos_serialize_props_serialize (void *p, const SpaProps *props)
{
size_t len, slen;
unsigned int i, j, c;
@ -314,7 +314,7 @@ spa_serialize_props_serialize (void *p, const SpaProps *props)
}
SpaProps *
spa_serialize_props_deserialize (void *p, off_t offset)
pinos_serialize_props_deserialize (void *p, off_t offset)
{
SpaProps *tp;
unsigned int i, j;
@ -344,11 +344,11 @@ spa_serialize_props_deserialize (void *p, off_t offset)
}
SpaProps *
spa_serialize_props_copy_into (void *dest, const SpaProps *props)
pinos_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);
pinos_serialize_props_serialize (dest, props);
return pinos_serialize_props_deserialize (dest, 0);
}

View file

@ -17,39 +17,37 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_SERIALIZE_H__
#define __SPA_SERIALIZE_H__
#ifndef __PINOS_SERIALIZE_H__
#define __PINOS_SERIALIZE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <glib-object.h>
G_BEGIN_DECLS
#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 pinos_serialize_buffer_get_size (const SpaBuffer *buffer);
size_t pinos_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer);
SpaBuffer * pinos_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 pinos_serialize_format_get_size (const SpaFormat *format);
size_t pinos_serialize_format_serialize (void *dest, const SpaFormat *format);
SpaFormat * pinos_serialize_format_deserialize (void *src, off_t offset);
SpaFormat * pinos_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 pinos_serialize_port_info_get_size (const SpaPortInfo *info);
size_t pinos_serialize_port_info_serialize (void *dest, const SpaPortInfo *info);
SpaPortInfo * pinos_serialize_port_info_deserialize (void *src, off_t offset);
SpaPortInfo * pinos_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);
size_t pinos_serialize_props_get_size (const SpaProps *props);
size_t pinos_serialize_props_serialize (void *dest, const SpaProps *props);
SpaProps * pinos_serialize_props_deserialize (void *src, off_t offset);
SpaProps * pinos_serialize_props_copy_into (void *dest, const SpaProps *props);
#ifdef __cplusplus
} /* extern "C" */
#endif
G_END_DECLS
#endif /* __SPA_SERIALIZE_H__ */
#endif /* __PINOS_SERIALIZE_H__ */

View file

@ -656,7 +656,6 @@ add_port_update (PinosStream *stream, uint32_t change_mask)
pu.props = NULL;
if (change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO) {
pu.info = &priv->port_info;
spa_debug_port_info (pu.info);
}
pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_PORT_UPDATE, &pu);
}
@ -978,10 +977,9 @@ parse_connection (PinosStream *stream)
if (priv->format)
g_free (priv->format);
mem = malloc (spa_serialize_format_get_size (p.format));
priv->format = spa_serialize_format_copy_into (mem, p.format);
mem = malloc (pinos_serialize_format_get_size (p.format));
priv->format = pinos_serialize_format_copy_into (mem, p.format);
spa_debug_format (p.format);
priv->pending_seq = p.seq;
g_object_notify (G_OBJECT (stream), "format");
break;