mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Use int counters for iterating items
Use counters instead of void* to iterate items. This simplifies some things and makes it easier to do over the wire. Add format description to NodeInfo and use this to add format descriptions to pinos devices. Small fixes to fix leaks and crashes.
This commit is contained in:
parent
8b84d8fde6
commit
b38ecafe81
38 changed files with 363 additions and 330 deletions
|
|
@ -81,8 +81,8 @@ connection_add_fd (PinosConnection *conn,
|
|||
return index;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#define PINOS_DEBUG_MESSAGE(format,args...) pinos_log_debug(stderr, format,##args)
|
||||
#if 1
|
||||
#define PINOS_DEBUG_MESSAGE(format,args...) pinos_log_debug(format,##args)
|
||||
#else
|
||||
#define PINOS_DEBUG_MESSAGE(format,args...)
|
||||
#endif
|
||||
|
|
@ -200,6 +200,7 @@ connection_parse_node_info (PinosConnection *conn, PinosMessageNodeInfo *m)
|
|||
{
|
||||
void *p;
|
||||
PinosNodeInfo *di;
|
||||
int i;
|
||||
|
||||
p = conn->in.data;
|
||||
memcpy (m, p, sizeof (PinosMessageNodeInfo));
|
||||
|
|
@ -207,12 +208,32 @@ connection_parse_node_info (PinosConnection *conn, PinosMessageNodeInfo *m)
|
|||
m->info = SPA_MEMBER (p, SPA_PTR_TO_INT (m->info), PinosNodeInfo);
|
||||
di = m->info;
|
||||
|
||||
if (m->info->name)
|
||||
m->info->name = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->name), const char);
|
||||
if (m->info->error)
|
||||
m->info->error = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->error), const char);
|
||||
if (m->info->props)
|
||||
m->info->props = pinos_serialize_dict_deserialize (di, SPA_PTR_TO_INT (m->info->props));
|
||||
if (di->name)
|
||||
di->name = SPA_MEMBER (di, SPA_PTR_TO_INT (di->name), const char);
|
||||
|
||||
if (di->input_formats)
|
||||
di->input_formats = SPA_MEMBER (di,
|
||||
SPA_PTR_TO_INT (di->input_formats), SpaFormat *);
|
||||
for (i = 0; i < di->n_input_formats; i++) {
|
||||
if (di->input_formats[i]) {
|
||||
di->input_formats[i] = pinos_serialize_format_deserialize (di,
|
||||
SPA_PTR_TO_INT (di->input_formats[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (di->output_formats)
|
||||
di->output_formats = SPA_MEMBER (di,
|
||||
SPA_PTR_TO_INT (di->output_formats), SpaFormat *);
|
||||
for (i = 0; i < di->n_output_formats; i++) {
|
||||
if (di->output_formats[i]) {
|
||||
di->output_formats[i] = pinos_serialize_format_deserialize (di,
|
||||
SPA_PTR_TO_INT (di->output_formats[i]));
|
||||
}
|
||||
}
|
||||
if (di->error)
|
||||
di->error = SPA_MEMBER (di, SPA_PTR_TO_INT (di->error), const char);
|
||||
if (di->props)
|
||||
di->props = pinos_serialize_dict_deserialize (di, SPA_PTR_TO_INT (di->props));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +380,7 @@ connection_add_message (PinosConnection *conn,
|
|||
buf->buffer_size += 8 + size;
|
||||
|
||||
*p++ = dest_id;
|
||||
*p++ = (type << 16) | (size & 0xffff);
|
||||
*p++ = (type << 24) | (size & 0xffffff);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
|
@ -624,12 +645,19 @@ connection_add_node_info (PinosConnection *conn, uint32_t dest_id, PinosMessageN
|
|||
size_t len, slen;
|
||||
void *p;
|
||||
PinosMessageNodeInfo *d;
|
||||
int i;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (PinosMessageNodeInfo);
|
||||
if (m->info) {
|
||||
len += sizeof (PinosNodeInfo);
|
||||
len += m->info->name ? strlen (m->info->name) + 1 : 0;
|
||||
len += m->info->n_input_formats * sizeof (SpaFormat *);
|
||||
for (i = 0; i < m->info->n_input_formats; i++)
|
||||
len += pinos_serialize_format_get_size (m->info->input_formats[i]);
|
||||
len += m->info->n_output_formats * sizeof (SpaFormat *);
|
||||
for (i = 0; i < m->info->n_output_formats; i++)
|
||||
len += pinos_serialize_format_get_size (m->info->output_formats[i]);
|
||||
len += m->info->error ? strlen (m->info->error) + 1 : 0;
|
||||
len += pinos_serialize_dict_get_size (m->info->props);
|
||||
}
|
||||
|
|
@ -641,18 +669,43 @@ connection_add_node_info (PinosConnection *conn, uint32_t dest_id, PinosMessageN
|
|||
p = SPA_MEMBER (d, sizeof (PinosMessageNodeInfo), void);
|
||||
if (m->info) {
|
||||
PinosNodeInfo *di;
|
||||
SpaFormat **ifa, **ofa;
|
||||
|
||||
memcpy (p, m->info, sizeof (PinosNodeInfo));
|
||||
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
di = p;
|
||||
|
||||
p = SPA_MEMBER (p, sizeof (PinosNodeInfo), void);
|
||||
ifa = p;
|
||||
if (m->info->n_input_formats)
|
||||
di->input_formats = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
else
|
||||
di->input_formats = 0;
|
||||
p = SPA_MEMBER (p, sizeof (SpaFormat*) * m->info->n_input_formats, void);
|
||||
|
||||
ofa = p;
|
||||
if (m->info->n_output_formats)
|
||||
di->output_formats = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
else
|
||||
di->output_formats = 0;
|
||||
p = SPA_MEMBER (p, sizeof (SpaFormat*) * m->info->n_output_formats, void);
|
||||
|
||||
if (m->info->name) {
|
||||
slen = strlen (m->info->name) + 1;
|
||||
memcpy (p, m->info->name, slen);
|
||||
di->name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
for (i = 0; i < m->info->n_input_formats; i++) {
|
||||
len = pinos_serialize_format_serialize (p, m->info->input_formats[i]);
|
||||
ifa[i] = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p = SPA_MEMBER (p, len, void);
|
||||
}
|
||||
for (i = 0; i < m->info->n_output_formats; i++) {
|
||||
len = pinos_serialize_format_serialize (p, m->info->output_formats[i]);
|
||||
ofa[i] = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p = SPA_MEMBER (p, len, void);
|
||||
}
|
||||
if (m->info->error) {
|
||||
slen = strlen (m->info->error) + 1;
|
||||
memcpy (p, m->info->error, slen);
|
||||
|
|
@ -662,6 +715,7 @@ connection_add_node_info (PinosConnection *conn, uint32_t dest_id, PinosMessageN
|
|||
if (m->info->props) {
|
||||
len = pinos_serialize_dict_serialize (p, m->info->props);
|
||||
di->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1084,8 +1138,8 @@ again:
|
|||
size -= 8;
|
||||
|
||||
buf->dest_id = p[0];
|
||||
buf->type = p[1] >> 16;
|
||||
len = p[1] & 0xffff;
|
||||
buf->type = p[1] >> 24;
|
||||
len = p[1] & 0xffffff;
|
||||
|
||||
if (len > size) {
|
||||
connection_ensure_size (conn, buf, len);
|
||||
|
|
@ -1522,11 +1576,11 @@ pinos_connection_flush (PinosConnection *conn)
|
|||
}
|
||||
break;
|
||||
}
|
||||
PINOS_DEBUG_MESSAGE ("connection %p: %d written %zd bytes and %u fds", conn, conn->fd, len, buf->n_fds);
|
||||
|
||||
buf->buffer_size -= len;
|
||||
buf->n_fds = 0;
|
||||
|
||||
PINOS_DEBUG_MESSAGE ("connection %p: %d written %zd bytes and %u fds", conn, conn->fd, len, buf->n_fds);
|
||||
|
||||
return true;
|
||||
|
||||
/* ERRORS */
|
||||
|
|
|
|||
|
|
@ -492,6 +492,8 @@ pinos_context_new (PinosLoop *loop,
|
|||
if (impl == NULL)
|
||||
return NULL;
|
||||
|
||||
impl->fd = -1;
|
||||
|
||||
this = &impl->this;
|
||||
pinos_log_debug ("context %p: new", impl);
|
||||
|
||||
|
|
@ -686,10 +688,21 @@ pinos_context_disconnect (PinosContext *context)
|
|||
|
||||
impl->disconnecting = true;
|
||||
|
||||
pinos_proxy_destroy (context->registry_proxy);
|
||||
pinos_proxy_destroy (context->core_proxy);
|
||||
pinos_connection_destroy (impl->connection);
|
||||
close (impl->fd);
|
||||
if (context->registry_proxy)
|
||||
pinos_proxy_destroy (context->registry_proxy);
|
||||
context->registry_proxy = NULL;
|
||||
|
||||
if (context->core_proxy)
|
||||
pinos_proxy_destroy (context->core_proxy);
|
||||
context->core_proxy = NULL;
|
||||
|
||||
if (impl->connection)
|
||||
pinos_connection_destroy (impl->connection);
|
||||
impl->connection = NULL;
|
||||
|
||||
if (impl->fd != -1)
|
||||
close (impl->fd);
|
||||
impl->fd = -1;
|
||||
|
||||
context_set_state (context, PINOS_CONTEXT_STATE_UNCONNECTED, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/serialize.h"
|
||||
|
||||
#include "pinos/client/context.h"
|
||||
#include "pinos/client/subscribe.h"
|
||||
|
|
@ -218,6 +219,8 @@ pinos_node_info_update (PinosNodeInfo *info,
|
|||
const PinosNodeInfo *update)
|
||||
{
|
||||
uint64_t change_mask;
|
||||
int i;
|
||||
size_t size;
|
||||
|
||||
if (update == NULL)
|
||||
return info;
|
||||
|
|
@ -240,13 +243,38 @@ pinos_node_info_update (PinosNodeInfo *info,
|
|||
}
|
||||
if (update->change_mask & (1 << 1))
|
||||
info->max_inputs = update->max_inputs;
|
||||
if (update->change_mask & (1 << 2))
|
||||
if (update->change_mask & (1 << 2)) {
|
||||
for (i = 0; i < info->n_input_formats; i++)
|
||||
free (info->input_formats[i]);
|
||||
info->n_input_formats = update->n_input_formats;
|
||||
|
||||
if (info->n_input_formats)
|
||||
info->input_formats = realloc (info->input_formats, info->n_input_formats * sizeof (SpaFormat *));
|
||||
else {
|
||||
free (info->input_formats);
|
||||
info->input_formats = NULL;
|
||||
}
|
||||
for (i = 0; i < info->n_input_formats; i++) {
|
||||
size = pinos_serialize_format_get_size (update->input_formats[i]);
|
||||
info->input_formats[i] = size ? pinos_serialize_format_copy_into (malloc (size), update->input_formats[i]) : NULL;
|
||||
}
|
||||
}
|
||||
if (update->change_mask & (1 << 3))
|
||||
info->max_outputs = update->max_outputs;
|
||||
if (update->change_mask & (1 << 4))
|
||||
if (update->change_mask & (1 << 4)) {
|
||||
for (i = 0; i < info->n_output_formats; i++)
|
||||
free (info->output_formats[i]);
|
||||
info->n_output_formats = update->n_output_formats;
|
||||
if (info->n_output_formats)
|
||||
info->output_formats = realloc (info->output_formats, info->n_output_formats * sizeof (SpaFormat *));
|
||||
else {
|
||||
free (info->output_formats);
|
||||
info->output_formats = NULL;
|
||||
}
|
||||
for (i = 0; i < info->n_output_formats; i++) {
|
||||
size = pinos_serialize_format_get_size (update->output_formats[i]);
|
||||
info->output_formats[i] = size ? pinos_serialize_format_copy_into (malloc (size), update->output_formats[i]) : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (update->change_mask & (1 << 5)) {
|
||||
info->state = update->state;
|
||||
|
|
@ -265,10 +293,22 @@ pinos_node_info_update (PinosNodeInfo *info,
|
|||
void
|
||||
pinos_node_info_free (PinosNodeInfo *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (info == NULL)
|
||||
return;
|
||||
if (info->name)
|
||||
free ((void*)info->name);
|
||||
if (info->input_formats) {
|
||||
for (i = 0; i < info->n_input_formats; i++)
|
||||
free (info->input_formats[i]);
|
||||
free (info->input_formats);
|
||||
}
|
||||
if (info->output_formats) {
|
||||
for (i = 0; i < info->n_output_formats; i++)
|
||||
free (info->output_formats[i]);
|
||||
free (info->output_formats);
|
||||
}
|
||||
if (info->error)
|
||||
free ((void*)info->error);
|
||||
if (info->props)
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ pinos_thread_main_loop_destroy (PinosThreadMainLoop *loop)
|
|||
|
||||
pinos_signal_emit (&loop->destroy_signal, loop);
|
||||
|
||||
pinos_thread_main_loop_stop (loop);
|
||||
|
||||
if (loop->name)
|
||||
free (loop->name);
|
||||
pthread_mutex_destroy (&impl->lock);
|
||||
|
|
@ -187,9 +189,11 @@ pinos_thread_main_loop_stop (PinosThreadMainLoop *loop)
|
|||
{
|
||||
PinosThreadMainLoopImpl *impl = SPA_CONTAINER_OF (loop, PinosThreadMainLoopImpl, this);
|
||||
|
||||
pinos_loop_signal_event (loop->loop, impl->event);
|
||||
|
||||
pthread_join (impl->thread, NULL);
|
||||
if (impl->running) {
|
||||
pinos_loop_signal_event (loop->loop, impl->event);
|
||||
pthread_join (impl->thread, NULL);
|
||||
impl->running = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstpinosformat.h"
|
||||
#include "gstpinosdeviceprovider.h"
|
||||
#include "gstpinossrc.h"
|
||||
#include "gstpinossink.h"
|
||||
|
|
@ -194,19 +195,29 @@ enum
|
|||
static GstDevice *
|
||||
new_node (const PinosNodeInfo *info)
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstCaps *caps = NULL;
|
||||
GstStructure *props;
|
||||
const gchar *klass = NULL;
|
||||
SpaDictItem *item;
|
||||
GstPinosDeviceType type;
|
||||
int i;
|
||||
|
||||
/* FIXME, iterate ports */
|
||||
#if 0
|
||||
if (info->possible_formats)
|
||||
caps = gst_caps_from_string (g_bytes_get_data (info->possible_formats, NULL));
|
||||
else
|
||||
caps = gst_caps_new_any();
|
||||
#endif
|
||||
caps = gst_caps_from_string ("video/x-raw,width=320,height=240,framerate=15/1");
|
||||
caps = gst_caps_new_empty();
|
||||
if (info->max_inputs > 0 && info->max_outputs == 0) {
|
||||
type = GST_PINOS_DEVICE_TYPE_SINK;
|
||||
|
||||
for (i = 0; i < info->n_input_formats; i++) {
|
||||
gst_caps_append (caps, gst_caps_from_format (info->input_formats[i]));
|
||||
}
|
||||
}
|
||||
else if (info->max_outputs > 0 && info->max_inputs == 0) {
|
||||
type = GST_PINOS_DEVICE_TYPE_SOURCE;
|
||||
for (i = 0; i < info->n_output_formats; i++) {
|
||||
gst_caps_append (caps, gst_caps_from_format (info->output_formats[i]));
|
||||
}
|
||||
} else {
|
||||
type = GST_PINOS_DEVICE_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
props = gst_structure_new_empty ("pinos-proplist");
|
||||
if (info->props) {
|
||||
|
|
@ -222,7 +233,7 @@ new_node (const PinosNodeInfo *info)
|
|||
info->name,
|
||||
caps,
|
||||
klass,
|
||||
GST_PINOS_DEVICE_TYPE_SOURCE,
|
||||
type,
|
||||
props);
|
||||
}
|
||||
|
||||
|
|
@ -500,7 +511,7 @@ failed_start:
|
|||
failed_main_loop:
|
||||
pinos_loop_destroy (self->loop);
|
||||
self->loop = NULL;
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ typedef struct _GstPinosDeviceClass GstPinosDeviceClass;
|
|||
#define GST_PINOS_DEVICE_CAST(obj) ((GstPinosDevice *)(obj))
|
||||
|
||||
typedef enum {
|
||||
GST_PINOS_DEVICE_TYPE_UNKNOWN,
|
||||
GST_PINOS_DEVICE_TYPE_SOURCE,
|
||||
GST_PINOS_DEVICE_TYPE_SINK,
|
||||
} GstPinosDeviceType;
|
||||
|
|
|
|||
|
|
@ -201,7 +201,8 @@ pinos_spa_monitor_load (PinosCore *core,
|
|||
SpaHandle *handle;
|
||||
SpaResult res;
|
||||
void *iface;
|
||||
void *hnd, *state = NULL;
|
||||
void *hnd;
|
||||
unsigned int index;
|
||||
SpaEnumHandleFactoryFunc enum_func;
|
||||
const SpaHandleFactory *factory;
|
||||
|
||||
|
|
@ -214,8 +215,8 @@ pinos_spa_monitor_load (PinosCore *core,
|
|||
goto no_symbol;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if ((res = enum_func (&factory, &state)) < 0) {
|
||||
for (index = 0;; index++) {
|
||||
if ((res = enum_func (&factory, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
pinos_log_error ("can't enumerate factories: %d", res);
|
||||
goto enum_failed;
|
||||
|
|
@ -256,12 +257,11 @@ pinos_spa_monitor_load (PinosCore *core,
|
|||
|
||||
spa_list_init (&impl->item_list);
|
||||
|
||||
state = NULL;
|
||||
while (true) {
|
||||
for (index = 0;; index++) {
|
||||
SpaMonitorItem *item;
|
||||
SpaResult res;
|
||||
|
||||
if ((res = spa_monitor_enum_items (this->monitor, &item, &state)) < 0) {
|
||||
if ((res = spa_monitor_enum_items (this->monitor, &item, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
pinos_log_debug ("spa_monitor_enum_items: got error %d\n", res);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ pinos_spa_node_load (PinosCore *core,
|
|||
SpaClock *spa_clock;
|
||||
SpaResult res;
|
||||
SpaHandle *handle;
|
||||
void *hnd, *state = NULL;
|
||||
void *hnd;
|
||||
unsigned int index;
|
||||
SpaEnumHandleFactoryFunc enum_func;
|
||||
const SpaHandleFactory *factory;
|
||||
void *iface;
|
||||
|
|
@ -60,8 +61,8 @@ pinos_spa_node_load (PinosCore *core,
|
|||
goto no_symbol;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if ((res = enum_func (&factory, &state)) < 0) {
|
||||
for (index = 0; ; index++) {
|
||||
if ((res = enum_func (&factory, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
pinos_log_error ("can't enumerate factories: %d", res);
|
||||
goto enum_failed;
|
||||
|
|
|
|||
|
|
@ -472,13 +472,12 @@ spa_proxy_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaProxyPort *port;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaProxy, node);
|
||||
|
|
@ -488,13 +487,10 @@ spa_proxy_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index >= port->n_formats)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*format = port->formats[index];
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
|
|||
PinosLinkImpl *impl = SPA_CONTAINER_OF (this, PinosLinkImpl, this);
|
||||
SpaResult res;
|
||||
SpaFormat *filter = NULL, *format;
|
||||
void *istate = NULL, *ostate = NULL;
|
||||
unsigned int iidx = 0, oidx = 0;
|
||||
char *error = NULL;
|
||||
|
||||
if (in_state != SPA_NODE_STATE_CONFIGURE && out_state != SPA_NODE_STATE_CONFIGURE)
|
||||
|
|
@ -95,8 +95,8 @@ again:
|
|||
this->input->port_id,
|
||||
&filter,
|
||||
NULL,
|
||||
&istate)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END && istate != NULL) {
|
||||
iidx)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END && iidx != 0) {
|
||||
asprintf (&error, "error input enum formats: %d", res);
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -110,9 +110,10 @@ again:
|
|||
this->output->port_id,
|
||||
&format,
|
||||
filter,
|
||||
&ostate)) < 0) {
|
||||
oidx)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END) {
|
||||
ostate = NULL;
|
||||
oidx = 0;
|
||||
iidx++;
|
||||
goto again;
|
||||
}
|
||||
asprintf (&error, "error output enum formats: %d", res);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/serialize.h"
|
||||
|
||||
#include "pinos/server/node.h"
|
||||
#include "pinos/server/data-loop.h"
|
||||
|
|
@ -423,8 +424,44 @@ node_bind_func (PinosGlobal *global,
|
|||
info.name = this->name;
|
||||
info.max_inputs = this->transport->area->max_inputs;
|
||||
info.n_inputs = this->transport->area->n_inputs;
|
||||
info.input_formats = NULL;
|
||||
for (info.n_input_formats = 0; ; info.n_input_formats++) {
|
||||
SpaFormat *fmt;
|
||||
void *p;
|
||||
|
||||
if (spa_node_port_enum_formats (this->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
0,
|
||||
&fmt,
|
||||
NULL,
|
||||
info.n_input_formats) < 0)
|
||||
break;
|
||||
|
||||
info.input_formats = realloc (info.input_formats, sizeof (SpaFormat*) * (info.n_input_formats + 1));
|
||||
|
||||
p = malloc (pinos_serialize_format_get_size (fmt));
|
||||
info.input_formats[info.n_input_formats] = pinos_serialize_format_copy_into (p, fmt);
|
||||
}
|
||||
info.max_outputs = this->transport->area->max_outputs;
|
||||
info.n_outputs = this->transport->area->n_outputs;
|
||||
info.output_formats = NULL;
|
||||
for (info.n_output_formats = 0; ; info.n_output_formats++) {
|
||||
SpaFormat *fmt;
|
||||
void *p;
|
||||
|
||||
if (spa_node_port_enum_formats (this->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
0,
|
||||
&fmt,
|
||||
NULL,
|
||||
info.n_output_formats) < 0)
|
||||
break;
|
||||
|
||||
info.output_formats = realloc (info.output_formats, sizeof (SpaFormat*) * (info.n_output_formats + 1));
|
||||
|
||||
p = malloc (pinos_serialize_format_get_size (fmt));
|
||||
info.output_formats[info.n_output_formats] = pinos_serialize_format_copy_into (p, fmt);
|
||||
}
|
||||
info.state = this->state;
|
||||
info.error = this->error;
|
||||
info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
|
@ -667,9 +704,9 @@ pinos_node_destroy (PinosNode * this)
|
|||
* @node: a #PinosNode
|
||||
* @direction: a #PinosDirection
|
||||
*
|
||||
* Find a new unused port id in @node with @direction
|
||||
* Find a new unused port in @node with @direction
|
||||
*
|
||||
* Returns: the new port id or %SPA_ID_INVALID on error
|
||||
* Returns: the new port or %NULL on error
|
||||
*/
|
||||
PinosPort *
|
||||
pinos_node_get_free_port (PinosNode *node,
|
||||
|
|
@ -698,12 +735,8 @@ pinos_node_get_free_port (PinosNode *node,
|
|||
}
|
||||
}
|
||||
|
||||
if (port == NULL) {
|
||||
if (!spa_list_is_empty (ports))
|
||||
port = spa_list_first (ports, PinosPort, link);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
if (port == NULL && !spa_list_is_empty (ports))
|
||||
port = spa_list_first (ports, PinosPort, link);
|
||||
|
||||
return port;
|
||||
|
||||
|
|
@ -812,7 +845,7 @@ pinos_node_update_state (PinosNode *node,
|
|||
|
||||
spa_zero (info);
|
||||
m.info = &info;
|
||||
info.change_mask = 1 << 1;
|
||||
info.change_mask = 1 << 5;
|
||||
info.state = node->state;
|
||||
info.error = node->error;
|
||||
|
||||
|
|
|
|||
|
|
@ -110,15 +110,25 @@ dump_node_info (PinosContext *c,
|
|||
printf ("\tid: %u\n", info->id);
|
||||
printf ("\ttype: %s\n", PINOS_NODE_URI);
|
||||
if (data->print_all) {
|
||||
int i;
|
||||
|
||||
printf ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name);
|
||||
printf ("%c\tinputs: %u/%u\n", MARK_CHANGE (1), info->n_inputs, info->max_inputs);
|
||||
printf ("%c\toutputs: %u/%u\n", MARK_CHANGE (2), info->n_outputs, info->max_outputs);
|
||||
printf ("%c\tstate: \"%s\"", MARK_CHANGE (3), pinos_node_state_as_string (info->state));
|
||||
printf ("%c\tinput formats:\n", MARK_CHANGE (2));
|
||||
for (i = 0; i < info->n_input_formats; i++)
|
||||
spa_debug_format (info->input_formats[i]);
|
||||
|
||||
printf ("%c\toutputs: %u/%u\n", MARK_CHANGE (3), info->n_outputs, info->max_outputs);
|
||||
printf ("%c\toutput formats:\n", MARK_CHANGE (4));
|
||||
for (i = 0; i < info->n_output_formats; i++)
|
||||
spa_debug_format (info->output_formats[i]);
|
||||
|
||||
printf ("%c\tstate: \"%s\"", MARK_CHANGE (5), pinos_node_state_as_string (info->state));
|
||||
if (info->state == PINOS_NODE_STATE_ERROR && info->error)
|
||||
printf (" \"%s\"\n", info->error);
|
||||
else
|
||||
printf ("\n");
|
||||
print_properties (info->props, MARK_CHANGE (4));
|
||||
print_properties (info->props, MARK_CHANGE (6));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ struct _SpaMonitor {
|
|||
|
||||
SpaResult (*enum_items) (SpaMonitor *monitor,
|
||||
SpaMonitorItem **item,
|
||||
void **state);
|
||||
unsigned int index);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -325,12 +325,12 @@ struct _SpaNode {
|
|||
* @port_id: the port to query
|
||||
* @format: pointer to a format
|
||||
* @filter: a format filter
|
||||
* @state: a state variable, %NULL to get the first item
|
||||
* @index: an index variable, 0 to get the first item
|
||||
*
|
||||
* Enumerate all possible formats on @port_id of @node that are compatible
|
||||
* with @filter..
|
||||
*
|
||||
* Use @state to retrieve the formats one by one until the function
|
||||
* Use @index to retrieve the formats one by one until the function
|
||||
* returns #SPA_RESULT_ENUM_END.
|
||||
*
|
||||
* The result format can be queried and modified and ultimately be used
|
||||
|
|
@ -348,7 +348,7 @@ struct _SpaNode {
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state);
|
||||
unsigned int index);
|
||||
/**
|
||||
* SpaNode::port_set_format:
|
||||
* @node: a #SpaNode
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ struct _SpaHandleFactory {
|
|||
* SpaHandle::enum_interface_info:
|
||||
* @factory: a #SpaHandleFactory
|
||||
* @info: result to hold SpaInterfaceInfo.
|
||||
* @state: state to keep track of the enumeration, %NULL for first item
|
||||
* @index: index to keep track of the enumeration, 0 for first item
|
||||
*
|
||||
* Enumerate the interface information for @factory.
|
||||
*
|
||||
|
|
@ -147,7 +147,7 @@ struct _SpaHandleFactory {
|
|||
*/
|
||||
SpaResult (*enum_interface_info) (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state);
|
||||
unsigned int index);
|
||||
};
|
||||
|
||||
#define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)
|
||||
|
|
@ -156,7 +156,7 @@ struct _SpaHandleFactory {
|
|||
/**
|
||||
* SpaEnumHandleFactoryFunc:
|
||||
* @factory: a location to hold the factory result
|
||||
* @state: state to keep track of the enumeration
|
||||
* @index: index to keep track of the enumeration
|
||||
*
|
||||
* The function signature of the entry point in a plugin.
|
||||
*
|
||||
|
|
@ -165,12 +165,12 @@ struct _SpaHandleFactory {
|
|||
* #SPA_RESULT_ENUM_END when there are no more factories
|
||||
*/
|
||||
typedef SpaResult (*SpaEnumHandleFactoryFunc) (const SpaHandleFactory **factory,
|
||||
void **state);
|
||||
unsigned int index);
|
||||
|
||||
/**
|
||||
* spa_enum_handle_factory:
|
||||
* @factory: a location to hold the factory result
|
||||
* @state: state to keep track of the enumeration
|
||||
* @index: index to keep track of the enumeration
|
||||
*
|
||||
* The entry point in a plugin.
|
||||
*
|
||||
|
|
@ -179,7 +179,7 @@ typedef SpaResult (*SpaEnumHandleFactoryFunc) (const SpaHandleFactory **factory,
|
|||
* #SPA_RESULT_ENUM_END when there are no more factories
|
||||
*/
|
||||
SpaResult spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state);
|
||||
unsigned int index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ struct _SpaALSAMonitor {
|
|||
struct udev* udev;
|
||||
struct udev_monitor *umonitor;
|
||||
struct udev_enumerate *enumerate;
|
||||
unsigned int index;
|
||||
struct udev_list_entry *devices;
|
||||
|
||||
ALSAItem uitem;
|
||||
|
||||
|
|
@ -317,14 +319,13 @@ spa_alsa_monitor_set_event_callback (SpaMonitor *monitor,
|
|||
static SpaResult
|
||||
spa_alsa_monitor_enum_items (SpaMonitor *monitor,
|
||||
SpaMonitorItem **item,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaResult res;
|
||||
SpaALSAMonitor *this;
|
||||
struct udev_list_entry *devices;
|
||||
struct udev_device *dev;
|
||||
|
||||
if (monitor == NULL || item == NULL || state == NULL)
|
||||
if (monitor == NULL || item == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor);
|
||||
|
|
@ -333,7 +334,7 @@ spa_alsa_monitor_enum_items (SpaMonitor *monitor,
|
|||
return res;
|
||||
|
||||
again:
|
||||
if (*state == NULL) {
|
||||
if (index == 0 || this->index > index) {
|
||||
if (this->enumerate)
|
||||
udev_enumerate_unref (this->enumerate);
|
||||
this->enumerate = udev_enumerate_new (this->udev);
|
||||
|
|
@ -341,27 +342,28 @@ again:
|
|||
udev_enumerate_add_match_subsystem (this->enumerate, "sound");
|
||||
udev_enumerate_scan_devices (this->enumerate);
|
||||
|
||||
devices = udev_enumerate_get_list_entry (this->enumerate);
|
||||
if (devices == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
} else {
|
||||
devices = *state;
|
||||
this->devices = udev_enumerate_get_list_entry (this->enumerate);
|
||||
this->index = 0;
|
||||
}
|
||||
|
||||
if (*state == (void*)1) {
|
||||
while (index > this->index && this->devices) {
|
||||
this->devices = udev_list_entry_get_next (this->devices);
|
||||
this->index++;
|
||||
}
|
||||
if (this->devices == NULL) {
|
||||
fill_item (this, &this->uitem, NULL);
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
dev = udev_device_new_from_syspath (this->udev,
|
||||
udev_list_entry_get_name (devices));
|
||||
udev_list_entry_get_name (this->devices));
|
||||
|
||||
if ((*state = udev_list_entry_get_next (devices)) == NULL)
|
||||
*state = (void*)1;
|
||||
this->devices = udev_list_entry_get_next (this->devices);
|
||||
|
||||
if (fill_item (this, &this->uitem, dev) < 0)
|
||||
goto again;
|
||||
|
||||
this->index++;
|
||||
|
||||
*item = &this->uitem.item;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -449,20 +451,15 @@ static const SpaInterfaceInfo alsa_monitor_interfaces[] =
|
|||
static SpaResult
|
||||
alsa_monitor_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index < 0 || index >= SPA_N_ELEMENTS (alsa_monitor_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &alsa_monitor_interfaces[index];
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -327,12 +327,11 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
|
|
@ -340,8 +339,6 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
|
|
@ -357,7 +354,6 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -832,15 +828,11 @@ static const SpaInterfaceInfo alsa_sink_interfaces[] =
|
|||
static SpaResult
|
||||
alsa_sink_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &alsa_sink_interfaces[index];
|
||||
|
|
@ -848,8 +840,6 @@ alsa_sink_enum_interface_info (const SpaHandleFactory *factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -363,12 +363,11 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
|
@ -376,8 +375,6 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
|
|
@ -393,7 +390,6 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -902,22 +898,16 @@ static const SpaInterfaceInfo alsa_source_interfaces[] =
|
|||
static SpaResult
|
||||
alsa_source_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index < 0 || index >= SPA_N_ELEMENTS (alsa_source_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &alsa_source_interfaces[index];
|
||||
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,14 +26,10 @@ extern const SpaHandleFactory spa_alsa_monitor_factory;
|
|||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
|
@ -48,7 +44,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,13 +311,12 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
SpaAudioMixerPort *port;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
|
@ -327,8 +326,6 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[0];
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
|
|
@ -339,7 +336,6 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &port->format[0].format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -781,15 +777,11 @@ static const SpaInterfaceInfo audiomixer_interfaces[] =
|
|||
static SpaResult
|
||||
audiomixer_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &audiomixer_interfaces[index];
|
||||
|
|
@ -797,7 +789,6 @@ audiomixer_enum_interface_info (const SpaHandleFactory *factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,15 +24,11 @@ extern const SpaHandleFactory spa_audiomixer_factory;
|
|||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_audiomixer_factory;
|
||||
|
|
@ -40,6 +36,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,12 +465,11 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
|
|
@ -478,8 +477,6 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
if (filter)
|
||||
|
|
@ -493,7 +490,6 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -984,15 +980,11 @@ static const SpaInterfaceInfo audiotestsrc_interfaces[] =
|
|||
static SpaResult
|
||||
audiotestsrc_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &audiotestsrc_interfaces[index];
|
||||
|
|
@ -1000,7 +992,6 @@ audiotestsrc_enum_interface_info (const SpaHandleFactory *factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,15 +24,11 @@ extern const SpaHandleFactory spa_audiotestsrc_factory;
|
|||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_audiotestsrc_factory;
|
||||
|
|
@ -40,6 +36,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,13 +251,12 @@ spa_ffmpeg_dec_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
SpaFFMpegPort *port;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
|
|
@ -267,8 +266,6 @@ spa_ffmpeg_dec_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_video_init (SPA_MEDIA_TYPE_VIDEO,
|
||||
|
|
@ -279,7 +276,6 @@ spa_ffmpeg_dec_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &port->format[0].format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,11 +256,10 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
SpaFFMpegPort *port;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -272,8 +271,6 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_video_init (SPA_MEDIA_TYPE_VIDEO,
|
||||
|
|
@ -284,7 +281,6 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &port->format[0].format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,39 +63,31 @@ static const SpaInterfaceInfo ffmpeg_interfaces[] =
|
|||
static SpaResult
|
||||
ffmpeg_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL || info == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &ffmpeg_interfaces[index];
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
static const AVCodec *c = NULL;
|
||||
static int ci = 0;
|
||||
static SpaHandleFactory f;
|
||||
static char name[128];
|
||||
int index;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
av_register_all();
|
||||
|
||||
if (index == 0 || index < ci) {
|
||||
if (index == 0) {
|
||||
c = av_codec_next (NULL);
|
||||
ci = 0;
|
||||
}
|
||||
|
|
@ -106,8 +98,6 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
if (c == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*(int*)state = ++index;
|
||||
|
||||
if (av_codec_is_encoder (c)) {
|
||||
snprintf (name, 128, "ffenc_%s", c->name);
|
||||
f.init = ffmpeg_enc_init;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ struct _SpaV4l2Monitor {
|
|||
struct udev* udev;
|
||||
struct udev_monitor *umonitor;
|
||||
struct udev_enumerate *enumerate;
|
||||
unsigned int index;
|
||||
struct udev_list_entry *devices;
|
||||
|
||||
V4l2Item uitem;
|
||||
|
||||
|
|
@ -251,14 +253,13 @@ spa_v4l2_monitor_set_event_callback (SpaMonitor *monitor,
|
|||
static SpaResult
|
||||
spa_v4l2_monitor_enum_items (SpaMonitor *monitor,
|
||||
SpaMonitorItem **item,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaResult res;
|
||||
SpaV4l2Monitor *this;
|
||||
struct udev_list_entry *devices;
|
||||
struct udev_device *dev;
|
||||
|
||||
if (monitor == NULL || item == NULL || state == NULL)
|
||||
if (monitor == NULL || item == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (monitor, SpaV4l2Monitor, monitor);
|
||||
|
|
@ -266,7 +267,7 @@ spa_v4l2_monitor_enum_items (SpaMonitor *monitor,
|
|||
if ((res = v4l2_udev_open (this)) < 0)
|
||||
return res;
|
||||
|
||||
if (*state == NULL) {
|
||||
if (index == 0) {
|
||||
if (this->enumerate)
|
||||
udev_enumerate_unref (this->enumerate);
|
||||
this->enumerate = udev_enumerate_new (this->udev);
|
||||
|
|
@ -274,20 +275,20 @@ spa_v4l2_monitor_enum_items (SpaMonitor *monitor,
|
|||
udev_enumerate_add_match_subsystem (this->enumerate, "video4linux");
|
||||
udev_enumerate_scan_devices (this->enumerate);
|
||||
|
||||
devices = udev_enumerate_get_list_entry (this->enumerate);
|
||||
if (devices == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
} else {
|
||||
devices = *state;
|
||||
this->devices = udev_enumerate_get_list_entry (this->enumerate);
|
||||
this->index = 0;
|
||||
}
|
||||
|
||||
if (*state == (void*)1) {
|
||||
while (index > this->index && this->devices) {
|
||||
this->devices = udev_list_entry_get_next (this->devices);
|
||||
this->index++;
|
||||
}
|
||||
if (this->devices == NULL) {
|
||||
fill_item (&this->uitem, NULL);
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
dev = udev_device_new_from_syspath (this->udev,
|
||||
udev_list_entry_get_name (devices));
|
||||
udev_list_entry_get_name (this->devices));
|
||||
|
||||
fill_item (&this->uitem, dev);
|
||||
if (dev == NULL)
|
||||
|
|
@ -295,8 +296,8 @@ spa_v4l2_monitor_enum_items (SpaMonitor *monitor,
|
|||
|
||||
*item = &this->uitem.item;
|
||||
|
||||
if ((*state = udev_list_entry_get_next (devices)) == NULL)
|
||||
*state = (void*)1;
|
||||
this->devices = udev_list_entry_get_next (this->devices);
|
||||
this->index++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -383,20 +384,15 @@ static const SpaInterfaceInfo v4l2_monitor_interfaces[] =
|
|||
static SpaResult
|
||||
v4l2_monitor_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index < 0 || index >= SPA_N_ELEMENTS (v4l2_monitor_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &v4l2_monitor_interfaces[index];
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ typedef struct {
|
|||
bool next_frmsize;
|
||||
struct v4l2_frmsizeenum frmsize;
|
||||
struct v4l2_frmivalenum frmival;
|
||||
void *cookie;
|
||||
|
||||
V4l2Format format[2];
|
||||
V4l2Format *current_format;
|
||||
|
|
@ -484,8 +483,8 @@ spa_v4l2_source_node_remove_port (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static void
|
||||
spa_v4l2_format_init (V4l2Format *f)
|
||||
static SpaResult
|
||||
spa_v4l2_format_init (V4l2Format *f, const SpaFormat *sf)
|
||||
{
|
||||
f->fmt.props.n_prop_info = 3;
|
||||
f->fmt.props.prop_info = f->infos;
|
||||
|
|
@ -499,6 +498,11 @@ spa_v4l2_format_init (V4l2Format *f)
|
|||
spa_prop_info_fill_video (&f->infos[2],
|
||||
SPA_PROP_ID_VIDEO_FRAMERATE,
|
||||
offsetof (V4l2Format, framerate));
|
||||
|
||||
f->fmt.media_type = sf->media_type;
|
||||
f->fmt.media_subtype = sf->media_subtype;
|
||||
|
||||
return spa_props_copy_values (&sf->props, &f->fmt.props);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -507,21 +511,20 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
|
||||
|
||||
spa_log_debug (this->log, "%p %d %d", this, direction, port_id);
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
res = spa_v4l2_enum_format (this, format, filter, state);
|
||||
res = spa_v4l2_enum_format (this, format, filter, index);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -537,7 +540,6 @@ spa_v4l2_source_node_port_set_format (SpaNode *node,
|
|||
SpaV4l2State *state;
|
||||
SpaResult res;
|
||||
V4l2Format *f, *tf;
|
||||
size_t fs;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -560,13 +562,9 @@ spa_v4l2_source_node_port_set_format (SpaNode *node,
|
|||
|
||||
f = &state->format[0];
|
||||
tf = &state->format[1];
|
||||
fs = sizeof (V4l2Format);
|
||||
|
||||
if ((SpaFormat*)f != format) {
|
||||
spa_v4l2_format_init (f);
|
||||
f->fmt.media_type = format->media_type;
|
||||
f->fmt.media_subtype = format->media_subtype;
|
||||
if ((res = spa_props_copy_values (&format->props, &f->fmt.props) < 0))
|
||||
if ((res = spa_v4l2_format_init (f, format)) < 0)
|
||||
return res;
|
||||
} else {
|
||||
f = (V4l2Format*)format;
|
||||
|
|
@ -590,7 +588,8 @@ spa_v4l2_source_node_port_set_format (SpaNode *node,
|
|||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
memcpy (tf, f, fs);
|
||||
if ((res = spa_v4l2_format_init (tf, &f->fmt)) < 0)
|
||||
return res;
|
||||
state->current_format = tf;
|
||||
|
||||
update_state (this, SPA_NODE_STATE_READY);
|
||||
|
|
@ -1019,20 +1018,15 @@ static const SpaInterfaceInfo v4l2_source_interfaces[] =
|
|||
static SpaResult
|
||||
v4l2_source_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index < 0 || index >= SPA_N_ELEMENTS (v4l2_source_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &v4l2_source_interfaces[index];
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -447,7 +447,10 @@ filter_framerate (struct v4l2_frmivalenum *frmival,
|
|||
#define FOURCC_ARGS(f) (f)&0x7f,((f)>>8)&0x7f,((f)>>16)&0x7f,((f)>>24)&0x7f
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_enum_format (SpaV4l2Source *this, SpaFormat **format, const SpaFormat *filter, void **cookie)
|
||||
spa_v4l2_enum_format (SpaV4l2Source *this,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
unsigned int index)
|
||||
{
|
||||
SpaV4l2State *state = &this->state[0];
|
||||
int res, i, pi;
|
||||
|
|
@ -459,7 +462,7 @@ spa_v4l2_enum_format (SpaV4l2Source *this, SpaFormat **format, const SpaFormat *
|
|||
|
||||
*format = NULL;
|
||||
|
||||
if (*cookie == NULL) {
|
||||
if (index == 0) {
|
||||
CLEAR (state->fmtdesc);
|
||||
state->fmtdesc.index = 0;
|
||||
state->fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
|
|
@ -467,7 +470,6 @@ spa_v4l2_enum_format (SpaV4l2Source *this, SpaFormat **format, const SpaFormat *
|
|||
CLEAR (state->frmsize);
|
||||
state->next_frmsize = true;
|
||||
CLEAR (state->frmival);
|
||||
*cookie = state;
|
||||
}
|
||||
|
||||
if (false) {
|
||||
|
|
|
|||
|
|
@ -25,15 +25,11 @@ extern const SpaHandleFactory spa_v4l2_monitor_factory;
|
|||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_v4l2_source_factory;
|
||||
|
|
@ -44,7 +40,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,15 +24,11 @@ extern const SpaHandleFactory spa_videotestsrc_factory;
|
|||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_videotestsrc_factory;
|
||||
|
|
@ -40,6 +36,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -425,12 +425,11 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||
|
|
@ -438,8 +437,6 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
if (filter)
|
||||
|
|
@ -453,7 +450,6 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -956,15 +952,11 @@ static const SpaInterfaceInfo videotestsrc_interfaces[] =
|
|||
static SpaResult
|
||||
videotestsrc_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &videotestsrc_interfaces[index];
|
||||
|
|
@ -972,7 +964,6 @@ videotestsrc_enum_interface_info (const SpaHandleFactory *factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,15 +24,11 @@ extern const SpaHandleFactory spa_volume_factory;
|
|||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_volume_factory;
|
||||
|
|
@ -40,7 +36,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,12 +288,11 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaVolume *this;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
|
@ -301,8 +300,6 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
|
|
@ -313,7 +310,6 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -851,15 +847,11 @@ static const SpaInterfaceInfo volume_interfaces[] =
|
|||
static SpaResult
|
||||
volume_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &volume_interfaces[index];
|
||||
|
|
@ -867,8 +859,6 @@ volume_enum_interface_info (const SpaHandleFactory *factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -290,12 +290,11 @@ spa_xv_sink_node_port_enum_formats (SpaNode *node,
|
|||
uint32_t port_id,
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
SpaXvSink *this;
|
||||
int index;
|
||||
|
||||
if (node == NULL || format == NULL || state == NULL)
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||
|
|
@ -303,8 +302,6 @@ spa_xv_sink_node_port_enum_formats (SpaNode *node,
|
|||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_format_video_init (SPA_MEDIA_TYPE_VIDEO,
|
||||
|
|
@ -315,7 +312,6 @@ spa_xv_sink_node_port_enum_formats (SpaNode *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->format[0].format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -613,15 +609,11 @@ static const SpaInterfaceInfo xv_sink_interfaces[] =
|
|||
static SpaResult
|
||||
xv_sink_enum_interface_info (const SpaHandleFactory *factory,
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &xv_sink_interfaces[index];
|
||||
|
|
@ -629,7 +621,6 @@ xv_sink_enum_interface_info (const SpaHandleFactory *factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,15 +24,11 @@ extern const SpaHandleFactory spa_xv_sink_factory;
|
|||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
unsigned int index)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_xv_sink_factory;
|
||||
|
|
@ -40,7 +36,5 @@ spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,17 +50,18 @@ inspect_port (SpaNode *node, SpaDirection direction, uint32_t port_id)
|
|||
{
|
||||
SpaResult res;
|
||||
SpaFormat *format;
|
||||
void *state = NULL;
|
||||
unsigned int index = 0;
|
||||
SpaProps *props;
|
||||
|
||||
while (true) {
|
||||
if ((res = spa_node_port_enum_formats (node, direction, port_id, &format, NULL, &state)) < 0) {
|
||||
if ((res = spa_node_port_enum_formats (node, direction, port_id, &format, NULL, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf ("got error %d\n", res);
|
||||
break;
|
||||
}
|
||||
if (format)
|
||||
spa_debug_format (format);
|
||||
index++;
|
||||
}
|
||||
if ((res = spa_node_port_get_props (node, direction, port_id, &props)) < 0)
|
||||
printf ("port_get_props error: %d\n", res);
|
||||
|
|
@ -113,7 +114,7 @@ inspect_factory (AppData *data, const SpaHandleFactory *factory)
|
|||
SpaResult res;
|
||||
SpaHandle *handle;
|
||||
void *interface;
|
||||
void *state = NULL;
|
||||
unsigned int index = 0;
|
||||
|
||||
printf ("factory name:\t\t'%s'\n", factory->name);
|
||||
printf ("factory info:\n");
|
||||
|
|
@ -134,12 +135,13 @@ inspect_factory (AppData *data, const SpaHandleFactory *factory)
|
|||
const SpaInterfaceInfo *info;
|
||||
uint32_t interface_id;
|
||||
|
||||
if ((res = spa_handle_factory_enum_interface_info (factory, &info, &state)) < 0) {
|
||||
if ((res = spa_handle_factory_enum_interface_info (factory, &info, index)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END)
|
||||
break;
|
||||
else
|
||||
printf ("can't enumerate interfaces: %d\n", res);
|
||||
}
|
||||
index++;
|
||||
printf (" interface: '%s'\n", info->uri);
|
||||
|
||||
interface_id = spa_id_map_get_id (data->map, info->uri);
|
||||
|
|
@ -179,7 +181,7 @@ main (int argc, char *argv[])
|
|||
SpaResult res;
|
||||
void *handle;
|
||||
SpaEnumHandleFactoryFunc enum_func;
|
||||
void *state = NULL;
|
||||
unsigned int index = 0;
|
||||
|
||||
if (argc < 2) {
|
||||
printf ("usage: %s <plugin.so>\n", argv[0]);
|
||||
|
|
@ -218,12 +220,13 @@ main (int argc, char *argv[])
|
|||
while (true) {
|
||||
const SpaHandleFactory *factory;
|
||||
|
||||
if ((res = enum_func (&factory, &state)) < 0) {
|
||||
if ((res = enum_func (&factory, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf ("can't enumerate factories: %d\n", res);
|
||||
break;
|
||||
}
|
||||
inspect_factory (&data, factory);
|
||||
index++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -123,15 +123,15 @@ static void
|
|||
handle_monitor (AppData *data, SpaMonitor *monitor)
|
||||
{
|
||||
SpaResult res;
|
||||
void *state = NULL;
|
||||
unsigned int index;
|
||||
|
||||
if (monitor->info)
|
||||
spa_debug_dict (monitor->info);
|
||||
|
||||
while (true) {
|
||||
for (index = 0; ; index++) {
|
||||
SpaMonitorItem *item;
|
||||
|
||||
if ((res = spa_monitor_enum_items (monitor, &item, &state)) < 0) {
|
||||
if ((res = spa_monitor_enum_items (monitor, &item, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf ("spa_monitor_enum_items: got error %d\n", res);
|
||||
break;
|
||||
|
|
@ -181,7 +181,7 @@ main (int argc, char *argv[])
|
|||
SpaResult res;
|
||||
void *handle;
|
||||
SpaEnumHandleFactoryFunc enum_func;
|
||||
void *fstate = NULL;
|
||||
unsigned int fidx;
|
||||
|
||||
data.map = spa_id_map_get_default ();
|
||||
data.log = NULL;
|
||||
|
|
@ -214,20 +214,20 @@ main (int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
for (fidx = 0;; fidx++) {
|
||||
const SpaHandleFactory *factory;
|
||||
void *istate = NULL;
|
||||
unsigned int iidx;
|
||||
|
||||
if ((res = enum_func (&factory, &fstate)) < 0) {
|
||||
if ((res = enum_func (&factory, fidx)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf ("can't enumerate factories: %d\n", res);
|
||||
break;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
for (iidx = 0;; iidx++) {
|
||||
const SpaInterfaceInfo *info;
|
||||
|
||||
if ((res = spa_handle_factory_enum_interface_info (factory, &info, &istate)) < 0) {
|
||||
if ((res = spa_handle_factory_enum_interface_info (factory, &info, iidx)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf ("can't enumerate interfaces: %d\n", res);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue