mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pod: handle NULL
This commit is contained in:
		
							parent
							
								
									e28b5f91b8
								
							
						
					
					
						commit
						3dba9f0fd4
					
				
					 10 changed files with 121 additions and 111 deletions
				
			
		| 
						 | 
					@ -277,6 +277,8 @@ again:
 | 
				
			||||||
  *dt = buf->data;
 | 
					  *dt = buf->data;
 | 
				
			||||||
  *sz = buf->size;
 | 
					  *sz = buf->size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  spa_debug_pod (data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -308,7 +310,7 @@ pinos_connection_end_write (PinosConnection  *conn,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  buf->buffer_size += 8 + size;
 | 
					  buf->buffer_size += 8 + size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//  spa_debug_pod (p);
 | 
					  spa_debug_pod (p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_signal_emit (&conn->need_flush, conn);
 | 
					  pinos_signal_emit (&conn->need_flush, conn);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -461,17 +461,11 @@ client_node_marshal_update (void           *object,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  core_update_map (proxy->context);
 | 
					  core_update_map (proxy->context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_pod_builder_add (&b.b,
 | 
					  spa_pod_builder_struct (&b.b, &f,
 | 
				
			||||||
      SPA_POD_TYPE_STRUCT, &f,
 | 
					 | 
				
			||||||
        SPA_POD_TYPE_INT, change_mask,
 | 
					        SPA_POD_TYPE_INT, change_mask,
 | 
				
			||||||
        SPA_POD_TYPE_INT, max_input_ports,
 | 
					        SPA_POD_TYPE_INT, max_input_ports,
 | 
				
			||||||
        SPA_POD_TYPE_INT, max_output_ports,
 | 
					        SPA_POD_TYPE_INT, max_output_ports,
 | 
				
			||||||
        SPA_POD_TYPE_INT, props ? 1 : 0,
 | 
					        SPA_POD_TYPE_POD, props);
 | 
				
			||||||
      0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (props)
 | 
					 | 
				
			||||||
    spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, props, 0);
 | 
					 | 
				
			||||||
  spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f, 0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_connection_end_write (connection, proxy->id, 0, b.b.offset);
 | 
					  pinos_connection_end_write (connection, proxy->id, 0, b.b.offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -506,12 +500,11 @@ client_node_marshal_port_update (void              *object,
 | 
				
			||||||
  for (i = 0; i < n_possible_formats; i++)
 | 
					  for (i = 0; i < n_possible_formats; i++)
 | 
				
			||||||
    spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, possible_formats[i], 0);
 | 
					    spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, possible_formats[i], 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, format ? 1 : 0, 0);
 | 
					  spa_pod_builder_add (&b.b,
 | 
				
			||||||
  if (format)
 | 
					      SPA_POD_TYPE_POD, format,
 | 
				
			||||||
    spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, format, 0);
 | 
					      SPA_POD_TYPE_POD, props,
 | 
				
			||||||
  spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, props ? 1 : 0, 0);
 | 
					      0);
 | 
				
			||||||
  if (props)
 | 
					
 | 
				
			||||||
    spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, props, 0);
 | 
					 | 
				
			||||||
  spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, info ? 1 : 0, 0);
 | 
					  spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, info ? 1 : 0, 0);
 | 
				
			||||||
  if (info) {
 | 
					  if (info) {
 | 
				
			||||||
    spa_pod_builder_add (&b.b,
 | 
					    spa_pod_builder_add (&b.b,
 | 
				
			||||||
| 
						 | 
					@ -678,7 +671,7 @@ client_node_demarshal_set_format (void   *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosProxy *proxy = object;
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
  SpaPODIter it;
 | 
					  SpaPODIter it;
 | 
				
			||||||
  uint32_t seq, direction, port_id, flags, have_format;
 | 
					  uint32_t seq, direction, port_id, flags;
 | 
				
			||||||
  const SpaFormat *format = NULL;
 | 
					  const SpaFormat *format = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!spa_pod_iter_struct (&it, data, size) ||
 | 
					  if (!spa_pod_iter_struct (&it, data, size) ||
 | 
				
			||||||
| 
						 | 
					@ -687,13 +680,10 @@ client_node_demarshal_set_format (void   *object,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &direction,
 | 
					        SPA_POD_TYPE_INT, &direction,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &port_id,
 | 
					        SPA_POD_TYPE_INT, &port_id,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &flags,
 | 
					        SPA_POD_TYPE_INT, &flags,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &have_format,
 | 
					        SPA_POD_TYPE_OBJECT, &format,
 | 
				
			||||||
        0))
 | 
					        0))
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (have_format && !spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &format, 0))
 | 
					 | 
				
			||||||
    return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ((PinosClientNodeEvents*)proxy->implementation)->set_format (proxy, seq, direction, port_id,
 | 
					  ((PinosClientNodeEvents*)proxy->implementation)->set_format (proxy, seq, direction, port_id,
 | 
				
			||||||
                                       flags, format);
 | 
					                                       flags, format);
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -153,14 +153,15 @@ connection_data (SpaSource *source,
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (opcode >= resource->iface->n_methods) {
 | 
					      if (opcode >= resource->iface->n_methods) {
 | 
				
			||||||
        pinos_log_error ("protocol-native %p: invalid method %u", client->impl, opcode);
 | 
					        pinos_log_error ("protocol-native %p: invalid method %u", client->impl, opcode);
 | 
				
			||||||
        continue;
 | 
					        client_destroy (client);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      demarshal = resource->iface->methods;
 | 
					      demarshal = resource->iface->methods;
 | 
				
			||||||
      if (demarshal[opcode]) {
 | 
					      if (!demarshal[opcode] || !demarshal[opcode] (resource, message, size)) {
 | 
				
			||||||
        if (!demarshal[opcode] (resource, message, size))
 | 
					        pinos_log_error ("protocol-native %p: invalid message received", client->impl);
 | 
				
			||||||
          pinos_log_error ("protocol-native %p: invalid message received", client->impl);
 | 
					        client_destroy (client);
 | 
				
			||||||
      } else
 | 
					        break;
 | 
				
			||||||
        pinos_log_error ("protocol-native %p: function %d not implemented", client->impl, opcode);
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -619,16 +619,12 @@ client_node_marshal_set_format (void              *object,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  core_update_map (resource->client);
 | 
					  core_update_map (resource->client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  spa_pod_builder_add (&b.b,
 | 
					  spa_pod_builder_struct (&b.b, &f,
 | 
				
			||||||
      SPA_POD_TYPE_STRUCT, &f,
 | 
					      SPA_POD_TYPE_INT, seq,
 | 
				
			||||||
        SPA_POD_TYPE_INT, seq,
 | 
					      SPA_POD_TYPE_INT, direction,
 | 
				
			||||||
        SPA_POD_TYPE_INT, direction,
 | 
					      SPA_POD_TYPE_INT, port_id,
 | 
				
			||||||
        SPA_POD_TYPE_INT, port_id,
 | 
					      SPA_POD_TYPE_INT, flags,
 | 
				
			||||||
        SPA_POD_TYPE_INT, flags,
 | 
					      SPA_POD_TYPE_POD, format);
 | 
				
			||||||
        SPA_POD_TYPE_INT, format ? 1 : 0, 0);
 | 
					 | 
				
			||||||
  if (format)
 | 
					 | 
				
			||||||
    spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, format, 0);
 | 
					 | 
				
			||||||
  spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f, 0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_connection_end_write (connection, resource->id, 4, b.b.offset);
 | 
					  pinos_connection_end_write (connection, resource->id, 4, b.b.offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -807,21 +803,18 @@ client_node_demarshal_update (void  *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  SpaPODIter it;
 | 
					  SpaPODIter it;
 | 
				
			||||||
  uint32_t change_mask, max_input_ports, max_output_ports, have_props;
 | 
					  uint32_t change_mask, max_input_ports, max_output_ports;
 | 
				
			||||||
  const SpaProps *props = NULL;
 | 
					  const SpaProps *props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!spa_pod_iter_struct (&it, data, size) ||
 | 
					  if (!spa_pod_iter_struct (&it, data, size) ||
 | 
				
			||||||
      !spa_pod_iter_get (&it,
 | 
					      !spa_pod_iter_get (&it,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &change_mask,
 | 
					        SPA_POD_TYPE_INT, &change_mask,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &max_input_ports,
 | 
					        SPA_POD_TYPE_INT, &max_input_ports,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &max_output_ports,
 | 
					        SPA_POD_TYPE_INT, &max_output_ports,
 | 
				
			||||||
        SPA_POD_TYPE_INT, &have_props,
 | 
					        SPA_POD_TYPE_OBJECT, &props,
 | 
				
			||||||
        0))
 | 
					        0))
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (have_props && !spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &props, 0))
 | 
					 | 
				
			||||||
    return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ((PinosClientNodeMethods*)resource->implementation)->update (resource, change_mask, max_input_ports, max_output_ports, props);
 | 
					  ((PinosClientNodeMethods*)resource->implementation)->update (resource, change_mask, max_input_ports, max_output_ports, props);
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -852,12 +845,10 @@ client_node_demarshal_port_update (void  *object,
 | 
				
			||||||
    if (!spa_pod_iter_get (&it,SPA_POD_TYPE_OBJECT, &possible_formats[i], 0))
 | 
					    if (!spa_pod_iter_get (&it,SPA_POD_TYPE_OBJECT, &possible_formats[i], 0))
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &t, 0) ||
 | 
					  if (!spa_pod_iter_get (&it,
 | 
				
			||||||
      (t && !spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &format, 0)))
 | 
					        SPA_POD_TYPE_OBJECT, &format,
 | 
				
			||||||
    return false;
 | 
					        SPA_POD_TYPE_OBJECT, &props,
 | 
				
			||||||
 | 
					        0))
 | 
				
			||||||
  if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &t, 0) ||
 | 
					 | 
				
			||||||
      (t && !spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &props, 0)))
 | 
					 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &t, 0))
 | 
					  if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &t, 0))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,6 +104,7 @@ typedef void (*SpaNotify) (void *data);
 | 
				
			||||||
#define SPA_N_ELEMENTS(arr)  (sizeof (arr) / sizeof ((arr)[0]))
 | 
					#define SPA_N_ELEMENTS(arr)  (sizeof (arr) / sizeof ((arr)[0]))
 | 
				
			||||||
#define SPA_MIN(a,b)  ((a)<(b) ? (a) : (b))
 | 
					#define SPA_MIN(a,b)  ((a)<(b) ? (a) : (b))
 | 
				
			||||||
#define SPA_MAX(a,b)  ((a)>(b) ? (a) : (b))
 | 
					#define SPA_MAX(a,b)  ((a)>(b) ? (a) : (b))
 | 
				
			||||||
 | 
					#define SPA_ABS(a)    ((a)>0 ? (a) : -(a))
 | 
				
			||||||
#define SPA_CLAMP(v,a,b)  ((v)>(b) ? (b) : ((v) < (a) ? (a) : (v)))
 | 
					#define SPA_CLAMP(v,a,b)  ((v)>(b) ? (b) : ((v) < (a) ? (a) : (v)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SPA_MEMBER(b,o,t) ((t*)((uint8_t*)(b) + (o)))
 | 
					#define SPA_MEMBER(b,o,t) ((t*)((uint8_t*)(b) + (o)))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -495,7 +495,11 @@ spa_pod_builder_addv (SpaPODBuilder *builder,
 | 
				
			||||||
        spa_pod_builder_pop (builder, f);
 | 
					        spa_pod_builder_pop (builder, f);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case SPA_POD_TYPE_POD:
 | 
					      case SPA_POD_TYPE_POD:
 | 
				
			||||||
        body = va_arg (args, void *);
 | 
					        if ((body = va_arg (args, void *)) == NULL) {
 | 
				
			||||||
 | 
					          head.pod.type = SPA_POD_TYPE_NONE;
 | 
				
			||||||
 | 
					          head.pod.size = 0;
 | 
				
			||||||
 | 
					          body = &head;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        body_size = SPA_POD_SIZE (body);
 | 
					        body_size = SPA_POD_SIZE (body);
 | 
				
			||||||
        goto extra;
 | 
					        goto extra;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -121,14 +121,13 @@ spa_pod_iter_getv (SpaPODIter *iter,
 | 
				
			||||||
  while (type && (res = spa_pod_iter_has_next (iter))) {
 | 
					  while (type && (res = spa_pod_iter_has_next (iter))) {
 | 
				
			||||||
    SpaPOD *pod = spa_pod_iter_next (iter);
 | 
					    SpaPOD *pod = spa_pod_iter_next (iter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (type != SPA_POD_TYPE_POD && pod->type != type)
 | 
					    SPA_POD_COLLECT (pod, type, args, error);
 | 
				
			||||||
      return false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SPA_POD_COLLECT (pod, type, args);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    type = va_arg (args, uint32_t);
 | 
					    type = va_arg (args, uint32_t);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return res;
 | 
					  return res;
 | 
				
			||||||
 | 
					error:
 | 
				
			||||||
 | 
					  return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline bool
 | 
					static inline bool
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
#include <spa/pod.h>
 | 
					#include <spa/pod.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,61 +91,78 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
 | 
				
			||||||
  return spa_pod_contents_find_prop (&obj->pod, sizeof (SpaPODObject), key);
 | 
					  return spa_pod_contents_find_prop (&obj->pod, sizeof (SpaPODObject), key);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SPA_POD_COLLECT(pod,type,args)                                                  \
 | 
					#define SPA_POD_COLLECT(pod,type,args,error)                                            \
 | 
				
			||||||
    switch (type) {                                                                     \
 | 
					  do {                                                                                  \
 | 
				
			||||||
      case SPA_POD_TYPE_BOOL:                                                           \
 | 
					    if (type == SPA_POD_TYPE_POD) {                                                     \
 | 
				
			||||||
      case SPA_POD_TYPE_URI:                                                            \
 | 
					      *(va_arg (args, SpaPOD **)) = pod;                                                \
 | 
				
			||||||
      case SPA_POD_TYPE_INT:                                                            \
 | 
					    } else if ((pod)->type == SPA_POD_TYPE_NONE) {                                      \
 | 
				
			||||||
        *(va_arg (args, int32_t*)) = SPA_POD_VALUE(SpaPODInt, pod);                     \
 | 
					      switch (type) {                                                                   \
 | 
				
			||||||
        break;                                                                          \
 | 
					        case SPA_POD_TYPE_ARRAY:                                                        \
 | 
				
			||||||
      case SPA_POD_TYPE_LONG:                                                           \
 | 
					        case SPA_POD_TYPE_STRUCT:                                                       \
 | 
				
			||||||
        *(va_arg (args, int64_t*)) = SPA_POD_VALUE (SpaPODLong, pod);                   \
 | 
					        case SPA_POD_TYPE_OBJECT:                                                       \
 | 
				
			||||||
        break;                                                                          \
 | 
					        case SPA_POD_TYPE_PROP:                                                         \
 | 
				
			||||||
      case SPA_POD_TYPE_FLOAT:                                                          \
 | 
					          *(va_arg (args, SpaPOD **)) = NULL;                                           \
 | 
				
			||||||
        *(va_arg (args, float*)) = SPA_POD_VALUE (SpaPODFloat, pod);                    \
 | 
					          break;                                                                        \
 | 
				
			||||||
        break;                                                                          \
 | 
					        default:                                                                        \
 | 
				
			||||||
      case SPA_POD_TYPE_DOUBLE:                                                         \
 | 
					          goto error;                                                                   \
 | 
				
			||||||
        *(va_arg (args, double*)) = SPA_POD_VALUE (SpaPODDouble, pod);                  \
 | 
					 | 
				
			||||||
        break;                                                                          \
 | 
					 | 
				
			||||||
      case SPA_POD_TYPE_STRING:                                                         \
 | 
					 | 
				
			||||||
        *(va_arg (args, char **)) = SPA_POD_CONTENTS (SpaPODString, pod);               \
 | 
					 | 
				
			||||||
        break;                                                                          \
 | 
					 | 
				
			||||||
      case -SPA_POD_TYPE_STRING:                                                        \
 | 
					 | 
				
			||||||
      {                                                                                 \
 | 
					 | 
				
			||||||
        char *dest = va_arg (args, char *);                                             \
 | 
					 | 
				
			||||||
        uint32_t maxlen = va_arg (args, uint32_t);                                      \
 | 
					 | 
				
			||||||
        strncpy (dest, SPA_POD_CONTENTS (SpaPODString, pod), maxlen-1);                 \
 | 
					 | 
				
			||||||
        break;                                                                          \
 | 
					 | 
				
			||||||
      }                                                                                 \
 | 
					      }                                                                                 \
 | 
				
			||||||
      case SPA_POD_TYPE_BYTES:                                                          \
 | 
					    } else if ((pod)->type == type) {                                                   \
 | 
				
			||||||
        *(va_arg (args, void **)) = SPA_POD_CONTENTS (SpaPODBytes, pod);                \
 | 
					      switch (type) {                                                                   \
 | 
				
			||||||
        *(va_arg (args, uint32_t *)) = SPA_POD_BODY_SIZE (pod);                         \
 | 
					        case SPA_POD_TYPE_BOOL:                                                         \
 | 
				
			||||||
        break;                                                                          \
 | 
					        case SPA_POD_TYPE_URI:                                                          \
 | 
				
			||||||
      case SPA_POD_TYPE_POINTER:                                                        \
 | 
					        case SPA_POD_TYPE_INT:                                                          \
 | 
				
			||||||
      {                                                                                 \
 | 
					          *(va_arg (args, int32_t*)) = SPA_POD_VALUE(SpaPODInt, pod);                   \
 | 
				
			||||||
        SpaPODPointerBody *b = SPA_POD_BODY (pod);                                      \
 | 
					          break;                                                                        \
 | 
				
			||||||
        *(va_arg (args, void **)) = b->value;                                           \
 | 
					        case SPA_POD_TYPE_LONG:                                                         \
 | 
				
			||||||
        break;                                                                          \
 | 
					          *(va_arg (args, int64_t*)) = SPA_POD_VALUE (SpaPODLong, pod);                 \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_FLOAT:                                                        \
 | 
				
			||||||
 | 
					          *(va_arg (args, float*)) = SPA_POD_VALUE (SpaPODFloat, pod);                  \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_DOUBLE:                                                       \
 | 
				
			||||||
 | 
					          *(va_arg (args, double*)) = SPA_POD_VALUE (SpaPODDouble, pod);                \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_STRING:                                                       \
 | 
				
			||||||
 | 
					          *(va_arg (args, char **)) = SPA_POD_CONTENTS (SpaPODString, pod);             \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        case -SPA_POD_TYPE_STRING:                                                      \
 | 
				
			||||||
 | 
					        {                                                                               \
 | 
				
			||||||
 | 
					          char *dest = va_arg (args, char *);                                           \
 | 
				
			||||||
 | 
					          uint32_t maxlen = va_arg (args, uint32_t);                                    \
 | 
				
			||||||
 | 
					          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_POINTER:                                                      \
 | 
				
			||||||
 | 
					        {                                                                               \
 | 
				
			||||||
 | 
					          SpaPODPointerBody *b = SPA_POD_BODY (pod);                                    \
 | 
				
			||||||
 | 
					          *(va_arg (args, void **)) = b->value;                                         \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        }                                                                               \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_RECTANGLE:                                                    \
 | 
				
			||||||
 | 
					          *(va_arg (args, SpaRectangle *)) = SPA_POD_VALUE (SpaPODRectangle, pod);      \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_FRACTION:                                                     \
 | 
				
			||||||
 | 
					          *(va_arg (args, SpaFraction *)) = SPA_POD_VALUE (SpaPODFraction, pod);        \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_BITMASK:                                                      \
 | 
				
			||||||
 | 
					          *(va_arg (args, uint32_t **)) = SPA_POD_CONTENTS (SpaPOD, pod);               \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_ARRAY:                                                        \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_STRUCT:                                                       \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_OBJECT:                                                       \
 | 
				
			||||||
 | 
					        case SPA_POD_TYPE_PROP:                                                         \
 | 
				
			||||||
 | 
					          *(va_arg (args, SpaPOD **)) = pod;                                            \
 | 
				
			||||||
 | 
					          break;                                                                        \
 | 
				
			||||||
 | 
					        default:                                                                        \
 | 
				
			||||||
 | 
					          goto error;                                                                   \
 | 
				
			||||||
      }                                                                                 \
 | 
					      }                                                                                 \
 | 
				
			||||||
      case SPA_POD_TYPE_RECTANGLE:                                                      \
 | 
					    } else                                                                              \
 | 
				
			||||||
        *(va_arg (args, SpaRectangle *)) = SPA_POD_VALUE (SpaPODRectangle, pod);        \
 | 
					       goto error;                                                                      \
 | 
				
			||||||
        break;                                                                          \
 | 
					  } while (false);                                                                      \
 | 
				
			||||||
      case SPA_POD_TYPE_FRACTION:                                                       \
 | 
					 | 
				
			||||||
        *(va_arg (args, SpaFraction *)) = SPA_POD_VALUE (SpaPODFraction, pod);          \
 | 
					 | 
				
			||||||
        break;                                                                          \
 | 
					 | 
				
			||||||
      case SPA_POD_TYPE_BITMASK:                                                        \
 | 
					 | 
				
			||||||
        *(va_arg (args, uint32_t **)) = SPA_POD_CONTENTS (SpaPOD, pod);                 \
 | 
					 | 
				
			||||||
        break;                                                                          \
 | 
					 | 
				
			||||||
      case SPA_POD_TYPE_ARRAY:                                                          \
 | 
					 | 
				
			||||||
      case SPA_POD_TYPE_STRUCT:                                                         \
 | 
					 | 
				
			||||||
      case SPA_POD_TYPE_OBJECT:                                                         \
 | 
					 | 
				
			||||||
      case SPA_POD_TYPE_PROP:                                                           \
 | 
					 | 
				
			||||||
      case SPA_POD_TYPE_POD:                                                            \
 | 
					 | 
				
			||||||
        *(va_arg (args, SpaPOD **)) = pod;                                              \
 | 
					 | 
				
			||||||
        break;                                                                          \
 | 
					 | 
				
			||||||
      default:                                                                          \
 | 
					 | 
				
			||||||
        break;                                                                          \
 | 
					 | 
				
			||||||
    }                                                                                   \
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SPA_POD_COLLECT_SKIP(type,args)                                                 \
 | 
					#define SPA_POD_COLLECT_SKIP(type,args)                                                 \
 | 
				
			||||||
    switch (type) {                                                                     \
 | 
					    switch (type) {                                                                     \
 | 
				
			||||||
| 
						 | 
					@ -184,13 +202,13 @@ spa_pod_contents_queryv (const SpaPOD *pod, uint32_t offset, uint32_t key, va_li
 | 
				
			||||||
    type = va_arg (args, uint32_t);
 | 
					    type = va_arg (args, uint32_t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (prop && prop->body.key == key &&
 | 
					    if (prop && prop->body.key == key &&
 | 
				
			||||||
        (type == SPA_POD_TYPE_POD || prop->body.value.type == type) &&
 | 
					 | 
				
			||||||
        !(prop->body.flags & SPA_POD_PROP_FLAG_UNSET)) {
 | 
					        !(prop->body.flags & SPA_POD_PROP_FLAG_UNSET)) {
 | 
				
			||||||
      SPA_POD_COLLECT (&prop->body.value, type, args);
 | 
					      SPA_POD_COLLECT (&prop->body.value, type, args, next);
 | 
				
			||||||
      count++;
 | 
					      count++;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      SPA_POD_COLLECT_SKIP (type, args);
 | 
					      SPA_POD_COLLECT_SKIP (type, args);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					next:
 | 
				
			||||||
    key = va_arg (args, uint32_t);
 | 
					    key = va_arg (args, uint32_t);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return count;
 | 
					  return count;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,7 +187,7 @@ struct pod_type_name {
 | 
				
			||||||
  const char *CCName;
 | 
					  const char *CCName;
 | 
				
			||||||
} pod_type_names[] = {
 | 
					} pod_type_names[] = {
 | 
				
			||||||
  { "invalid", "*Invalid*" },
 | 
					  { "invalid", "*Invalid*" },
 | 
				
			||||||
  { "ignored", "ignored" },
 | 
					  { "none", "None" },
 | 
				
			||||||
  { "bool", "Bool" },
 | 
					  { "bool", "Bool" },
 | 
				
			||||||
  { "uri", "URI" },
 | 
					  { "uri", "URI" },
 | 
				
			||||||
  { "int", "Int" },
 | 
					  { "int", "Int" },
 | 
				
			||||||
| 
						 | 
					@ -310,6 +310,10 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
 | 
				
			||||||
      printf ("%-*sBytes\n", prefix, "");
 | 
					      printf ("%-*sBytes\n", prefix, "");
 | 
				
			||||||
      spa_debug_dump_mem (body, size);
 | 
					      spa_debug_dump_mem (body, size);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    case SPA_POD_TYPE_NONE:
 | 
				
			||||||
 | 
					      printf ("%-*sNone\n", prefix, "");
 | 
				
			||||||
 | 
					      spa_debug_dump_mem (body, size);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      printf ("unhandled POD type %d\n", type);
 | 
					      printf ("unhandled POD type %d\n", type);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,8 +69,8 @@ init_uri (URI *uri, SpaIDMap *map)
 | 
				
			||||||
  uri->prop_wave = spa_id_map_get_id (map, SPA_PROPS__waveType);
 | 
					  uri->prop_wave = spa_id_map_get_id (map, SPA_PROPS__waveType);
 | 
				
			||||||
  uri->prop_freq = spa_id_map_get_id (map, SPA_PROPS__frequency);
 | 
					  uri->prop_freq = spa_id_map_get_id (map, SPA_PROPS__frequency);
 | 
				
			||||||
  uri->prop_volume = spa_id_map_get_id (map, SPA_PROPS__volume);
 | 
					  uri->prop_volume = spa_id_map_get_id (map, SPA_PROPS__volume);
 | 
				
			||||||
  uri->wave_sine = spa_id_map_get_id (map, SPA_PROPS__waveType ":Sine");
 | 
					  uri->wave_sine = spa_id_map_get_id (map, SPA_PROPS__waveType ":sine");
 | 
				
			||||||
  uri->wave_square = spa_id_map_get_id (map, SPA_PROPS__waveType ":Square");
 | 
					  uri->wave_square = spa_id_map_get_id (map, SPA_PROPS__waveType ":square");
 | 
				
			||||||
  spa_media_types_fill (&uri->media_types, map);
 | 
					  spa_media_types_fill (&uri->media_types, map);
 | 
				
			||||||
  spa_media_subtypes_map (map, &uri->media_subtypes);
 | 
					  spa_media_subtypes_map (map, &uri->media_subtypes);
 | 
				
			||||||
  spa_prop_audio_map (map, &uri->prop_audio);
 | 
					  spa_prop_audio_map (map, &uri->prop_audio);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue