mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	serialize: remove serialization
Remove obsolete serialization code. Merge last bits into stream buffer reconstruction. Use POD copy for the allocation params. Small cleanups
This commit is contained in:
		
							parent
							
								
									8a6ce3b179
								
							
						
					
					
						commit
						1588b9df8d
					
				
					 12 changed files with 66 additions and 279 deletions
				
			
		| 
						 | 
				
			
			@ -30,7 +30,6 @@ pinos_sources = [
 | 
			
		|||
  'properties.c',
 | 
			
		||||
  'protocol-native.c',
 | 
			
		||||
  'proxy.c',
 | 
			
		||||
  'serialize.c',
 | 
			
		||||
  'stream.c',
 | 
			
		||||
  'pinos.c',
 | 
			
		||||
  'rtkit.c',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -798,10 +798,8 @@ client_node_demarshal_use_buffers (void   *object,
 | 
			
		|||
 | 
			
		||||
      if (!spa_pod_iter_get (&it,
 | 
			
		||||
            SPA_POD_TYPE_INT, &m->type,
 | 
			
		||||
            SPA_POD_TYPE_INT, &size, 0))
 | 
			
		||||
            SPA_POD_TYPE_INT, &m->size, 0))
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
      m->size = size;
 | 
			
		||||
    }
 | 
			
		||||
    if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &buf->n_datas, 0))
 | 
			
		||||
      return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,164 +0,0 @@
 | 
			
		|||
/* Simple Plugin API
 | 
			
		||||
 * Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * This library is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU Library General Public
 | 
			
		||||
 * License as published by the Free Software Foundation; either
 | 
			
		||||
 * version 2 of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This library is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
			
		||||
 * Library General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU Library General Public
 | 
			
		||||
 * License along with this library; if not, write to the
 | 
			
		||||
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 | 
			
		||||
 * Boston, MA 02110-1301, USA.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "serialize.h"
 | 
			
		||||
 | 
			
		||||
size_t
 | 
			
		||||
pinos_serialize_buffer_get_size (const SpaBuffer *buffer)
 | 
			
		||||
{
 | 
			
		||||
  size_t size;
 | 
			
		||||
  unsigned int i;
 | 
			
		||||
 | 
			
		||||
  if (buffer == NULL)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  size = sizeof (SpaBuffer);
 | 
			
		||||
  for (i = 0; i < buffer->n_metas; i++)
 | 
			
		||||
    size += sizeof (SpaMeta);
 | 
			
		||||
  for (i = 0; i < buffer->n_datas; i++)
 | 
			
		||||
    size += sizeof (SpaData);
 | 
			
		||||
  return size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t
 | 
			
		||||
pinos_serialize_buffer_serialize (void *dest, const SpaBuffer *buffer)
 | 
			
		||||
{
 | 
			
		||||
  SpaBuffer *tb;
 | 
			
		||||
  SpaMeta *mp;
 | 
			
		||||
  SpaData *dp;
 | 
			
		||||
  void *p;
 | 
			
		||||
  unsigned int i;
 | 
			
		||||
 | 
			
		||||
  if (buffer == NULL)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  tb = dest;
 | 
			
		||||
  memcpy (tb, buffer, sizeof (SpaBuffer));
 | 
			
		||||
  mp = SPA_MEMBER (tb, sizeof(SpaBuffer), SpaMeta);
 | 
			
		||||
  dp = SPA_MEMBER (mp, sizeof(SpaMeta) * tb->n_metas, SpaData);
 | 
			
		||||
  p = SPA_MEMBER (dp, sizeof(SpaData) * tb->n_datas, void);
 | 
			
		||||
 | 
			
		||||
  tb->metas = SPA_INT_TO_PTR (SPA_PTRDIFF (mp, tb));
 | 
			
		||||
  tb->datas = SPA_INT_TO_PTR (SPA_PTRDIFF (dp, tb));
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < tb->n_metas; i++)
 | 
			
		||||
    memcpy (&mp[i], &buffer->metas[i], sizeof (SpaMeta));
 | 
			
		||||
  for (i = 0; i < tb->n_datas; i++)
 | 
			
		||||
    memcpy (&dp[i], &buffer->datas[i], sizeof (SpaData));
 | 
			
		||||
 | 
			
		||||
  return SPA_PTRDIFF (p, tb);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SpaBuffer *
 | 
			
		||||
pinos_serialize_buffer_deserialize (void *src, off_t offset)
 | 
			
		||||
{
 | 
			
		||||
  SpaBuffer *b;
 | 
			
		||||
 | 
			
		||||
  b = SPA_MEMBER (src, offset, SpaBuffer);
 | 
			
		||||
  if (b->metas)
 | 
			
		||||
    b->metas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->metas), SpaMeta);
 | 
			
		||||
  if (b->datas)
 | 
			
		||||
    b->datas = SPA_MEMBER (b, SPA_PTR_TO_INT (b->datas), SpaData);
 | 
			
		||||
 | 
			
		||||
  return b;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SpaBuffer *
 | 
			
		||||
pinos_serialize_buffer_copy_into (void *dest, const SpaBuffer *buffer)
 | 
			
		||||
{
 | 
			
		||||
  if (buffer == NULL)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  pinos_serialize_buffer_serialize (dest, buffer);
 | 
			
		||||
  return pinos_serialize_buffer_deserialize (dest, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t
 | 
			
		||||
pinos_serialize_port_info_get_size (const SpaPortInfo *info)
 | 
			
		||||
{
 | 
			
		||||
  size_t len;
 | 
			
		||||
  unsigned int i;
 | 
			
		||||
 | 
			
		||||
  if (info == NULL)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  len = sizeof (SpaPortInfo);
 | 
			
		||||
  len += info->n_params * sizeof (SpaAllocParam *);
 | 
			
		||||
  for (i = 0; i < info->n_params; i++)
 | 
			
		||||
    len += SPA_POD_SIZE (info->params[i]);
 | 
			
		||||
 | 
			
		||||
  return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t
 | 
			
		||||
pinos_serialize_port_info_serialize (void *p, const SpaPortInfo *info)
 | 
			
		||||
{
 | 
			
		||||
  SpaPortInfo *pi;
 | 
			
		||||
  SpaAllocParam **ap;
 | 
			
		||||
  int i;
 | 
			
		||||
  size_t len;
 | 
			
		||||
 | 
			
		||||
  if (info == NULL)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  pi = p;
 | 
			
		||||
  memcpy (pi, info, sizeof (SpaPortInfo));
 | 
			
		||||
 | 
			
		||||
  ap = SPA_MEMBER (pi, sizeof (SpaPortInfo), SpaAllocParam *);
 | 
			
		||||
  if (info->n_params)
 | 
			
		||||
    pi->params = SPA_INT_TO_PTR (SPA_PTRDIFF (ap, pi));
 | 
			
		||||
  else
 | 
			
		||||
    pi->params = 0;
 | 
			
		||||
  pi->extra = 0;
 | 
			
		||||
 | 
			
		||||
  p = SPA_MEMBER (ap, sizeof (SpaAllocParam*) * info->n_params, void);
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < info->n_params; i++) {
 | 
			
		||||
    len = SPA_POD_SIZE (info->params[i]);
 | 
			
		||||
    memcpy (p, info->params[i], len);
 | 
			
		||||
    ap[i] = SPA_INT_TO_PTR (SPA_PTRDIFF (p, pi));
 | 
			
		||||
    p = SPA_MEMBER (p, len, void);
 | 
			
		||||
  }
 | 
			
		||||
  return SPA_PTRDIFF (p, pi);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SpaPortInfo *
 | 
			
		||||
pinos_serialize_port_info_deserialize (void *p, off_t offset)
 | 
			
		||||
{
 | 
			
		||||
  SpaPortInfo *pi;
 | 
			
		||||
  unsigned int i;
 | 
			
		||||
 | 
			
		||||
  pi = SPA_MEMBER (p, offset, SpaPortInfo);
 | 
			
		||||
  if (pi->params)
 | 
			
		||||
    pi->params = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->params), SpaAllocParam *);
 | 
			
		||||
  for (i = 0; i < pi->n_params; i++) {
 | 
			
		||||
    pi->params[i] = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->params[i]), SpaAllocParam);
 | 
			
		||||
  }
 | 
			
		||||
  return pi;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SpaPortInfo *
 | 
			
		||||
pinos_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info)
 | 
			
		||||
{
 | 
			
		||||
  if (info == NULL)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  pinos_serialize_port_info_serialize (dest, info);
 | 
			
		||||
  return pinos_serialize_port_info_deserialize (dest, 0);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,46 +0,0 @@
 | 
			
		|||
/* Simple Plugin API
 | 
			
		||||
 * Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * This library is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU Library General Public
 | 
			
		||||
 * License as published by the Free Software Foundation; either
 | 
			
		||||
 * version 2 of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This library is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
			
		||||
 * Library General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU Library General Public
 | 
			
		||||
 * License along with this library; if not, write to the
 | 
			
		||||
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 | 
			
		||||
 * Boston, MA 02110-1301, USA.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __PINOS_SERIALIZE_H__
 | 
			
		||||
#define __PINOS_SERIALIZE_H__
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <spa/include/spa/buffer.h>
 | 
			
		||||
#include <spa/include/spa/format.h>
 | 
			
		||||
#include <spa/include/spa/props.h>
 | 
			
		||||
#include <spa/include/spa/port.h>
 | 
			
		||||
 | 
			
		||||
size_t          pinos_serialize_buffer_get_size       (const SpaBuffer *buffer);
 | 
			
		||||
size_t          pinos_serialize_buffer_serialize      (void *dest, const SpaBuffer *buffer);
 | 
			
		||||
SpaBuffer *     pinos_serialize_buffer_deserialize    (void *src, off_t offset);
 | 
			
		||||
SpaBuffer *     pinos_serialize_buffer_copy_into      (void *dest, const SpaBuffer *buffer);
 | 
			
		||||
 | 
			
		||||
size_t          pinos_serialize_port_info_get_size    (const SpaPortInfo *info);
 | 
			
		||||
size_t          pinos_serialize_port_info_serialize   (void *dest, const SpaPortInfo *info);
 | 
			
		||||
SpaPortInfo *   pinos_serialize_port_info_deserialize (void *src, off_t offset);
 | 
			
		||||
SpaPortInfo *   pinos_serialize_port_info_copy_into   (void *dest, const SpaPortInfo *info);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __PINOS_SERIALIZE_H__ */
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +33,6 @@
 | 
			
		|||
#include "pinos/client/connection.h"
 | 
			
		||||
#include "pinos/client/context.h"
 | 
			
		||||
#include "pinos/client/stream.h"
 | 
			
		||||
#include "pinos/client/serialize.h"
 | 
			
		||||
#include "pinos/client/transport.h"
 | 
			
		||||
#include "pinos/client/utils.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -769,7 +768,7 @@ client_node_use_buffers (void                  *object,
 | 
			
		|||
  clear_buffers (stream);
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < n_buffers; i++) {
 | 
			
		||||
    off_t offset = 0;
 | 
			
		||||
    off_t offset;
 | 
			
		||||
 | 
			
		||||
    MemId *mid = find_mem (stream, buffers[i].mem_id);
 | 
			
		||||
    if (mid == NULL) {
 | 
			
		||||
| 
						 | 
				
			
			@ -796,9 +795,17 @@ client_node_use_buffers (void                  *object,
 | 
			
		|||
    {
 | 
			
		||||
      size_t size;
 | 
			
		||||
 | 
			
		||||
      size = pinos_serialize_buffer_get_size (buffers[i].buffer);
 | 
			
		||||
      size = sizeof (SpaBuffer);
 | 
			
		||||
      for (j = 0; j < buffers[i].buffer->n_metas; j++)
 | 
			
		||||
        size += sizeof (SpaMeta);
 | 
			
		||||
      for (j = 0; j < buffers[i].buffer->n_datas; j++)
 | 
			
		||||
        size += sizeof (SpaData);
 | 
			
		||||
 | 
			
		||||
      b = bid->buf = malloc (size);
 | 
			
		||||
      pinos_serialize_buffer_copy_into (b, buffers[i].buffer);
 | 
			
		||||
      memcpy (b, buffers[i].buffer, sizeof (SpaBuffer));
 | 
			
		||||
 | 
			
		||||
      b->metas = SPA_MEMBER (b, sizeof (SpaBuffer), SpaMeta);
 | 
			
		||||
      b->datas = SPA_MEMBER (b->metas, sizeof(SpaMeta) * b->n_metas, SpaData);
 | 
			
		||||
    }
 | 
			
		||||
    bid->id = b->id;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -808,8 +815,10 @@ client_node_use_buffers (void                  *object,
 | 
			
		|||
    }
 | 
			
		||||
    pinos_log_debug ("add buffer %d %d %u", mid->id, bid->id, buffers[i].offset);
 | 
			
		||||
 | 
			
		||||
    offset = 0;
 | 
			
		||||
    for (j = 0; j < b->n_metas; j++) {
 | 
			
		||||
      SpaMeta *m = &b->metas[j];
 | 
			
		||||
      memcpy (m, &buffers[i].buffer->metas[j], sizeof (SpaMeta));
 | 
			
		||||
      m->data = SPA_MEMBER (bid->buf_ptr, offset, void);
 | 
			
		||||
      offset += m->size;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -817,6 +826,7 @@ client_node_use_buffers (void                  *object,
 | 
			
		|||
    for (j = 0; j < b->n_datas; j++) {
 | 
			
		||||
      SpaData *d = &b->datas[j];
 | 
			
		||||
 | 
			
		||||
      memcpy (d, &buffers[i].buffer->datas[j], sizeof (SpaData));
 | 
			
		||||
      d->chunk = SPA_MEMBER (bid->buf_ptr, offset + sizeof (SpaChunk) * j, SpaChunk);
 | 
			
		||||
 | 
			
		||||
      switch (d->type) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,6 +48,7 @@ pinos_spa_pod_copy (const SpaPOD *pod)
 | 
			
		|||
 | 
			
		||||
#define spa_format_copy(f)      ((SpaFormat*)pinos_spa_pod_copy(&(f)->pod))
 | 
			
		||||
#define spa_props_copy(p)       ((SpaProps*)pinos_spa_pod_copy(&(p)->pod))
 | 
			
		||||
#define spa_alloc_param_copy(p) ((SpaAllocParam*)pinos_spa_pod_copy(&(p)->pod))
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}  /* extern "C" */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,6 @@
 | 
			
		|||
 | 
			
		||||
#include "pinos/client/pinos.h"
 | 
			
		||||
#include "pinos/client/interfaces.h"
 | 
			
		||||
#include "pinos/client/serialize.h"
 | 
			
		||||
#include "pinos/client/transport.h"
 | 
			
		||||
 | 
			
		||||
#include "pinos/server/core.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +69,7 @@ struct _ProxyBuffer {
 | 
			
		|||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  bool           valid;
 | 
			
		||||
  SpaPortInfo   *info;
 | 
			
		||||
  SpaPortInfo    info;
 | 
			
		||||
  SpaFormat     *format;
 | 
			
		||||
  uint32_t       n_formats;
 | 
			
		||||
  SpaFormat    **formats;
 | 
			
		||||
| 
						 | 
				
			
			@ -312,7 +311,6 @@ do_update_port (SpaProxy          *this,
 | 
			
		|||
{
 | 
			
		||||
  SpaProxyPort *port;
 | 
			
		||||
  uint32_t i;
 | 
			
		||||
  size_t size;
 | 
			
		||||
 | 
			
		||||
  if (direction == SPA_DIRECTION_INPUT) {
 | 
			
		||||
    port = &this->in_ports[port_id];
 | 
			
		||||
| 
						 | 
				
			
			@ -324,16 +322,10 @@ do_update_port (SpaProxy          *this,
 | 
			
		|||
    for (i = 0; i < port->n_formats; i++)
 | 
			
		||||
      free (port->formats[i]);
 | 
			
		||||
    port->n_formats = n_possible_formats;
 | 
			
		||||
    if (port->n_formats)
 | 
			
		||||
    port->formats = realloc (port->formats, port->n_formats * sizeof (SpaFormat *));
 | 
			
		||||
    else {
 | 
			
		||||
      free (port->formats);
 | 
			
		||||
      port->formats = NULL;
 | 
			
		||||
    }
 | 
			
		||||
    for (i = 0; i < port->n_formats; i++) {
 | 
			
		||||
    for (i = 0; i < port->n_formats; i++)
 | 
			
		||||
      port->formats[i] = spa_format_copy (possible_formats[i]);
 | 
			
		||||
  }
 | 
			
		||||
  }
 | 
			
		||||
  if (change_mask & PINOS_MESSAGE_PORT_UPDATE_FORMAT) {
 | 
			
		||||
    if (port->format)
 | 
			
		||||
      free (port->format);
 | 
			
		||||
| 
						 | 
				
			
			@ -344,10 +336,15 @@ do_update_port (SpaProxy          *this,
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  if (change_mask & PINOS_MESSAGE_PORT_UPDATE_INFO && info) {
 | 
			
		||||
    if (port->info)
 | 
			
		||||
      free (port->info);
 | 
			
		||||
    size = pinos_serialize_port_info_get_size (info);
 | 
			
		||||
    port->info = size ? pinos_serialize_port_info_copy_into (malloc (size), info) : NULL;
 | 
			
		||||
    void *old;
 | 
			
		||||
    for (i = 0; i < port->info.n_params; i++)
 | 
			
		||||
      free (port->info.params[i]);
 | 
			
		||||
    old = port->info.params;
 | 
			
		||||
    port->info = *info;
 | 
			
		||||
    port->info.params = realloc (old, port->info.n_params * sizeof (SpaAllocParam *));
 | 
			
		||||
    for (i = 0; i < port->info.n_params; i++)
 | 
			
		||||
      port->info.params[i] = spa_alloc_param_copy (info->params[i]);
 | 
			
		||||
    port->info.extra = NULL;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!port->valid) {
 | 
			
		||||
| 
						 | 
				
			
			@ -549,7 +546,7 @@ spa_proxy_node_port_get_info (SpaNode            *node,
 | 
			
		|||
 | 
			
		||||
  port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
 | 
			
		||||
 | 
			
		||||
  *info = port->info;
 | 
			
		||||
  *info = &port->info;
 | 
			
		||||
 | 
			
		||||
  return SPA_RESULT_OK;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,6 +107,12 @@ struct _SpaFormat {
 | 
			
		|||
  SpaFormatBody body;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define SPA_FORMAT_INIT(size,type,media_type,media_subtype,...)         \
 | 
			
		||||
  { { size, SPA_POD_TYPE_OBJECT },                                      \
 | 
			
		||||
    { { 0, type },                                                      \
 | 
			
		||||
        SPA_POD_INT_INIT (media_type),                                  \
 | 
			
		||||
        SPA_POD_INT_INIT (media_subtype) } }
 | 
			
		||||
 | 
			
		||||
#define SPA_FORMAT_BODY_FOREACH(body, size, iter) \
 | 
			
		||||
  for ((iter) = SPA_MEMBER ((body), sizeof (SpaFormatBody), SpaPODProp); \
 | 
			
		||||
       (iter) < SPA_MEMBER ((body), (size), SpaPODProp); \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,19 +72,9 @@ typedef enum {
 | 
			
		|||
  SPA_PORT_FORMAT_FLAG_NEAREST          = (1 << 2),
 | 
			
		||||
} SpaPortFormatFlags;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
  SPA_PORT_STATE_FLAG_NONE                  = 0,
 | 
			
		||||
  SPA_PORT_STATE_FLAG_HAVE_FORMAT           = 1 << 0,
 | 
			
		||||
  SPA_PORT_STATE_FLAG_HAVE_BUFFERS          = 1 << 1,
 | 
			
		||||
} SpaPortStateFlags;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SpaPortInputFlags:
 | 
			
		||||
 * @SPA_INPUT_FLAG_NONE: no flag
 | 
			
		||||
 */
 | 
			
		||||
typedef enum {
 | 
			
		||||
  SPA_PORT_INPUT_FLAG_NONE                  = 0,
 | 
			
		||||
} SpaPortInputFlags;
 | 
			
		||||
#define SPA_PORT_STATE_FLAG_NONE                  0
 | 
			
		||||
#define SPA_PORT_STATE_FLAG_HAVE_FORMAT           (1 << 0)
 | 
			
		||||
#define SPA_PORT_STATE_FLAG_HAVE_BUFFERS          (1 << 1)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SpaPortInput:
 | 
			
		||||
| 
						 | 
				
			
			@ -96,39 +86,34 @@ typedef enum {
 | 
			
		|||
 * Input information for a node.
 | 
			
		||||
 */
 | 
			
		||||
typedef struct {
 | 
			
		||||
  SpaPortStateFlags state;
 | 
			
		||||
  SpaPortInputFlags flags;
 | 
			
		||||
  uint32_t          state;
 | 
			
		||||
#define SPA_PORT_INPUT_FLAG_NONE        0
 | 
			
		||||
  uint32_t          flags;
 | 
			
		||||
  uint32_t          buffer_id;
 | 
			
		||||
  SpaResult         status;
 | 
			
		||||
  uint32_t          status;
 | 
			
		||||
} SpaPortInput;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SpaPortOutputFlags:
 | 
			
		||||
 * @SPA_PORT_OUTPUT_FLAG_NONE: no flag
 | 
			
		||||
 */
 | 
			
		||||
typedef enum {
 | 
			
		||||
  SPA_PORT_OUTPUT_FLAG_NONE                  =  0,
 | 
			
		||||
} SpaPortOutputFlags;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SpaPortOutput:
 | 
			
		||||
 * @state: the port state
 | 
			
		||||
 * @flags: extra flags
 | 
			
		||||
 * @buffer_id: a buffer id will be set
 | 
			
		||||
 * @event: output event
 | 
			
		||||
 * @status: the status
 | 
			
		||||
 * @latency: current port latency
 | 
			
		||||
 * @event: output event
 | 
			
		||||
 *
 | 
			
		||||
 * Output information for a port on a node. This is allocated
 | 
			
		||||
 * by the host and configured on all output ports for which output is
 | 
			
		||||
 * requested.
 | 
			
		||||
 */
 | 
			
		||||
typedef struct {
 | 
			
		||||
  SpaPortStateFlags  state;
 | 
			
		||||
  uint64_t           latency;
 | 
			
		||||
  SpaPortOutputFlags flags;
 | 
			
		||||
  uint32_t           state;
 | 
			
		||||
#define SPA_PORT_OUTPUT_FLAG_NONE        0
 | 
			
		||||
  uint32_t           flags;
 | 
			
		||||
  uint32_t           buffer_id;
 | 
			
		||||
  uint32_t           status;
 | 
			
		||||
  uint64_t           latency;
 | 
			
		||||
  SpaNodeEvent      *event;
 | 
			
		||||
  SpaResult          status;
 | 
			
		||||
} SpaPortOutput;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -472,7 +457,7 @@ struct _SpaNode {
 | 
			
		|||
   *
 | 
			
		||||
   * Tell the port to allocate memory for @buffers.
 | 
			
		||||
   *
 | 
			
		||||
   * @params should contain an array of pointers to buffers. The data
 | 
			
		||||
   * @buffers should contain an array of pointers to buffers. The data
 | 
			
		||||
   * in the buffers should point to an array of at least 1 SPA_DATA_TYPE_INVALID
 | 
			
		||||
   * data pointers that will be filled by this function.
 | 
			
		||||
   *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -351,6 +351,13 @@ spa_pod_builder_addv (SpaPODBuilder *builder,
 | 
			
		|||
        spa_pod_builder_string_len (builder, str, len);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      case SPA_POD_TYPE_BYTES:
 | 
			
		||||
      {
 | 
			
		||||
        void *value = va_arg (args, void *);
 | 
			
		||||
        uint32_t size = va_arg (args, uint32_t);
 | 
			
		||||
        spa_pod_builder_bytes (builder, value, size);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      case SPA_POD_TYPE_RECTANGLE:
 | 
			
		||||
      {
 | 
			
		||||
        uint32_t width = va_arg (args, uint32_t), height = va_arg (args, uint32_t);
 | 
			
		||||
| 
						 | 
				
			
			@ -418,13 +425,6 @@ spa_pod_builder_addv (SpaPODBuilder *builder,
 | 
			
		|||
        spa_pod_builder_pop (builder, f);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      case SPA_POD_TYPE_BYTES:
 | 
			
		||||
      {
 | 
			
		||||
        void *value = va_arg (args, void *);
 | 
			
		||||
        uint32_t size = va_arg (args, uint32_t);
 | 
			
		||||
        spa_pod_builder_bytes (builder, value, size);
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      case SPA_POD_TYPE_POD:
 | 
			
		||||
      {
 | 
			
		||||
        const SpaPOD *value = va_arg (args, SpaPOD *);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -116,6 +116,10 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
 | 
			
		|||
        strncpy (dest, SPA_POD_CONTENTS (SpaPODString, pod), maxlen-1);                 \
 | 
			
		||||
        break;                                                                          \
 | 
			
		||||
      }                                                                                 \
 | 
			
		||||
      case SPA_POD_TYPE_BYTES:                                                          \
 | 
			
		||||
        *(va_arg (args, void **)) = SPA_POD_CONTENTS (SpaPODBytes, pod);                \
 | 
			
		||||
        *(va_arg (args, uint32_t *)) = SPA_POD_BODY_SIZE (pod);                         \
 | 
			
		||||
        break;                                                                          \
 | 
			
		||||
      case SPA_POD_TYPE_RECTANGLE:                                                      \
 | 
			
		||||
        *(va_arg (args, SpaRectangle *)) = SPA_POD_VALUE (SpaPODRectangle, pod);        \
 | 
			
		||||
        break;                                                                          \
 | 
			
		||||
| 
						 | 
				
			
			@ -132,10 +136,6 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
 | 
			
		|||
      case SPA_POD_TYPE_POD:                                                            \
 | 
			
		||||
        *(va_arg (args, SpaPOD **)) = pod;                                              \
 | 
			
		||||
        break;                                                                          \
 | 
			
		||||
      case SPA_POD_TYPE_BYTES:                                                          \
 | 
			
		||||
        *(va_arg (args, void **)) = SPA_POD_CONTENTS (SpaPODBytes, pod);                \
 | 
			
		||||
        *(va_arg (args, uint32_t *)) = SPA_POD_BODY_SIZE (pod);                         \
 | 
			
		||||
        break;                                                                          \
 | 
			
		||||
      default:                                                                          \
 | 
			
		||||
        break;                                                                          \
 | 
			
		||||
    }                                                                                   \
 | 
			
		||||
| 
						 | 
				
			
			@ -144,6 +144,7 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
 | 
			
		|||
    switch (type) {                                                                     \
 | 
			
		||||
      case SPA_POD_TYPE_BYTES:                                                          \
 | 
			
		||||
        va_arg (args, void*);                                                           \
 | 
			
		||||
        /* fallthrough */                                                               \
 | 
			
		||||
      case SPA_POD_TYPE_BOOL:                                                           \
 | 
			
		||||
      case SPA_POD_TYPE_URI:                                                            \
 | 
			
		||||
      case SPA_POD_TYPE_INT:                                                            \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,6 +43,7 @@ typedef enum {
 | 
			
		|||
  SPA_POD_TYPE_FLOAT,
 | 
			
		||||
  SPA_POD_TYPE_DOUBLE,
 | 
			
		||||
  SPA_POD_TYPE_STRING,
 | 
			
		||||
  SPA_POD_TYPE_BYTES,
 | 
			
		||||
  SPA_POD_TYPE_RECTANGLE,
 | 
			
		||||
  SPA_POD_TYPE_FRACTION,
 | 
			
		||||
  SPA_POD_TYPE_BITMASK,
 | 
			
		||||
| 
						 | 
				
			
			@ -50,8 +51,7 @@ typedef enum {
 | 
			
		|||
  SPA_POD_TYPE_STRUCT,
 | 
			
		||||
  SPA_POD_TYPE_OBJECT,
 | 
			
		||||
  SPA_POD_TYPE_PROP,
 | 
			
		||||
  SPA_POD_TYPE_BYTES,
 | 
			
		||||
  SPA_POD_TYPE_POD
 | 
			
		||||
  SPA_POD_TYPE_POD,
 | 
			
		||||
} SpaPODType;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue