mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Cleanups
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:
		
							parent
							
								
									70fb53cdc6
								
							
						
					
					
						commit
						98dbb6424d
					
				
					 13 changed files with 350 additions and 339 deletions
				
			
		| 
						 | 
					@ -84,7 +84,7 @@ connection_parse_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  memcpy (nu, conn->in.data, sizeof (PinosControlCmdNodeUpdate));
 | 
					  memcpy (nu, conn->in.data, sizeof (PinosControlCmdNodeUpdate));
 | 
				
			||||||
  if (nu->props)
 | 
					  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
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -102,16 +102,16 @@ connection_parse_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *
 | 
				
			||||||
                        SPA_PTR_TO_INT (pu->possible_formats), SpaFormat *);
 | 
					                        SPA_PTR_TO_INT (pu->possible_formats), SpaFormat *);
 | 
				
			||||||
  for (i = 0; i < pu->n_possible_formats; i++) {
 | 
					  for (i = 0; i < pu->n_possible_formats; i++) {
 | 
				
			||||||
    if (pu->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]));
 | 
					                          SPA_PTR_TO_INT (pu->possible_formats[i]));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (pu->format)
 | 
					  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)
 | 
					  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)
 | 
					  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
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -119,7 +119,7 @@ connection_parse_set_format (PinosConnection *conn, PinosControlCmdSetFormat *cm
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  memcpy (cmd, conn->in.data, sizeof (PinosControlCmdSetFormat));
 | 
					  memcpy (cmd, conn->in.data, sizeof (PinosControlCmdSetFormat));
 | 
				
			||||||
  if (cmd->format)
 | 
					  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
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -161,7 +161,7 @@ connection_ensure_size (PinosConnection *conn, ConnectionBuffer *buf, size_t siz
 | 
				
			||||||
  if (buf->buffer_size + size > buf->buffer_maxsize) {
 | 
					  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_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);
 | 
					    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;
 | 
					  return (uint8_t *) buf->buffer_data + buf->buffer_size;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -202,7 +202,7 @@ connection_add_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *nu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* calc len */
 | 
					  /* calc len */
 | 
				
			||||||
  len = sizeof (PinosControlCmdNodeUpdate);
 | 
					  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);
 | 
					  p = connection_add_cmd (conn, PINOS_CONTROL_CMD_NODE_UPDATE, len);
 | 
				
			||||||
  memcpy (p, nu, sizeof (PinosControlCmdNodeUpdate));
 | 
					  memcpy (p, nu, sizeof (PinosControlCmdNodeUpdate));
 | 
				
			||||||
| 
						 | 
					@ -210,7 +210,7 @@ connection_add_node_update (PinosConnection *conn, PinosControlCmdNodeUpdate *nu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeUpdate), void);
 | 
					  p = SPA_MEMBER (d, sizeof (PinosControlCmdNodeUpdate), void);
 | 
				
			||||||
  if (nu->props) {
 | 
					  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));
 | 
					    d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    d->props = 0;
 | 
					    d->props = 0;
 | 
				
			||||||
| 
						 | 
					@ -230,12 +230,12 @@ connection_add_port_update (PinosConnection *conn, PinosControlCmdPortUpdate *pu
 | 
				
			||||||
  len = sizeof (PinosControlCmdPortUpdate);
 | 
					  len = sizeof (PinosControlCmdPortUpdate);
 | 
				
			||||||
  len += pu->n_possible_formats * sizeof (SpaFormat *);
 | 
					  len += pu->n_possible_formats * sizeof (SpaFormat *);
 | 
				
			||||||
  for (i = 0; i < pu->n_possible_formats; i++) {
 | 
					  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 += pinos_serialize_format_get_size (pu->format);
 | 
				
			||||||
  len += spa_serialize_props_get_size (pu->props);
 | 
					  len += pinos_serialize_props_get_size (pu->props);
 | 
				
			||||||
  if (pu->info)
 | 
					  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);
 | 
					  p = connection_add_cmd (conn, PINOS_CONTROL_CMD_PORT_UPDATE, len);
 | 
				
			||||||
  memcpy (p, pu, sizeof (PinosControlCmdPortUpdate));
 | 
					  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);
 | 
					  p = SPA_MEMBER (p, sizeof (SpaFormat*) * pu->n_possible_formats, void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (i = 0; i < pu->n_possible_formats; i++) {
 | 
					  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));
 | 
					    bfa[i] = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
 | 
				
			||||||
    p = SPA_MEMBER (p, len, void);
 | 
					    p = SPA_MEMBER (p, len, void);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (pu->format) {
 | 
					  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));
 | 
					    d->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
 | 
				
			||||||
    p = SPA_MEMBER (p, len, void);
 | 
					    p = SPA_MEMBER (p, len, void);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    d->format = 0;
 | 
					    d->format = 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (pu->props) {
 | 
					  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));
 | 
					    d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
 | 
				
			||||||
    p = SPA_MEMBER (p, len, void);
 | 
					    p = SPA_MEMBER (p, len, void);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    d->props = 0;
 | 
					    d->props = 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (pu->info) {
 | 
					  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));
 | 
					    d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
 | 
				
			||||||
    p = SPA_MEMBER (p, len, void);
 | 
					    p = SPA_MEMBER (p, len, void);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
| 
						 | 
					@ -286,14 +286,14 @@ connection_add_set_format (PinosConnection *conn, PinosControlCmdSetFormat *sf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* calculate length */
 | 
					  /* calculate length */
 | 
				
			||||||
  /* port_id + format + mask  */
 | 
					  /* 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);
 | 
					  p = connection_add_cmd (conn, PINOS_CONTROL_CMD_SET_FORMAT, len);
 | 
				
			||||||
  memcpy (p, sf, sizeof (PinosControlCmdSetFormat));
 | 
					  memcpy (p, sf, sizeof (PinosControlCmdSetFormat));
 | 
				
			||||||
  sf = p;
 | 
					  sf = p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  p = SPA_MEMBER (sf, sizeof (PinosControlCmdSetFormat), void);
 | 
					  p = SPA_MEMBER (sf, sizeof (PinosControlCmdSetFormat), void);
 | 
				
			||||||
  if (sf->format) {
 | 
					  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));
 | 
					    sf->format = SPA_INT_TO_PTR (SPA_PTRDIFF (p, sf));
 | 
				
			||||||
  } else
 | 
					  } else
 | 
				
			||||||
    sf->format = 0;
 | 
					    sf->format = 0;
 | 
				
			||||||
| 
						 | 
					@ -428,7 +428,7 @@ refill_buffer (PinosConnection *conn, ConnectionBuffer *buf)
 | 
				
			||||||
  /* ERRORS */
 | 
					  /* ERRORS */
 | 
				
			||||||
recv_error:
 | 
					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;
 | 
					    return FALSE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -557,7 +557,7 @@ pinos_connection_parse_cmd (PinosConnection *conn,
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_CONTROL_CMD_PORT_STATUS_CHANGE:
 | 
					    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;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
 | 
					    case PINOS_CONTROL_CMD_NODE_STATE_CHANGE:
 | 
				
			||||||
| 
						 | 
					@ -584,7 +584,7 @@ pinos_connection_parse_cmd (PinosConnection *conn,
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_CONTROL_CMD_SET_PROPERTY:
 | 
					    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;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* bidirectional */
 | 
					    /* bidirectional */
 | 
				
			||||||
| 
						 | 
					@ -739,7 +739,7 @@ pinos_connection_add_cmd (PinosConnection *conn,
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_CONTROL_CMD_SET_PROPERTY:
 | 
					    case PINOS_CONTROL_CMD_SET_PROPERTY:
 | 
				
			||||||
      g_warning ("implement builder of %d\n", cmd);
 | 
					      g_warning ("implement builder of %d", cmd);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* bidirectional */
 | 
					    /* bidirectional */
 | 
				
			||||||
| 
						 | 
					@ -837,7 +837,7 @@ pinos_connection_flush (PinosConnection *conn)
 | 
				
			||||||
  /* ERRORS */
 | 
					  /* ERRORS */
 | 
				
			||||||
send_error:
 | 
					send_error:
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    g_warning ("could not sendmsg: %s\n", strerror (errno));
 | 
					    g_warning ("could not sendmsg: %s", strerror (errno));
 | 
				
			||||||
    return FALSE;
 | 
					    return FALSE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,9 +30,9 @@ format_copy (SpaFormat *format)
 | 
				
			||||||
  if (format == NULL)
 | 
					  if (format == NULL)
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  size = spa_serialize_format_get_size (format);
 | 
					  size = pinos_serialize_format_get_size (format);
 | 
				
			||||||
  p = malloc (size);
 | 
					  p = malloc (size);
 | 
				
			||||||
  return spa_serialize_format_copy_into (p, format);
 | 
					  return pinos_serialize_format_copy_into (p, format);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@
 | 
				
			||||||
#include "serialize.h"
 | 
					#include "serialize.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
spa_serialize_buffer_get_size (const SpaBuffer *buffer)
 | 
					pinos_serialize_buffer_get_size (const SpaBuffer *buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  size_t size;
 | 
					  size_t size;
 | 
				
			||||||
  unsigned int i;
 | 
					  unsigned int i;
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,7 @@ spa_serialize_buffer_get_size (const SpaBuffer *buffer)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
spa_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
 | 
					pinos_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaBuffer *tb;
 | 
					  SpaBuffer *tb;
 | 
				
			||||||
  SpaMeta *mp;
 | 
					  SpaMeta *mp;
 | 
				
			||||||
| 
						 | 
					@ -70,7 +70,7 @@ spa_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaBuffer *
 | 
					SpaBuffer *
 | 
				
			||||||
spa_serialize_buffer_deserialize (void *src, off_t offset)
 | 
					pinos_serialize_buffer_deserialize (void *src, off_t offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaBuffer *b;
 | 
					  SpaBuffer *b;
 | 
				
			||||||
  unsigned int i;
 | 
					  unsigned int i;
 | 
				
			||||||
| 
						 | 
					@ -91,16 +91,16 @@ spa_serialize_buffer_deserialize (void *src, off_t offset)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
spa_serialize_format_get_size (const SpaFormat *format)
 | 
					pinos_serialize_format_get_size (const SpaFormat *format)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (format == NULL)
 | 
					  if (format == NULL)
 | 
				
			||||||
    return 0;
 | 
					    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
 | 
					size_t
 | 
				
			||||||
spa_serialize_format_serialize (void *dest, const SpaFormat *format)
 | 
					pinos_serialize_format_serialize (void *dest, const SpaFormat *format)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaFormat *tf;
 | 
					  SpaFormat *tf;
 | 
				
			||||||
  size_t size;
 | 
					  size_t size;
 | 
				
			||||||
| 
						 | 
					@ -113,34 +113,34 @@ spa_serialize_format_serialize (void *dest, const SpaFormat *format)
 | 
				
			||||||
  tf->media_subtype = format->media_subtype;
 | 
					  tf->media_subtype = format->media_subtype;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dest = SPA_MEMBER (tf, offsetof (SpaFormat, props), void);
 | 
					  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;
 | 
					  return size;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaFormat *
 | 
					SpaFormat *
 | 
				
			||||||
spa_serialize_format_deserialize (void *src, off_t offset)
 | 
					pinos_serialize_format_deserialize (void *src, off_t offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaFormat *f;
 | 
					  SpaFormat *f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  f = SPA_MEMBER (src, offset, SpaFormat);
 | 
					  f = SPA_MEMBER (src, offset, SpaFormat);
 | 
				
			||||||
  spa_serialize_props_deserialize (f, offsetof (SpaFormat, props));
 | 
					  pinos_serialize_props_deserialize (f, offsetof (SpaFormat, props));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return f;
 | 
					  return f;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaFormat *
 | 
					SpaFormat *
 | 
				
			||||||
spa_serialize_format_copy_into (void *dest, const SpaFormat *format)
 | 
					pinos_serialize_format_copy_into (void *dest, const SpaFormat *format)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (format == NULL)
 | 
					  if (format == NULL)
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_serialize_format_serialize (dest, format);
 | 
					  pinos_serialize_format_serialize (dest, format);
 | 
				
			||||||
  return spa_serialize_format_deserialize (dest, 0);
 | 
					  return pinos_serialize_format_deserialize (dest, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
spa_serialize_port_info_get_size (const SpaPortInfo *info)
 | 
					pinos_serialize_port_info_get_size (const SpaPortInfo *info)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  size_t len;
 | 
					  size_t len;
 | 
				
			||||||
  unsigned int i;
 | 
					  unsigned int i;
 | 
				
			||||||
| 
						 | 
					@ -157,7 +157,7 @@ spa_serialize_port_info_get_size (const SpaPortInfo *info)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
spa_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
 | 
					pinos_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaPortInfo *pi;
 | 
					  SpaPortInfo *pi;
 | 
				
			||||||
  SpaAllocParam **ap;
 | 
					  SpaAllocParam **ap;
 | 
				
			||||||
| 
						 | 
					@ -189,7 +189,7 @@ spa_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaPortInfo *
 | 
					SpaPortInfo *
 | 
				
			||||||
spa_serialize_port_info_deserialize (void *p, off_t offset)
 | 
					pinos_serialize_port_info_deserialize (void *p, off_t offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaPortInfo *pi;
 | 
					  SpaPortInfo *pi;
 | 
				
			||||||
  unsigned int i;
 | 
					  unsigned int i;
 | 
				
			||||||
| 
						 | 
					@ -204,17 +204,17 @@ spa_serialize_port_info_deserialize (void *p, off_t offset)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaPortInfo *
 | 
					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)
 | 
					  if (info == NULL)
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_serialize_port_info_serialize (dest, info);
 | 
					  pinos_serialize_port_info_serialize (dest, info);
 | 
				
			||||||
  return spa_serialize_port_info_deserialize (dest, 0);
 | 
					  return pinos_serialize_port_info_deserialize (dest, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
spa_serialize_props_get_size (const SpaProps *props)
 | 
					pinos_serialize_props_get_size (const SpaProps *props)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  size_t len;
 | 
					  size_t len;
 | 
				
			||||||
  unsigned int i, j;
 | 
					  unsigned int i, j;
 | 
				
			||||||
| 
						 | 
					@ -243,7 +243,7 @@ spa_serialize_props_get_size (const SpaProps *props)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
spa_serialize_props_serialize (void *p, const SpaProps *props)
 | 
					pinos_serialize_props_serialize (void *p, const SpaProps *props)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  size_t len, slen;
 | 
					  size_t len, slen;
 | 
				
			||||||
  unsigned int i, j, c;
 | 
					  unsigned int i, j, c;
 | 
				
			||||||
| 
						 | 
					@ -314,7 +314,7 @@ spa_serialize_props_serialize (void *p, const SpaProps *props)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaProps *
 | 
					SpaProps *
 | 
				
			||||||
spa_serialize_props_deserialize (void *p, off_t offset)
 | 
					pinos_serialize_props_deserialize (void *p, off_t offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaProps *tp;
 | 
					  SpaProps *tp;
 | 
				
			||||||
  unsigned int i, j;
 | 
					  unsigned int i, j;
 | 
				
			||||||
| 
						 | 
					@ -344,11 +344,11 @@ spa_serialize_props_deserialize (void *p, off_t offset)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaProps *
 | 
					SpaProps *
 | 
				
			||||||
spa_serialize_props_copy_into (void *dest, const SpaProps *props)
 | 
					pinos_serialize_props_copy_into (void *dest, const SpaProps *props)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (props == NULL)
 | 
					  if (props == NULL)
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_serialize_props_serialize (dest, props);
 | 
					  pinos_serialize_props_serialize (dest, props);
 | 
				
			||||||
  return spa_serialize_props_deserialize (dest, 0);
 | 
					  return pinos_serialize_props_deserialize (dest, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,39 +17,37 @@
 | 
				
			||||||
 * Boston, MA 02110-1301, USA.
 | 
					 * Boston, MA 02110-1301, USA.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef __SPA_SERIALIZE_H__
 | 
					#ifndef __PINOS_SERIALIZE_H__
 | 
				
			||||||
#define __SPA_SERIALIZE_H__
 | 
					#define __PINOS_SERIALIZE_H__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#include <glib-object.h>
 | 
				
			||||||
extern "C" {
 | 
					
 | 
				
			||||||
#endif
 | 
					G_BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <spa/include/spa/buffer.h>
 | 
					#include <spa/include/spa/buffer.h>
 | 
				
			||||||
#include <spa/include/spa/format.h>
 | 
					#include <spa/include/spa/format.h>
 | 
				
			||||||
#include <spa/include/spa/props.h>
 | 
					#include <spa/include/spa/props.h>
 | 
				
			||||||
#include <spa/include/spa/port.h>
 | 
					#include <spa/include/spa/port.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t          spa_serialize_buffer_get_size       (const SpaBuffer *buffer);
 | 
					size_t          pinos_serialize_buffer_get_size       (const SpaBuffer *buffer);
 | 
				
			||||||
size_t          spa_serialize_buffer_serialize      (void *dest, const SpaBuffer *buffer);
 | 
					size_t          pinos_serialize_buffer_serialize      (void *dest, const SpaBuffer *buffer);
 | 
				
			||||||
SpaBuffer *     spa_serialize_buffer_deserialize    (void *src, off_t offset);
 | 
					SpaBuffer *     pinos_serialize_buffer_deserialize    (void *src, off_t offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t          spa_serialize_format_get_size       (const SpaFormat *format);
 | 
					size_t          pinos_serialize_format_get_size       (const SpaFormat *format);
 | 
				
			||||||
size_t          spa_serialize_format_serialize      (void *dest, const SpaFormat *format);
 | 
					size_t          pinos_serialize_format_serialize      (void *dest, const SpaFormat *format);
 | 
				
			||||||
SpaFormat *     spa_serialize_format_deserialize    (void *src, off_t offset);
 | 
					SpaFormat *     pinos_serialize_format_deserialize    (void *src, off_t offset);
 | 
				
			||||||
SpaFormat *     spa_serialize_format_copy_into      (void *dest, const SpaFormat *format);
 | 
					SpaFormat *     pinos_serialize_format_copy_into      (void *dest, const SpaFormat *format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t          spa_serialize_port_info_get_size    (const SpaPortInfo *info);
 | 
					size_t          pinos_serialize_port_info_get_size    (const SpaPortInfo *info);
 | 
				
			||||||
size_t          spa_serialize_port_info_serialize   (void *dest, const SpaPortInfo *info);
 | 
					size_t          pinos_serialize_port_info_serialize   (void *dest, const SpaPortInfo *info);
 | 
				
			||||||
SpaPortInfo *   spa_serialize_port_info_deserialize (void *src, off_t offset);
 | 
					SpaPortInfo *   pinos_serialize_port_info_deserialize (void *src, off_t offset);
 | 
				
			||||||
SpaPortInfo *   spa_serialize_port_info_copy_into   (void *dest, const SpaPortInfo *info);
 | 
					SpaPortInfo *   pinos_serialize_port_info_copy_into   (void *dest, const SpaPortInfo *info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t          spa_serialize_props_get_size        (const SpaProps *props);
 | 
					size_t          pinos_serialize_props_get_size        (const SpaProps *props);
 | 
				
			||||||
size_t          spa_serialize_props_serialize       (void *dest, const SpaProps *props);
 | 
					size_t          pinos_serialize_props_serialize       (void *dest, const SpaProps *props);
 | 
				
			||||||
SpaProps *      spa_serialize_props_deserialize     (void *src, off_t offset);
 | 
					SpaProps *      pinos_serialize_props_deserialize     (void *src, off_t offset);
 | 
				
			||||||
SpaProps *      spa_serialize_props_copy_into       (void *dest, const SpaProps *props);
 | 
					SpaProps *      pinos_serialize_props_copy_into       (void *dest, const SpaProps *props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					G_END_DECLS
 | 
				
			||||||
}  /* extern "C" */
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __SPA_SERIALIZE_H__ */
 | 
					#endif /* __PINOS_SERIALIZE_H__ */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -656,7 +656,6 @@ add_port_update (PinosStream *stream, uint32_t change_mask)
 | 
				
			||||||
  pu.props = NULL;
 | 
					  pu.props = NULL;
 | 
				
			||||||
  if (change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO) {
 | 
					  if (change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO) {
 | 
				
			||||||
    pu.info = &priv->port_info;
 | 
					    pu.info = &priv->port_info;
 | 
				
			||||||
    spa_debug_port_info (pu.info);
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_PORT_UPDATE, &pu);
 | 
					  pinos_connection_add_cmd (priv->conn, PINOS_CONTROL_CMD_PORT_UPDATE, &pu);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -978,10 +977,9 @@ parse_connection (PinosStream *stream)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (priv->format)
 | 
					        if (priv->format)
 | 
				
			||||||
          g_free (priv->format);
 | 
					          g_free (priv->format);
 | 
				
			||||||
        mem = malloc (spa_serialize_format_get_size (p.format));
 | 
					        mem = malloc (pinos_serialize_format_get_size (p.format));
 | 
				
			||||||
        priv->format = spa_serialize_format_copy_into (mem, p.format);
 | 
					        priv->format = pinos_serialize_format_copy_into (mem, p.format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        spa_debug_format (p.format);
 | 
					 | 
				
			||||||
        priv->pending_seq = p.seq;
 | 
					        priv->pending_seq = p.seq;
 | 
				
			||||||
        g_object_notify (G_OBJECT (stream), "format");
 | 
					        g_object_notify (G_OBJECT (stream), "format");
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -146,13 +146,13 @@ handle_video_format (ConvertData *d)
 | 
				
			||||||
      *sv = gst_video_format_from_string (g_value_get_string (val));
 | 
					      *sv = gst_video_format_from_string (g_value_get_string (val));
 | 
				
			||||||
      d->p = ++sv;
 | 
					      d->p = ++sv;
 | 
				
			||||||
    } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
					    } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
      fprintf (stderr, "implement me\n");
 | 
					      g_debug ("implement me");
 | 
				
			||||||
      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
    } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
					    } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
      fprintf (stderr, "implement me\n");
 | 
					      g_debug ("implement me");
 | 
				
			||||||
      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      fprintf (stderr, "implement me\n");
 | 
					      g_debug ("implement me");
 | 
				
			||||||
      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    d->pi++;
 | 
					    d->pi++;
 | 
				
			||||||
| 
						 | 
					@ -204,13 +204,13 @@ handle_video_size (ConvertData *d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -266,13 +266,13 @@ handle_video_framerate (ConvertData *d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
    } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
					    } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
      fprintf (stderr, "implement me\n");
 | 
					      g_debug ("implement me");
 | 
				
			||||||
      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
    } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
					    } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
      fprintf (stderr, "implement me\n");
 | 
					      g_debug ("implement me");
 | 
				
			||||||
      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      fprintf (stderr, "implement me\n");
 | 
					      g_debug ("implement me");
 | 
				
			||||||
      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
					      SPA_PROPS_INDEX_UNSET (&d->f->props, d->pi);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    d->pi++;
 | 
					    d->pi++;
 | 
				
			||||||
| 
						 | 
					@ -329,13 +329,13 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
 | 
				
			||||||
        *sv = gst_audio_format_from_string (g_value_get_string (val));
 | 
					        *sv = gst_audio_format_from_string (g_value_get_string (val));
 | 
				
			||||||
        d.p = ++sv;
 | 
					        d.p = ++sv;
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      d.pi++;
 | 
					      d.pi++;
 | 
				
			||||||
| 
						 | 
					@ -356,13 +356,13 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
 | 
				
			||||||
          *sv = SPA_AUDIO_LAYOUT_NON_INTERLEAVED;
 | 
					          *sv = SPA_AUDIO_LAYOUT_NON_INTERLEAVED;
 | 
				
			||||||
        d.p = ++sv;
 | 
					        d.p = ++sv;
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      d.pi++;
 | 
					      d.pi++;
 | 
				
			||||||
| 
						 | 
					@ -379,13 +379,13 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
 | 
				
			||||||
        *sv = g_value_get_int (val);
 | 
					        *sv = g_value_get_int (val);
 | 
				
			||||||
        d.p = ++sv;
 | 
					        d.p = ++sv;
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      d.pi++;
 | 
					      d.pi++;
 | 
				
			||||||
| 
						 | 
					@ -402,13 +402,13 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
 | 
				
			||||||
        *sv = g_value_get_int (val);
 | 
					        *sv = g_value_get_int (val);
 | 
				
			||||||
        d.p = ++sv;
 | 
					        d.p = ++sv;
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        fprintf (stderr, "implement me\n");
 | 
					        g_debug ("implement me");
 | 
				
			||||||
        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
					        SPA_PROPS_INDEX_UNSET (&d.f->props, d.pi);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      d.pi++;
 | 
					      d.pi++;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -334,15 +334,15 @@ do_update_port (SpaProxy                *this,
 | 
				
			||||||
    port->n_formats = pu->n_possible_formats;
 | 
					    port->n_formats = pu->n_possible_formats;
 | 
				
			||||||
    port->formats = realloc (port->formats, port->n_formats * sizeof (SpaFormat *));
 | 
					    port->formats = realloc (port->formats, port->n_formats * sizeof (SpaFormat *));
 | 
				
			||||||
    for (i = 0; i < port->n_formats; i++) {
 | 
					    for (i = 0; i < port->n_formats; i++) {
 | 
				
			||||||
      size = spa_serialize_format_get_size (pu->possible_formats[i]);
 | 
					      size = pinos_serialize_format_get_size (pu->possible_formats[i]);
 | 
				
			||||||
      port->formats[i] = spa_serialize_format_copy_into (malloc (size), pu->possible_formats[i]);
 | 
					      port->formats[i] = pinos_serialize_format_copy_into (malloc (size), pu->possible_formats[i]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT) {
 | 
					  if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_FORMAT) {
 | 
				
			||||||
    if (port->format)
 | 
					    if (port->format)
 | 
				
			||||||
      free (port->format);
 | 
					      free (port->format);
 | 
				
			||||||
    size = spa_serialize_format_get_size (pu->format);
 | 
					    size = pinos_serialize_format_get_size (pu->format);
 | 
				
			||||||
    port->format = spa_serialize_format_copy_into (malloc (size), pu->format);
 | 
					    port->format = pinos_serialize_format_copy_into (malloc (size), pu->format);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_PROPS) {
 | 
					  if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_PROPS) {
 | 
				
			||||||
| 
						 | 
					@ -351,8 +351,8 @@ do_update_port (SpaProxy                *this,
 | 
				
			||||||
  if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO && pu->info) {
 | 
					  if (pu->change_mask & PINOS_CONTROL_CMD_PORT_UPDATE_INFO && pu->info) {
 | 
				
			||||||
    if (port->info)
 | 
					    if (port->info)
 | 
				
			||||||
      free (port->info);
 | 
					      free (port->info);
 | 
				
			||||||
    size = spa_serialize_port_info_get_size (pu->info);
 | 
					    size = pinos_serialize_port_info_get_size (pu->info);
 | 
				
			||||||
    port->info = spa_serialize_port_info_copy_into (malloc (size), pu->info);
 | 
					    port->info = pinos_serialize_port_info_copy_into (malloc (size), pu->info);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!port->valid) {
 | 
					  if (!port->valid) {
 | 
				
			||||||
| 
						 | 
					@ -654,7 +654,7 @@ spa_proxy_node_port_use_buffers (SpaNode         *node,
 | 
				
			||||||
    b->buffer.datas = b->datas;
 | 
					    b->buffer.datas = b->datas;
 | 
				
			||||||
    b->buffer.metas = b->metas;
 | 
					    b->buffer.metas = b->metas;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    b->size = spa_serialize_buffer_get_size (buffers[i]);
 | 
					    b->size = pinos_serialize_buffer_get_size (buffers[i]);
 | 
				
			||||||
    b->offset = size;
 | 
					    b->offset = size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (j = 0; j < buffers[i]->n_metas; j++) {
 | 
					    for (j = 0; j < buffers[i]->n_metas; j++) {
 | 
				
			||||||
| 
						 | 
					@ -724,7 +724,7 @@ spa_proxy_node_port_use_buffers (SpaNode         *node,
 | 
				
			||||||
      SpaMeta *sbm;
 | 
					      SpaMeta *sbm;
 | 
				
			||||||
      SpaData *sbd;
 | 
					      SpaData *sbd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      spa_serialize_buffer_serialize (p, &b->buffer);
 | 
					      pinos_serialize_buffer_serialize (p, &b->buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      sb = p;
 | 
					      sb = p;
 | 
				
			||||||
      b->buffer.datas = SPA_MEMBER (sb, SPA_PTR_TO_INT (sb->datas), SpaData);
 | 
					      b->buffer.datas = SPA_MEMBER (sb, SPA_PTR_TO_INT (sb->datas), SpaData);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -152,20 +152,14 @@ handle_create_node (PinosDaemon1           *interface,
 | 
				
			||||||
  props = pinos_properties_from_variant (arg_properties);
 | 
					  props = pinos_properties_from_variant (arg_properties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  factory = g_hash_table_lookup (priv->node_factories, arg_factory_name);
 | 
					  factory = g_hash_table_lookup (priv->node_factories, arg_factory_name);
 | 
				
			||||||
  if (factory != NULL) {
 | 
					  if (factory == NULL)
 | 
				
			||||||
 | 
					    goto no_factory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  node = pinos_node_factory_create_node (factory,
 | 
					  node = pinos_node_factory_create_node (factory,
 | 
				
			||||||
                                         daemon,
 | 
					                                         daemon,
 | 
				
			||||||
                                         client,
 | 
					                                         client,
 | 
				
			||||||
                                         arg_name,
 | 
					                                         arg_name,
 | 
				
			||||||
                                         props);
 | 
					                                         props);
 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    node = pinos_node_new (daemon,
 | 
					 | 
				
			||||||
                           client,
 | 
					 | 
				
			||||||
                           arg_name,
 | 
					 | 
				
			||||||
                           props,
 | 
					 | 
				
			||||||
                           NULL);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  pinos_properties_free (props);
 | 
					  pinos_properties_free (props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (node == NULL)
 | 
					  if (node == NULL)
 | 
				
			||||||
| 
						 | 
					@ -187,6 +181,13 @@ handle_create_node (PinosDaemon1           *interface,
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* ERRORS */
 | 
					  /* ERRORS */
 | 
				
			||||||
 | 
					no_factory:
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    g_debug ("daemon %p: could find factory named %s", daemon, arg_factory_name);
 | 
				
			||||||
 | 
					    g_dbus_method_invocation_return_dbus_error (invocation,
 | 
				
			||||||
 | 
					                 "org.pinos.Error", "can't find factory");
 | 
				
			||||||
 | 
					    return TRUE;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
no_node:
 | 
					no_node:
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    g_debug ("daemon %p: could create node named %s from factory %s", daemon, arg_name, arg_factory_name);
 | 
					    g_debug ("daemon %p: could create node named %s from factory %s", daemon, arg_name, arg_factory_name);
 | 
				
			||||||
| 
						 | 
					@ -196,6 +197,29 @@ no_node:
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					on_node_remove_signal (PinosNode   *node,
 | 
				
			||||||
 | 
					                       PinosDaemon *daemon)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  g_debug ("daemon %p: node %p remove", daemon, node);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					on_link_input_unlinked (PinosLink   *link,
 | 
				
			||||||
 | 
					                        PinosPort   *port,
 | 
				
			||||||
 | 
					                        PinosDaemon *daemon)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  g_debug ("daemon %p: link %p: input unlinked", daemon, link);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					on_link_output_unlinked (PinosLink   *link,
 | 
				
			||||||
 | 
					                         PinosPort   *port,
 | 
				
			||||||
 | 
					                         PinosDaemon *daemon)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  g_debug ("daemon %p: link %p: output unlinked", daemon, link);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_link_state_notify (GObject     *obj,
 | 
					on_link_state_notify (GObject     *obj,
 | 
				
			||||||
                      GParamSpec  *pspec,
 | 
					                      GParamSpec  *pspec,
 | 
				
			||||||
| 
						 | 
					@ -209,20 +233,29 @@ on_link_state_notify (GObject     *obj,
 | 
				
			||||||
  switch (state) {
 | 
					  switch (state) {
 | 
				
			||||||
    case PINOS_LINK_STATE_ERROR:
 | 
					    case PINOS_LINK_STATE_ERROR:
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      g_warning ("daemon %p: link %p: state error: %s", daemon, link, error->message);
 | 
					      g_debug ("daemon %p: link %p: state error: %s", daemon, link, error->message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (link->input->node) {
 | 
					      if (link->input && link->input->node)
 | 
				
			||||||
        pinos_node_report_error (link->input->node, g_error_copy (error));
 | 
					        pinos_node_report_error (link->input->node, g_error_copy (error));
 | 
				
			||||||
      }
 | 
					      if (link->output && link->output->node)
 | 
				
			||||||
      if (link->output->node) {
 | 
					 | 
				
			||||||
        pinos_node_report_error (link->output->node, g_error_copy (error));
 | 
					        pinos_node_report_error (link->output->node, g_error_copy (error));
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_LINK_STATE_UNLINKED:
 | 
					    case PINOS_LINK_STATE_UNLINKED:
 | 
				
			||||||
      g_warning ("daemon %p: link %p: unlinked", daemon, link);
 | 
					      g_debug ("daemon %p: link %p: unlinked", daemon, link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      g_set_error (&error,
 | 
				
			||||||
 | 
					                   PINOS_ERROR,
 | 
				
			||||||
 | 
					                   PINOS_ERROR_NODE_LINK,
 | 
				
			||||||
 | 
					                   "error node unlinked");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (link->input && link->input->node)
 | 
				
			||||||
 | 
					        pinos_node_report_error (link->input->node, g_error_copy (error));
 | 
				
			||||||
 | 
					      if (link->output && link->output->node)
 | 
				
			||||||
 | 
					        pinos_node_report_error (link->output->node, g_error_copy (error));
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_LINK_STATE_INIT:
 | 
					    case PINOS_LINK_STATE_INIT:
 | 
				
			||||||
    case PINOS_LINK_STATE_NEGOTIATING:
 | 
					    case PINOS_LINK_STATE_NEGOTIATING:
 | 
				
			||||||
    case PINOS_LINK_STATE_ALLOCATING:
 | 
					    case PINOS_LINK_STATE_ALLOCATING:
 | 
				
			||||||
| 
						 | 
					@ -233,14 +266,14 @@ on_link_state_notify (GObject     *obj,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_port_added (PinosNode *node, PinosDirection direction, PinosDaemon *this)
 | 
					on_port_added (PinosNode *node, PinosPort *port, PinosDaemon *this)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosClient *client;
 | 
					  PinosClient *client;
 | 
				
			||||||
  PinosProperties *props;
 | 
					  PinosProperties *props;
 | 
				
			||||||
  PinosNode *target;
 | 
					 | 
				
			||||||
  const gchar *path;
 | 
					  const gchar *path;
 | 
				
			||||||
  GError *error = NULL;
 | 
					  GError *error = NULL;
 | 
				
			||||||
  PinosLink *link;
 | 
					  PinosLink *link;
 | 
				
			||||||
 | 
					  PinosDirection direction = port->direction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  props = pinos_node_get_properties (node);
 | 
					  props = pinos_node_get_properties (node);
 | 
				
			||||||
  if (props == NULL)
 | 
					  if (props == NULL)
 | 
				
			||||||
| 
						 | 
					@ -249,10 +282,9 @@ on_port_added (PinosNode *node, PinosDirection direction, PinosDaemon *this)
 | 
				
			||||||
  path = pinos_properties_get (props, "pinos.target.node");
 | 
					  path = pinos_properties_get (props, "pinos.target.node");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (path) {
 | 
					  if (path) {
 | 
				
			||||||
    guint target_port;
 | 
					    PinosPort *target;
 | 
				
			||||||
    guint node_port;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    target = pinos_daemon_find_node (this,
 | 
					    target = pinos_daemon_find_port (this,
 | 
				
			||||||
                                     pinos_direction_reverse (direction),
 | 
					                                     pinos_direction_reverse (direction),
 | 
				
			||||||
                                     path,
 | 
					                                     path,
 | 
				
			||||||
                                     NULL,
 | 
					                                     NULL,
 | 
				
			||||||
| 
						 | 
					@ -262,36 +294,21 @@ on_port_added (PinosNode *node, PinosDirection direction, PinosDaemon *this)
 | 
				
			||||||
    if (target == NULL)
 | 
					    if (target == NULL)
 | 
				
			||||||
      goto error;
 | 
					      goto error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    target_port = pinos_node_get_free_port (target, pinos_direction_reverse (direction));
 | 
					 | 
				
			||||||
    if (target_port == SPA_ID_INVALID) {
 | 
					 | 
				
			||||||
      g_set_error (&error,
 | 
					 | 
				
			||||||
                   PINOS_ERROR,
 | 
					 | 
				
			||||||
                   PINOS_ERROR_NODE_PORT,
 | 
					 | 
				
			||||||
                   "can't get free port from target %s", pinos_node_get_object_path (target));
 | 
					 | 
				
			||||||
      goto error;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    node_port = pinos_node_get_free_port (node, direction);
 | 
					 | 
				
			||||||
    if (node_port == SPA_ID_INVALID) {
 | 
					 | 
				
			||||||
      g_set_error (&error,
 | 
					 | 
				
			||||||
                   PINOS_ERROR,
 | 
					 | 
				
			||||||
                   PINOS_ERROR_NODE_PORT,
 | 
					 | 
				
			||||||
                   "can't get free port from node %s", pinos_node_get_object_path (node));
 | 
					 | 
				
			||||||
      goto error;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (direction == PINOS_DIRECTION_OUTPUT)
 | 
					    if (direction == PINOS_DIRECTION_OUTPUT)
 | 
				
			||||||
      link = pinos_node_link (node, node_port, target, target_port, NULL, NULL, &error);
 | 
					      link = pinos_node_link (node, port, target, NULL, NULL, &error);
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      link = pinos_node_link (target, target_port, node, node_port, NULL, NULL, &error);
 | 
					      link = pinos_node_link (target->node, target, port, NULL, NULL, &error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (link == NULL)
 | 
					    if (link == NULL)
 | 
				
			||||||
      goto error;
 | 
					      goto error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    client = pinos_node_get_client (node);
 | 
					    client = pinos_node_get_client (node);
 | 
				
			||||||
    if (client) {
 | 
					    if (client)
 | 
				
			||||||
      pinos_client_add_object (client, G_OBJECT (link));
 | 
					      pinos_client_add_object (client, G_OBJECT (link));
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    g_signal_connect (target->node, "remove", (GCallback) on_node_remove_signal, daemon);
 | 
				
			||||||
 | 
					    g_signal_connect (link, "input-unlinked", (GCallback) on_link_input_unlinked, daemon);
 | 
				
			||||||
 | 
					    g_signal_connect (link, "output-unlinked", (GCallback) on_link_output_unlinked, daemon);
 | 
				
			||||||
    g_signal_connect (link, "notify::state", (GCallback) on_link_state_notify, daemon);
 | 
					    g_signal_connect (link, "notify::state", (GCallback) on_link_state_notify, daemon);
 | 
				
			||||||
    pinos_link_activate (link);
 | 
					    pinos_link_activate (link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -307,21 +324,29 @@ error:
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_port_removed (PinosNode *node, PinosDaemon *daemon)
 | 
					on_port_removed (PinosNode *node, PinosPort *port, PinosDaemon *daemon)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
handle_node_connections (PinosDaemon *daemon,
 | 
					on_node_created (PinosNode      *node,
 | 
				
			||||||
                         PinosNode   *node)
 | 
					                 PinosDaemon    *daemon)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosDirection direction;
 | 
					  GList *ports, *walk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  direction = node->have_inputs ? PINOS_DIRECTION_INPUT : PINOS_DIRECTION_OUTPUT;
 | 
					  ports = pinos_node_get_ports (node, PINOS_DIRECTION_INPUT);
 | 
				
			||||||
 | 
					  for (walk = ports; walk; walk = g_list_next (walk))
 | 
				
			||||||
 | 
					    on_port_added (node, walk->data, daemon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  on_port_added (node, direction, daemon);
 | 
					  ports = pinos_node_get_ports (node, PINOS_DIRECTION_OUTPUT);
 | 
				
			||||||
 | 
					  for (walk = ports; walk; walk = g_list_next (walk))
 | 
				
			||||||
 | 
					    on_port_added (node, walk->data, daemon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_signal_connect (node, "port-added", (GCallback) on_port_added, daemon);
 | 
				
			||||||
 | 
					  g_signal_connect (node, "port-removed", (GCallback) on_port_removed, daemon);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_node_state_change (PinosNode      *node,
 | 
					on_node_state_change (PinosNode      *node,
 | 
				
			||||||
                      PinosNodeState  old,
 | 
					                      PinosNodeState  old,
 | 
				
			||||||
| 
						 | 
					@ -333,7 +358,7 @@ on_node_state_change (PinosNode      *node,
 | 
				
			||||||
                        pinos_node_state_as_string (state));
 | 
					                        pinos_node_state_as_string (state));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (old == PINOS_NODE_STATE_CREATING && state == PINOS_NODE_STATE_SUSPENDED)
 | 
					  if (old == PINOS_NODE_STATE_CREATING && state == PINOS_NODE_STATE_SUSPENDED)
 | 
				
			||||||
    handle_node_connections (daemon, node);
 | 
					    on_node_created (node, daemon);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -350,17 +375,14 @@ on_node_added (PinosDaemon *daemon, PinosNode *node)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  state = pinos_node_get_state (node);
 | 
					  state = pinos_node_get_state (node);
 | 
				
			||||||
  if (state > PINOS_NODE_STATE_CREATING) {
 | 
					  if (state > PINOS_NODE_STATE_CREATING) {
 | 
				
			||||||
    handle_node_connections (daemon, node);
 | 
					    on_node_created (node, daemon);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  g_signal_connect (node, "port-added", (GCallback) on_port_added, daemon);
 | 
					 | 
				
			||||||
  g_signal_connect (node, "port-removed", (GCallback) on_port_removed, daemon);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_node_removed (PinosDaemon *daemon, PinosNode *node)
 | 
					on_node_removed (PinosDaemon *daemon, PinosNode *node)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  g_debug ("daemon %p: node %p removed", daemon, node);
 | 
					  g_debug ("daemon %p: node %p removed", daemon, node);
 | 
				
			||||||
 | 
					 | 
				
			||||||
  g_signal_handlers_disconnect_by_data (node, daemon);
 | 
					  g_signal_handlers_disconnect_by_data (node, daemon);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -703,7 +725,7 @@ pinos_daemon_remove_node (PinosDaemon *daemon,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * pinos_daemon_find_node:
 | 
					 * pinos_daemon_find_port:
 | 
				
			||||||
 * @daemon: a #PinosDaemon
 | 
					 * @daemon: a #PinosDaemon
 | 
				
			||||||
 * @name: a port name
 | 
					 * @name: a port name
 | 
				
			||||||
 * @props: port properties
 | 
					 * @props: port properties
 | 
				
			||||||
| 
						 | 
					@ -714,8 +736,8 @@ pinos_daemon_remove_node (PinosDaemon *daemon,
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a #PinosPort or %NULL when no port could be found.
 | 
					 * Returns: a #PinosPort or %NULL when no port could be found.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
PinosNode *
 | 
					PinosPort *
 | 
				
			||||||
pinos_daemon_find_node (PinosDaemon     *daemon,
 | 
					pinos_daemon_find_port (PinosDaemon     *daemon,
 | 
				
			||||||
                        PinosDirection   direction,
 | 
					                        PinosDirection   direction,
 | 
				
			||||||
                        const gchar     *name,
 | 
					                        const gchar     *name,
 | 
				
			||||||
                        PinosProperties *props,
 | 
					                        PinosProperties *props,
 | 
				
			||||||
| 
						 | 
					@ -724,7 +746,7 @@ pinos_daemon_find_node (PinosDaemon     *daemon,
 | 
				
			||||||
                        GError         **error)
 | 
					                        GError         **error)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosDaemonPrivate *priv;
 | 
					  PinosDaemonPrivate *priv;
 | 
				
			||||||
  PinosNode *best = NULL;
 | 
					  PinosPort *best = NULL;
 | 
				
			||||||
  GList *nodes;
 | 
					  GList *nodes;
 | 
				
			||||||
  gboolean have_name;
 | 
					  gboolean have_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -740,12 +762,16 @@ pinos_daemon_find_node (PinosDaemon     *daemon,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_debug ("node path \"%s\"", pinos_node_get_object_path (n));
 | 
					    g_debug ("node path \"%s\"", pinos_node_get_object_path (n));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (have_name && g_str_has_suffix (pinos_node_get_object_path (n), name)) {
 | 
					    if (have_name) {
 | 
				
			||||||
 | 
					      if (g_str_has_suffix (pinos_node_get_object_path (n), name)) {
 | 
				
			||||||
        g_debug ("name \"%s\" matches node %p", name, n);
 | 
					        g_debug ("name \"%s\" matches node %p", name, n);
 | 
				
			||||||
      best = n;
 | 
					
 | 
				
			||||||
 | 
					        best = pinos_node_get_free_port (n, direction);
 | 
				
			||||||
 | 
					        if (best)
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (best == NULL) {
 | 
					  if (best == NULL) {
 | 
				
			||||||
    g_set_error (error,
 | 
					    g_set_error (error,
 | 
				
			||||||
| 
						 | 
					@ -1025,7 +1051,6 @@ pinos_daemon_init (PinosDaemon * daemon)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  priv->main_loop.size = sizeof (SpaPoll);
 | 
					  priv->main_loop.size = sizeof (SpaPoll);
 | 
				
			||||||
  priv->main_loop.info = NULL;
 | 
					  priv->main_loop.info = NULL;
 | 
				
			||||||
  priv->main_loop.info = NULL;
 | 
					 | 
				
			||||||
  priv->main_loop.add_item = do_add_item;
 | 
					  priv->main_loop.add_item = do_add_item;
 | 
				
			||||||
  priv->main_loop.update_item = do_update_item;
 | 
					  priv->main_loop.update_item = do_update_item;
 | 
				
			||||||
  priv->main_loop.remove_item = do_remove_item;
 | 
					  priv->main_loop.remove_item = do_remove_item;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,7 +85,7 @@ void              pinos_daemon_unexport          (PinosDaemon *daemon, const gch
 | 
				
			||||||
void              pinos_daemon_add_node          (PinosDaemon *daemon, PinosNode *node);
 | 
					void              pinos_daemon_add_node          (PinosDaemon *daemon, PinosNode *node);
 | 
				
			||||||
void              pinos_daemon_remove_node       (PinosDaemon *daemon, PinosNode *node);
 | 
					void              pinos_daemon_remove_node       (PinosDaemon *daemon, PinosNode *node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PinosNode *       pinos_daemon_find_node         (PinosDaemon     *daemon,
 | 
					PinosPort *       pinos_daemon_find_port         (PinosDaemon     *daemon,
 | 
				
			||||||
                                                  PinosDirection   direction,
 | 
					                                                  PinosDirection   direction,
 | 
				
			||||||
                                                  const gchar     *name,
 | 
					                                                  const gchar     *name,
 | 
				
			||||||
                                                  PinosProperties *props,
 | 
					                                                  PinosProperties *props,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,6 +74,8 @@ enum
 | 
				
			||||||
enum
 | 
					enum
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SIGNAL_REMOVE,
 | 
					  SIGNAL_REMOVE,
 | 
				
			||||||
 | 
					  SIGNAL_INPUT_UNLINKED,
 | 
				
			||||||
 | 
					  SIGNAL_OUTPUT_UNLINKED,
 | 
				
			||||||
  LAST_SIGNAL
 | 
					  LAST_SIGNAL
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -735,12 +737,22 @@ on_property_notify (GObject    *obj,
 | 
				
			||||||
  PinosLinkPrivate *priv = this->priv;
 | 
					  PinosLinkPrivate *priv = this->priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "output-port") == 0) {
 | 
					  if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "output-port") == 0) {
 | 
				
			||||||
 | 
					    if (this->output) {
 | 
				
			||||||
      pinos_link1_set_output_node (priv->iface, pinos_node_get_object_path (this->output->node));
 | 
					      pinos_link1_set_output_node (priv->iface, pinos_node_get_object_path (this->output->node));
 | 
				
			||||||
      pinos_link1_set_output_port (priv->iface, this->output->port);
 | 
					      pinos_link1_set_output_port (priv->iface, this->output->port);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      pinos_link1_set_output_node (priv->iface, "/");
 | 
				
			||||||
 | 
					      pinos_link1_set_output_port (priv->iface, -1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "input-port") == 0) {
 | 
					  if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "input-port") == 0) {
 | 
				
			||||||
 | 
					    if (this->input) {
 | 
				
			||||||
      pinos_link1_set_input_node (priv->iface, pinos_node_get_object_path (this->input->node));
 | 
					      pinos_link1_set_input_node (priv->iface, pinos_node_get_object_path (this->input->node));
 | 
				
			||||||
      pinos_link1_set_input_port (priv->iface, this->input->port);
 | 
					      pinos_link1_set_input_port (priv->iface, this->input->port);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      pinos_link1_set_input_node (priv->iface, "/");
 | 
				
			||||||
 | 
					      pinos_link1_set_input_port (priv->iface, -1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -756,14 +768,19 @@ on_node_remove (PinosNode *node, PinosLink *this)
 | 
				
			||||||
      priv->n_buffers = 0;
 | 
					      priv->n_buffers = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    this->input = NULL;
 | 
					    this->input = NULL;
 | 
				
			||||||
 | 
					    g_object_notify (G_OBJECT (this), "input-port");
 | 
				
			||||||
 | 
					    g_signal_emit (this, signals[SIGNAL_INPUT_UNLINKED], 0, node);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    if (this->output->allocated) {
 | 
					    if (this->output->allocated) {
 | 
				
			||||||
      priv->buffers = NULL;
 | 
					      priv->buffers = NULL;
 | 
				
			||||||
      priv->n_buffers = 0;
 | 
					      priv->n_buffers = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    this->output = NULL;
 | 
					    this->output = NULL;
 | 
				
			||||||
 | 
					    g_object_notify (G_OBJECT (this), "output-port");
 | 
				
			||||||
 | 
					    g_signal_emit (this, signals[SIGNAL_OUTPUT_UNLINKED], 0, node);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (this->input == NULL || this->output == NULL)
 | 
				
			||||||
    pinos_link_update_state (this, PINOS_LINK_STATE_UNLINKED);
 | 
					    pinos_link_update_state (this, PINOS_LINK_STATE_UNLINKED);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -796,9 +813,9 @@ pinos_link_dispose (GObject * object)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_debug ("link %p: dispose", this);
 | 
					  g_debug ("link %p: dispose", this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (this->input->node)
 | 
					  if (this->input && this->input->node)
 | 
				
			||||||
    g_signal_handlers_disconnect_by_data (this->input->node, this);
 | 
					    g_signal_handlers_disconnect_by_data (this->input->node, this);
 | 
				
			||||||
  if (this->output->node)
 | 
					  if (this->output && this->output->node)
 | 
				
			||||||
    g_signal_handlers_disconnect_by_data (this->output->node, this);
 | 
					    g_signal_handlers_disconnect_by_data (this->output->node, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_signal_emit (this, signals[SIGNAL_REMOVE], 0, NULL);
 | 
					  g_signal_emit (this, signals[SIGNAL_REMOVE], 0, NULL);
 | 
				
			||||||
| 
						 | 
					@ -929,6 +946,26 @@ pinos_link_class_init (PinosLinkClass * klass)
 | 
				
			||||||
                                         G_TYPE_NONE,
 | 
					                                         G_TYPE_NONE,
 | 
				
			||||||
                                         0,
 | 
					                                         0,
 | 
				
			||||||
                                         G_TYPE_NONE);
 | 
					                                         G_TYPE_NONE);
 | 
				
			||||||
 | 
					  signals[SIGNAL_INPUT_UNLINKED] = g_signal_new ("input-unlinked",
 | 
				
			||||||
 | 
					                                         G_TYPE_FROM_CLASS (klass),
 | 
				
			||||||
 | 
					                                         G_SIGNAL_RUN_LAST,
 | 
				
			||||||
 | 
					                                         0,
 | 
				
			||||||
 | 
					                                         NULL,
 | 
				
			||||||
 | 
					                                         NULL,
 | 
				
			||||||
 | 
					                                         g_cclosure_marshal_generic,
 | 
				
			||||||
 | 
					                                         G_TYPE_NONE,
 | 
				
			||||||
 | 
					                                         1,
 | 
				
			||||||
 | 
					                                         G_TYPE_POINTER);
 | 
				
			||||||
 | 
					  signals[SIGNAL_OUTPUT_UNLINKED] = g_signal_new ("output-unlinked",
 | 
				
			||||||
 | 
					                                         G_TYPE_FROM_CLASS (klass),
 | 
				
			||||||
 | 
					                                         G_SIGNAL_RUN_LAST,
 | 
				
			||||||
 | 
					                                         0,
 | 
				
			||||||
 | 
					                                         NULL,
 | 
				
			||||||
 | 
					                                         NULL,
 | 
				
			||||||
 | 
					                                         g_cclosure_marshal_generic,
 | 
				
			||||||
 | 
					                                         G_TYPE_NONE,
 | 
				
			||||||
 | 
					                                         1,
 | 
				
			||||||
 | 
					                                         G_TYPE_POINTER);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,15 +41,6 @@ typedef struct _PinosLinkPrivate PinosLinkPrivate;
 | 
				
			||||||
#define PINOS_LINK_CAST(obj)        ((PinosLink*)(obj))
 | 
					#define PINOS_LINK_CAST(obj)        ((PinosLink*)(obj))
 | 
				
			||||||
#define PINOS_LINK_CLASS_CAST(klass)((PinosLinkClass*)(klass))
 | 
					#define PINOS_LINK_CLASS_CAST(klass)((PinosLinkClass*)(klass))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
  PinosNode      *node;
 | 
					 | 
				
			||||||
  uint32_t        port;
 | 
					 | 
				
			||||||
  gboolean        allocated;
 | 
					 | 
				
			||||||
  PinosMemblock   buffer_mem;
 | 
					 | 
				
			||||||
  SpaBuffer     **buffers;
 | 
					 | 
				
			||||||
  guint           n_buffers;
 | 
					 | 
				
			||||||
} PinosPort;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PinosLink:
 | 
					 * PinosLink:
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,36 +33,32 @@
 | 
				
			||||||
#define PINOS_NODE_GET_PRIVATE(node)  \
 | 
					#define PINOS_NODE_GET_PRIVATE(node)  \
 | 
				
			||||||
   (G_TYPE_INSTANCE_GET_PRIVATE ((node), PINOS_TYPE_NODE, PinosNodePrivate))
 | 
					   (G_TYPE_INSTANCE_GET_PRIVATE ((node), PINOS_TYPE_NODE, PinosNodePrivate))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					static PinosPort *
 | 
				
			||||||
  PinosPort port;
 | 
					new_pinos_port (PinosNode *node, PinosDirection direction, uint32_t port)
 | 
				
			||||||
  GPtrArray *links;
 | 
					 | 
				
			||||||
} NodePort;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static NodePort *
 | 
					 | 
				
			||||||
new_node_port (PinosNode *node, uint32_t port)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  NodePort *np;
 | 
					  PinosPort *np;
 | 
				
			||||||
  np = g_slice_new0 (NodePort);
 | 
					  np = g_slice_new0 (PinosPort);
 | 
				
			||||||
  np->port.node = node;
 | 
					  np->node = node;
 | 
				
			||||||
  np->port.port = port;
 | 
					  np->direction = direction;
 | 
				
			||||||
 | 
					  np->port = port;
 | 
				
			||||||
  np->links = g_ptr_array_new ();
 | 
					  np->links = g_ptr_array_new ();
 | 
				
			||||||
  return np;
 | 
					  return np;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
free_node_port (NodePort *np)
 | 
					free_node_port (PinosPort *np)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  g_ptr_array_free (np->links, TRUE);
 | 
					  g_ptr_array_free (np->links, TRUE);
 | 
				
			||||||
  g_slice_free (NodePort, np);
 | 
					  g_slice_free (PinosPort, np);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static NodePort *
 | 
					static PinosPort *
 | 
				
			||||||
find_node_port (GList *ports, PinosNode *node, uint32_t port)
 | 
					find_node_port (GList *ports, PinosNode *node, uint32_t port)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  GList *walk;
 | 
					  GList *walk;
 | 
				
			||||||
  for (walk = ports; walk; walk = g_list_next (walk)) {
 | 
					  for (walk = ports; walk; walk = g_list_next (walk)) {
 | 
				
			||||||
    NodePort *np = walk->data;
 | 
					    PinosPort *np = walk->data;
 | 
				
			||||||
    if (np->port.node == node && np->port.port == port)
 | 
					    if (np->node == node && np->port == port)
 | 
				
			||||||
      return np;
 | 
					      return np;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return NULL;
 | 
					  return NULL;
 | 
				
			||||||
| 
						 | 
					@ -162,33 +158,33 @@ update_port_ids (PinosNode *node, gboolean create)
 | 
				
			||||||
  i = 0;
 | 
					  i = 0;
 | 
				
			||||||
  ports = priv->input_ports;
 | 
					  ports = priv->input_ports;
 | 
				
			||||||
  while (true) {
 | 
					  while (true) {
 | 
				
			||||||
    NodePort *p = (ports ? ports->data : NULL);
 | 
					    PinosPort *p = (ports ? ports->data : NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (p && i < n_input_ports && p->port.port == input_port_ids[i]) {
 | 
					    if (p && i < n_input_ports && p->port == input_port_ids[i]) {
 | 
				
			||||||
      i++;
 | 
					      i++;
 | 
				
			||||||
      ports = g_list_next (ports);
 | 
					      ports = g_list_next (ports);
 | 
				
			||||||
    } else if ((p && i < n_input_ports && input_port_ids[i] < p->port.port) || i < n_input_ports) {
 | 
					    } else if ((p && i < n_input_ports && input_port_ids[i] < p->port) || i < n_input_ports) {
 | 
				
			||||||
      NodePort *np;
 | 
					      PinosPort *np;
 | 
				
			||||||
      g_debug ("node %p: input port added %d", node, input_port_ids[i]);
 | 
					      g_debug ("node %p: input port added %d", node, input_port_ids[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      np = new_node_port (node, input_port_ids[i]);
 | 
					      np = new_pinos_port (node, PINOS_DIRECTION_INPUT, input_port_ids[i]);
 | 
				
			||||||
      priv->input_ports = g_list_insert_before (priv->input_ports, ports, np);
 | 
					      priv->input_ports = g_list_insert_before (priv->input_ports, ports, np);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!priv->async_init)
 | 
					      if (!priv->async_init)
 | 
				
			||||||
        g_signal_emit (node, signals[SIGNAL_PORT_ADDED], 0, PINOS_DIRECTION_INPUT);
 | 
					        g_signal_emit (node, signals[SIGNAL_PORT_ADDED], 0, np);
 | 
				
			||||||
      i++;
 | 
					      i++;
 | 
				
			||||||
    } else if (p) {
 | 
					    } else if (p) {
 | 
				
			||||||
      GList *next;
 | 
					      GList *next;
 | 
				
			||||||
      g_debug ("node %p: input port removed %d", node, p->port.port);
 | 
					      g_debug ("node %p: input port removed %d", node, p->port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      next = g_list_next (ports);
 | 
					      next = g_list_next (ports);
 | 
				
			||||||
      priv->input_ports = g_list_delete_link (priv->input_ports, ports);
 | 
					      priv->input_ports = g_list_delete_link (priv->input_ports, ports);
 | 
				
			||||||
      ports = next;
 | 
					      ports = next;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      free_node_port (p);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (!priv->async_init)
 | 
					      if (!priv->async_init)
 | 
				
			||||||
        g_signal_emit (node, signals[SIGNAL_PORT_REMOVED], 0, PINOS_DIRECTION_INPUT);
 | 
					        g_signal_emit (node, signals[SIGNAL_PORT_REMOVED], 0, p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      free_node_port (p);
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -196,33 +192,33 @@ update_port_ids (PinosNode *node, gboolean create)
 | 
				
			||||||
  i = 0;
 | 
					  i = 0;
 | 
				
			||||||
  ports = priv->output_ports;
 | 
					  ports = priv->output_ports;
 | 
				
			||||||
  while (true) {
 | 
					  while (true) {
 | 
				
			||||||
    NodePort *p = (ports ? ports->data : NULL);
 | 
					    PinosPort *p = (ports ? ports->data : NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (p && i < n_output_ports && p->port.port == output_port_ids[i]) {
 | 
					    if (p && i < n_output_ports && p->port == output_port_ids[i]) {
 | 
				
			||||||
      i++;
 | 
					      i++;
 | 
				
			||||||
      ports = g_list_next (ports);
 | 
					      ports = g_list_next (ports);
 | 
				
			||||||
    } else if ((p && i < n_output_ports && output_port_ids[i] < p->port.port) || i < n_output_ports) {
 | 
					    } else if ((p && i < n_output_ports && output_port_ids[i] < p->port) || i < n_output_ports) {
 | 
				
			||||||
      NodePort *np;
 | 
					      PinosPort *np;
 | 
				
			||||||
      g_debug ("node %p: output port added %d", node, output_port_ids[i]);
 | 
					      g_debug ("node %p: output port added %d", node, output_port_ids[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      np = new_node_port (node, output_port_ids[i]);
 | 
					      np = new_pinos_port (node, PINOS_DIRECTION_OUTPUT, output_port_ids[i]);
 | 
				
			||||||
      priv->output_ports = g_list_insert_before (priv->output_ports, ports, np);
 | 
					      priv->output_ports = g_list_insert_before (priv->output_ports, ports, np);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!priv->async_init)
 | 
					      if (!priv->async_init)
 | 
				
			||||||
        g_signal_emit (node, signals[SIGNAL_PORT_ADDED], 0, PINOS_DIRECTION_INPUT);
 | 
					        g_signal_emit (node, signals[SIGNAL_PORT_ADDED], 0, np);
 | 
				
			||||||
      i++;
 | 
					      i++;
 | 
				
			||||||
    } else if (p) {
 | 
					    } else if (p) {
 | 
				
			||||||
      GList *next;
 | 
					      GList *next;
 | 
				
			||||||
      g_debug ("node %p: output port removed %d", node, p->port.port);
 | 
					      g_debug ("node %p: output port removed %d", node, p->port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      next = g_list_next (ports);
 | 
					      next = g_list_next (ports);
 | 
				
			||||||
      priv->output_ports = g_list_delete_link (priv->output_ports, ports);
 | 
					      priv->output_ports = g_list_delete_link (priv->output_ports, ports);
 | 
				
			||||||
      ports = next;
 | 
					      ports = next;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      free_node_port (p);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (!priv->async_init)
 | 
					      if (!priv->async_init)
 | 
				
			||||||
        g_signal_emit (node, signals[SIGNAL_PORT_REMOVED], 0, PINOS_DIRECTION_INPUT);
 | 
					        g_signal_emit (node, signals[SIGNAL_PORT_REMOVED], 0, p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      free_node_port (p);
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -281,24 +277,24 @@ suspend_node (PinosNode *this)
 | 
				
			||||||
  g_debug ("node %p: suspend node", this);
 | 
					  g_debug ("node %p: suspend node", this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (walk = priv->input_ports; walk; walk = g_list_next (walk)) {
 | 
					  for (walk = priv->input_ports; walk; walk = g_list_next (walk)) {
 | 
				
			||||||
    NodePort *p = walk->data;
 | 
					    PinosPort *p = walk->data;
 | 
				
			||||||
    if ((res = spa_node_port_set_format (this->node, SPA_DIRECTION_INPUT, p->port.port, 0, NULL)) < 0)
 | 
					    if ((res = spa_node_port_set_format (this->node, SPA_DIRECTION_INPUT, p->port, 0, NULL)) < 0)
 | 
				
			||||||
      g_warning ("error unset format output: %d", res);
 | 
					      g_warning ("error unset format output: %d", res);
 | 
				
			||||||
    p->port.buffers = NULL;
 | 
					    p->buffers = NULL;
 | 
				
			||||||
    p->port.n_buffers = 0;
 | 
					    p->n_buffers = 0;
 | 
				
			||||||
    if (p->port.allocated)
 | 
					    if (p->allocated)
 | 
				
			||||||
      pinos_memblock_free (&p->port.buffer_mem);
 | 
					      pinos_memblock_free (&p->buffer_mem);
 | 
				
			||||||
    p->port.allocated = FALSE;
 | 
					    p->allocated = FALSE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  for (walk = priv->output_ports; walk; walk = g_list_next (walk)) {
 | 
					  for (walk = priv->output_ports; walk; walk = g_list_next (walk)) {
 | 
				
			||||||
    NodePort *p = walk->data;
 | 
					    PinosPort *p = walk->data;
 | 
				
			||||||
    if ((res = spa_node_port_set_format (this->node, SPA_DIRECTION_OUTPUT, p->port.port, 0, NULL)) < 0)
 | 
					    if ((res = spa_node_port_set_format (this->node, SPA_DIRECTION_OUTPUT, p->port, 0, NULL)) < 0)
 | 
				
			||||||
      g_warning ("error unset format output: %d", res);
 | 
					      g_warning ("error unset format output: %d", res);
 | 
				
			||||||
    p->port.buffers = NULL;
 | 
					    p->buffers = NULL;
 | 
				
			||||||
    p->port.n_buffers = 0;
 | 
					    p->n_buffers = 0;
 | 
				
			||||||
    if (p->port.allocated)
 | 
					    if (p->allocated)
 | 
				
			||||||
      pinos_memblock_free (&p->port.buffer_mem);
 | 
					      pinos_memblock_free (&p->buffer_mem);
 | 
				
			||||||
    p->port.allocated = FALSE;
 | 
					    p->allocated = FALSE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return res;
 | 
					  return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -457,7 +453,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
 | 
				
			||||||
    case SPA_NODE_EVENT_TYPE_NEED_INPUT:
 | 
					    case SPA_NODE_EVENT_TYPE_NEED_INPUT:
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      SpaNodeEventNeedInput *ni = event->data;
 | 
					      SpaNodeEventNeedInput *ni = event->data;
 | 
				
			||||||
      NodePort *p;
 | 
					      PinosPort *p;
 | 
				
			||||||
      guint i;
 | 
					      guint i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!(p = find_node_port (priv->input_ports, this, ni->port_id)))
 | 
					      if (!(p = find_node_port (priv->input_ports, this, ni->port_id)))
 | 
				
			||||||
| 
						 | 
					@ -477,7 +473,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
 | 
				
			||||||
      SpaPortOutputInfo oinfo[1] = { 0, };
 | 
					      SpaPortOutputInfo oinfo[1] = { 0, };
 | 
				
			||||||
      SpaResult res;
 | 
					      SpaResult res;
 | 
				
			||||||
      gboolean pushed = FALSE;
 | 
					      gboolean pushed = FALSE;
 | 
				
			||||||
      NodePort *p;
 | 
					      PinosPort *p;
 | 
				
			||||||
      guint i;
 | 
					      guint i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      oinfo[0].port_id = ho->port_id;
 | 
					      oinfo[0].port_id = ho->port_id;
 | 
				
			||||||
| 
						 | 
					@ -513,7 +509,7 @@ on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      SpaResult res;
 | 
					      SpaResult res;
 | 
				
			||||||
      SpaNodeEventReuseBuffer *rb = event->data;
 | 
					      SpaNodeEventReuseBuffer *rb = event->data;
 | 
				
			||||||
      NodePort *p;
 | 
					      PinosPort *p;
 | 
				
			||||||
      guint i;
 | 
					      guint i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!(p = find_node_port (priv->input_ports, this, rb->port_id)))
 | 
					      if (!(p = find_node_port (priv->input_ports, this, rb->port_id)))
 | 
				
			||||||
| 
						 | 
					@ -912,7 +908,7 @@ pinos_node_class_init (PinosNodeClass * klass)
 | 
				
			||||||
                                             g_cclosure_marshal_generic,
 | 
					                                             g_cclosure_marshal_generic,
 | 
				
			||||||
                                             G_TYPE_NONE,
 | 
					                                             G_TYPE_NONE,
 | 
				
			||||||
                                             1,
 | 
					                                             1,
 | 
				
			||||||
                                             PINOS_TYPE_DIRECTION);
 | 
					                                             G_TYPE_POINTER);
 | 
				
			||||||
  signals[SIGNAL_PORT_REMOVED] = g_signal_new ("port-removed",
 | 
					  signals[SIGNAL_PORT_REMOVED] = g_signal_new ("port-removed",
 | 
				
			||||||
                                               G_TYPE_FROM_CLASS (klass),
 | 
					                                               G_TYPE_FROM_CLASS (klass),
 | 
				
			||||||
                                               G_SIGNAL_RUN_LAST,
 | 
					                                               G_SIGNAL_RUN_LAST,
 | 
				
			||||||
| 
						 | 
					@ -922,7 +918,7 @@ pinos_node_class_init (PinosNodeClass * klass)
 | 
				
			||||||
                                               g_cclosure_marshal_generic,
 | 
					                                               g_cclosure_marshal_generic,
 | 
				
			||||||
                                               G_TYPE_NONE,
 | 
					                                               G_TYPE_NONE,
 | 
				
			||||||
                                               1,
 | 
					                                               1,
 | 
				
			||||||
                                               PINOS_TYPE_DIRECTION);
 | 
					                                               G_TYPE_POINTER);
 | 
				
			||||||
  signals[SIGNAL_ASYNC_COMPLETE] = g_signal_new ("async-complete",
 | 
					  signals[SIGNAL_ASYNC_COMPLETE] = g_signal_new ("async-complete",
 | 
				
			||||||
                                               G_TYPE_FROM_CLASS (klass),
 | 
					                                               G_TYPE_FROM_CLASS (klass),
 | 
				
			||||||
                                               G_SIGNAL_RUN_LAST,
 | 
					                                               G_SIGNAL_RUN_LAST,
 | 
				
			||||||
| 
						 | 
					@ -953,35 +949,6 @@ pinos_node_init (PinosNode * node)
 | 
				
			||||||
  pinos_node1_set_state (priv->iface, priv->state);
 | 
					  pinos_node1_set_state (priv->iface, priv->state);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * pinos_node_new:
 | 
					 | 
				
			||||||
 * @daemon: a #PinosDaemon
 | 
					 | 
				
			||||||
 * @client: the client owner
 | 
					 | 
				
			||||||
 * @name: a name
 | 
					 | 
				
			||||||
 * @properties: extra properties
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Create a new #PinosNode.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Returns: a new #PinosNode
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
PinosNode *
 | 
					 | 
				
			||||||
pinos_node_new (PinosDaemon     *daemon,
 | 
					 | 
				
			||||||
                PinosClient     *client,
 | 
					 | 
				
			||||||
                const gchar     *name,
 | 
					 | 
				
			||||||
                PinosProperties *properties,
 | 
					 | 
				
			||||||
                SpaNode         *node)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return g_object_new (PINOS_TYPE_NODE,
 | 
					 | 
				
			||||||
                       "daemon", daemon,
 | 
					 | 
				
			||||||
                       "client", client,
 | 
					 | 
				
			||||||
                       "name", name,
 | 
					 | 
				
			||||||
                       "properties", properties,
 | 
					 | 
				
			||||||
                       "node", node,
 | 
					 | 
				
			||||||
                       NULL);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * pinos_node_get_name:
 | 
					 * pinos_node_get_name:
 | 
				
			||||||
 * @node: a #PinosNode
 | 
					 * @node: a #PinosNode
 | 
				
			||||||
| 
						 | 
					@ -1120,15 +1087,16 @@ pinos_node_remove (PinosNode *node)
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: the new port id or %SPA_ID_INVALID on error
 | 
					 * Returns: the new port id or %SPA_ID_INVALID on error
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
guint
 | 
					PinosPort *
 | 
				
			||||||
pinos_node_get_free_port (PinosNode       *node,
 | 
					pinos_node_get_free_port (PinosNode       *node,
 | 
				
			||||||
                          PinosDirection   direction)
 | 
					                          PinosDirection   direction)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosNodePrivate *priv;
 | 
					  PinosNodePrivate *priv;
 | 
				
			||||||
  guint free_port, n_ports, max_ports;
 | 
					  guint free_port, n_ports, max_ports;
 | 
				
			||||||
  GList *ports, *walk;
 | 
					  GList *ports, *walk;
 | 
				
			||||||
 | 
					  PinosPort *port = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_return_val_if_fail (PINOS_IS_NODE (node), SPA_ID_INVALID);
 | 
					  g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
 | 
				
			||||||
  priv = node->priv;
 | 
					  priv = node->priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (direction == PINOS_DIRECTION_INPUT) {
 | 
					  if (direction == PINOS_DIRECTION_INPUT) {
 | 
				
			||||||
| 
						 | 
					@ -1147,26 +1115,25 @@ pinos_node_get_free_port (PinosNode       *node,
 | 
				
			||||||
  for (walk = ports; walk; walk = g_list_next (walk)) {
 | 
					  for (walk = ports; walk; walk = g_list_next (walk)) {
 | 
				
			||||||
    PinosPort *p = walk->data;
 | 
					    PinosPort *p = walk->data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (free_port < p->port)
 | 
					    if (free_port < p->port) {
 | 
				
			||||||
 | 
					      port = p;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    free_port = p->port + 1;
 | 
					    free_port = p->port + 1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (free_port >= max_ports && ports) {
 | 
					  if (free_port >= max_ports && ports) {
 | 
				
			||||||
    PinosPort *p = ports->data;
 | 
					    port = ports->data;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    free_port = p->port;
 | 
					 | 
				
			||||||
  } else
 | 
					  } else
 | 
				
			||||||
    return SPA_ID_INVALID;
 | 
					    return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return free_port;
 | 
					  return port;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
do_remove_link (PinosLink *link, PinosNode *node)
 | 
					do_remove_link (PinosLink *link, PinosNode *node)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  NodePort *p;
 | 
					  PinosPort *p;
 | 
				
			||||||
  PinosNode *n;
 | 
					  PinosNode *n;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (link->output) {
 | 
					  if (link->output) {
 | 
				
			||||||
| 
						 | 
					@ -1195,13 +1162,12 @@ do_remove_link (PinosLink *link, PinosNode *node)
 | 
				
			||||||
 * pinos_node_link:
 | 
					 * pinos_node_link:
 | 
				
			||||||
 * @output_node: a #PinosNode
 | 
					 * @output_node: a #PinosNode
 | 
				
			||||||
 * @output_port: an output port
 | 
					 * @output_port: an output port
 | 
				
			||||||
 * @input_node: a #PinosNode
 | 
					 | 
				
			||||||
 * @input_port: an input port
 | 
					 * @input_port: an input port
 | 
				
			||||||
 * @format_filter: a format filter
 | 
					 * @format_filter: a format filter
 | 
				
			||||||
 * @properties: extra properties
 | 
					 * @properties: extra properties
 | 
				
			||||||
 * @error: an error or %NULL
 | 
					 * @error: an error or %NULL
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Make a link between @output_node and @input_node with the given ids
 | 
					 * Make a link between @output_port and @input_port with the given ids
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * If the ports were already linked, the existing links will be returned.
 | 
					 * If the ports were already linked, the existing links will be returned.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -1212,47 +1178,41 @@ do_remove_link (PinosLink *link, PinosNode *node)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
PinosLink *
 | 
					PinosLink *
 | 
				
			||||||
pinos_node_link (PinosNode       *output_node,
 | 
					pinos_node_link (PinosNode       *output_node,
 | 
				
			||||||
                 guint            output_port,
 | 
					                 PinosPort       *output_port,
 | 
				
			||||||
                 PinosNode       *input_node,
 | 
					                 PinosPort       *input_port,
 | 
				
			||||||
                 guint            input_port,
 | 
					 | 
				
			||||||
                 GPtrArray       *format_filter,
 | 
					                 GPtrArray       *format_filter,
 | 
				
			||||||
                 PinosProperties *properties,
 | 
					                 PinosProperties *properties,
 | 
				
			||||||
                 GError         **error)
 | 
					                 GError         **error)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosNodePrivate *priv;
 | 
					  PinosNodePrivate *priv;
 | 
				
			||||||
  NodePort *onp, *inp;
 | 
					  PinosNode *input_node;
 | 
				
			||||||
  PinosLink *link = NULL;
 | 
					  PinosLink *link = NULL;
 | 
				
			||||||
  guint i;
 | 
					  guint i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_return_val_if_fail (PINOS_IS_NODE (output_node), NULL);
 | 
					  g_return_val_if_fail (PINOS_IS_NODE (output_node), NULL);
 | 
				
			||||||
  g_return_val_if_fail (PINOS_IS_NODE (input_node), NULL);
 | 
					  g_return_val_if_fail (output_port != NULL, NULL);
 | 
				
			||||||
 | 
					  g_return_val_if_fail (input_port != NULL, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  priv = output_node->priv;
 | 
					  priv = output_node->priv;
 | 
				
			||||||
 | 
					  input_node = input_port->node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_debug ("node %p: link %u %p:%u", output_node, output_port, input_node, input_port);
 | 
					  g_debug ("node %p: link %u %p:%u", output_node, output_port->port, input_node, input_port->port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (output_node == input_node)
 | 
					  if (output_node == input_node)
 | 
				
			||||||
    goto same_node;
 | 
					    goto same_node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  onp = find_node_port (priv->output_ports, output_node, output_port);
 | 
					  for (i = 0; i < output_port->links->len; i++) {
 | 
				
			||||||
  if (onp == NULL)
 | 
					    PinosLink *pl = g_ptr_array_index (output_port->links, i);
 | 
				
			||||||
      goto no_output_ports;
 | 
					    if (pl->input->node == input_node && pl->input == input_port) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (i = 0; i < onp->links->len; i++) {
 | 
					 | 
				
			||||||
    PinosLink *pl = g_ptr_array_index (onp->links, i);
 | 
					 | 
				
			||||||
    if (pl->input->node == input_node && pl->input->port == input_port) {
 | 
					 | 
				
			||||||
      link = pl;
 | 
					      link = pl;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  inp = find_node_port (input_node->priv->input_ports, input_node, input_port);
 | 
					 | 
				
			||||||
  if (inp == NULL)
 | 
					 | 
				
			||||||
      goto no_input_ports;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (link)  {
 | 
					  if (link)  {
 | 
				
			||||||
    /* FIXME */
 | 
					    /* FIXME */
 | 
				
			||||||
    link->input->node = input_node;
 | 
					    link->input->node = input_node;
 | 
				
			||||||
    link->input->port = input_port;
 | 
					    link->input = input_port;
 | 
				
			||||||
    g_object_ref (link);
 | 
					    g_object_ref (link);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    input_node->live = output_node->live;
 | 
					    input_node->live = output_node->live;
 | 
				
			||||||
| 
						 | 
					@ -1262,14 +1222,14 @@ pinos_node_link (PinosNode       *output_node,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    link = g_object_new (PINOS_TYPE_LINK,
 | 
					    link = g_object_new (PINOS_TYPE_LINK,
 | 
				
			||||||
                       "daemon", priv->daemon,
 | 
					                       "daemon", priv->daemon,
 | 
				
			||||||
                       "output-port", &onp->port,
 | 
					                       "output-port", output_port,
 | 
				
			||||||
                       "input-port", &inp->port,
 | 
					                       "input-port", input_port,
 | 
				
			||||||
                       "format-filter", format_filter,
 | 
					                       "format-filter", format_filter,
 | 
				
			||||||
                       "properties", properties,
 | 
					                       "properties", properties,
 | 
				
			||||||
                       NULL);
 | 
					                       NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_ptr_array_add (onp->links, link);
 | 
					    g_ptr_array_add (output_port->links, link);
 | 
				
			||||||
    g_ptr_array_add (inp->links, link);
 | 
					    g_ptr_array_add (input_port->links, link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_signal_connect (link,
 | 
					    g_signal_connect (link,
 | 
				
			||||||
                      "remove",
 | 
					                      "remove",
 | 
				
			||||||
| 
						 | 
					@ -1289,37 +1249,32 @@ same_node:
 | 
				
			||||||
                 "can't link a node to itself");
 | 
					                 "can't link a node to itself");
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
no_input_ports:
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    g_set_error (error,
 | 
					 | 
				
			||||||
                 PINOS_ERROR,
 | 
					 | 
				
			||||||
                 PINOS_ERROR_NODE_LINK,
 | 
					 | 
				
			||||||
                 "can't get an input port to link to");
 | 
					 | 
				
			||||||
    return NULL;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
no_output_ports:
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    g_set_error (error,
 | 
					 | 
				
			||||||
                 PINOS_ERROR,
 | 
					 | 
				
			||||||
                 PINOS_ERROR_NODE_LINK,
 | 
					 | 
				
			||||||
                 "can't get an output port to link to");
 | 
					 | 
				
			||||||
    return NULL;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * pinos_node_get_links:
 | 
					 * pinos_node_get_ports:
 | 
				
			||||||
 * @node: a #PinosNode
 | 
					 * @node: a #PinosNode
 | 
				
			||||||
 | 
					 * @direction: a #PinosDirection
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Get the links in @node.
 | 
					 * Get the port in @node.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Returns: a #GList of #PinosLink g_list_free after usage.
 | 
					 * Returns: a #GList of #PinosPort g_list_free after usage.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
GList *
 | 
					GList *
 | 
				
			||||||
pinos_node_get_links (PinosNode *node)
 | 
					pinos_node_get_ports (PinosNode *node, PinosDirection direction)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  GList *ports;
 | 
				
			||||||
 | 
					  PinosNodePrivate *priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
 | 
					  g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
 | 
				
			||||||
  return NULL;
 | 
					  priv = node->priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (direction == PINOS_DIRECTION_INPUT) {
 | 
				
			||||||
 | 
					    ports = priv->input_ports;
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    ports = priv->output_ports;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return ports;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
G_BEGIN_DECLS
 | 
					G_BEGIN_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct _PinosPort PinosPort;
 | 
				
			||||||
typedef struct _PinosNode PinosNode;
 | 
					typedef struct _PinosNode PinosNode;
 | 
				
			||||||
typedef struct _PinosNodeClass PinosNodeClass;
 | 
					typedef struct _PinosNodeClass PinosNodeClass;
 | 
				
			||||||
typedef struct _PinosNodePrivate PinosNodePrivate;
 | 
					typedef struct _PinosNodePrivate PinosNodePrivate;
 | 
				
			||||||
| 
						 | 
					@ -34,6 +35,18 @@ typedef struct _PinosNodePrivate PinosNodePrivate;
 | 
				
			||||||
#include <pinos/server/daemon.h>
 | 
					#include <pinos/server/daemon.h>
 | 
				
			||||||
#include <pinos/server/link.h>
 | 
					#include <pinos/server/link.h>
 | 
				
			||||||
#include <pinos/server/client.h>
 | 
					#include <pinos/server/client.h>
 | 
				
			||||||
 | 
					#include <pinos/server/utils.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct _PinosPort {
 | 
				
			||||||
 | 
					  PinosNode      *node;
 | 
				
			||||||
 | 
					  PinosDirection  direction;
 | 
				
			||||||
 | 
					  uint32_t        port;
 | 
				
			||||||
 | 
					  gboolean        allocated;
 | 
				
			||||||
 | 
					  PinosMemblock   buffer_mem;
 | 
				
			||||||
 | 
					  SpaBuffer     **buffers;
 | 
				
			||||||
 | 
					  guint           n_buffers;
 | 
				
			||||||
 | 
					  GPtrArray      *links;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define PINOS_TYPE_NODE                 (pinos_node_get_type ())
 | 
					#define PINOS_TYPE_NODE                 (pinos_node_get_type ())
 | 
				
			||||||
#define PINOS_IS_NODE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_NODE))
 | 
					#define PINOS_IS_NODE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_NODE))
 | 
				
			||||||
| 
						 | 
					@ -79,11 +92,6 @@ struct _PinosNodeClass {
 | 
				
			||||||
/* normal GObject stuff */
 | 
					/* normal GObject stuff */
 | 
				
			||||||
GType               pinos_node_get_type                (void);
 | 
					GType               pinos_node_get_type                (void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PinosNode *         pinos_node_new                     (PinosDaemon      *daemon,
 | 
					 | 
				
			||||||
                                                        PinosClient      *client,
 | 
					 | 
				
			||||||
                                                        const gchar      *name,
 | 
					 | 
				
			||||||
                                                        PinosProperties  *properties,
 | 
					 | 
				
			||||||
                                                        SpaNode          *node);
 | 
					 | 
				
			||||||
void                pinos_node_remove                  (PinosNode *node);
 | 
					void                pinos_node_remove                  (PinosNode *node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const gchar *       pinos_node_get_name                (PinosNode *node);
 | 
					const gchar *       pinos_node_get_name                (PinosNode *node);
 | 
				
			||||||
| 
						 | 
					@ -93,18 +101,17 @@ PinosDaemon *       pinos_node_get_daemon              (PinosNode        *node);
 | 
				
			||||||
PinosClient *       pinos_node_get_client              (PinosNode        *node);
 | 
					PinosClient *       pinos_node_get_client              (PinosNode        *node);
 | 
				
			||||||
const gchar *       pinos_node_get_object_path         (PinosNode        *node);
 | 
					const gchar *       pinos_node_get_object_path         (PinosNode        *node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
guint               pinos_node_get_free_port           (PinosNode        *node,
 | 
					PinosPort *         pinos_node_get_free_port           (PinosNode        *node,
 | 
				
			||||||
                                                        PinosDirection    direction);
 | 
					                                                        PinosDirection    direction);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PinosLink *         pinos_node_link                    (PinosNode        *output_node,
 | 
					PinosLink *         pinos_node_link                    (PinosNode        *output_node,
 | 
				
			||||||
                                                        guint             output_id,
 | 
					                                                        PinosPort        *output_port,
 | 
				
			||||||
                                                        PinosNode        *input_node,
 | 
					                                                        PinosPort        *input_port,
 | 
				
			||||||
                                                        guint             input_id,
 | 
					 | 
				
			||||||
                                                        GPtrArray        *format_filter,
 | 
					                                                        GPtrArray        *format_filter,
 | 
				
			||||||
                                                        PinosProperties  *properties,
 | 
					                                                        PinosProperties  *properties,
 | 
				
			||||||
                                                        GError          **error);
 | 
					                                                        GError          **error);
 | 
				
			||||||
GList *             pinos_node_get_links               (PinosNode        *node);
 | 
					GList *             pinos_node_get_ports               (PinosNode        *node,
 | 
				
			||||||
 | 
					                                                        PinosDirection    direction);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PinosNodeState      pinos_node_get_state               (PinosNode *node);
 | 
					PinosNodeState      pinos_node_get_state               (PinosNode *node);
 | 
				
			||||||
gboolean            pinos_node_set_state               (PinosNode *node, PinosNodeState state);
 | 
					gboolean            pinos_node_set_state               (PinosNode *node, PinosNodeState state);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue