Make events and command specific to the node
Remove some unused code
Improve state changes
Use easier fixate by just taking the element default value
Fix reuse buffer in the proxy
This commit is contained in:
Wim Taymans 2016-09-06 16:43:37 +02:00
parent ac3cd24d5c
commit 8ada6736c0
29 changed files with 686 additions and 708 deletions

View file

@ -883,7 +883,6 @@ parse_control (PinosStream *stream,
if (spa_control_iter_parse_cmd (&it, &p) < 0) if (spa_control_iter_parse_cmd (&it, &p) < 0)
break; break;
g_debug ("reuse buffer %d", p.buffer_id);
if ((bid = find_buffer (stream, p.buffer_id))) { if ((bid = find_buffer (stream, p.buffer_id))) {
bid->used = FALSE; bid->used = FALSE;
g_signal_emit (stream, signals[SIGNAL_NEW_BUFFER], 0, p.buffer_id); g_signal_emit (stream, signals[SIGNAL_NEW_BUFFER], 0, p.buffer_id);

View file

@ -443,7 +443,6 @@ on_new_buffer (GObject *gobject,
} }
buf = g_hash_table_lookup (pinossink->buf_ids, GINT_TO_POINTER (id)); buf = g_hash_table_lookup (pinossink->buf_ids, GINT_TO_POINTER (id));
g_debug ("recycle buffer %d %p", id, buf);
if (buf) { if (buf) {
pinos_main_loop_signal (pinossink->loop, FALSE); pinos_main_loop_signal (pinossink->loop, FALSE);
} }

View file

@ -92,20 +92,20 @@ make_node (SpaNode **node, const char *lib, const char *name)
#if 0 #if 0
static void static void
on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) on_sink_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
{ {
PinosSpaAlsaSink *this = user_data; PinosSpaAlsaSink *this = user_data;
PinosSpaAlsaSinkPrivate *priv = this->priv; PinosSpaAlsaSinkPrivate *priv = this->priv;
switch (event->type) { switch (event->type) {
case SPA_EVENT_TYPE_NEED_INPUT: case SPA_NODE_EVENT_TYPE_NEED_INPUT:
{ {
SpaInputInfo iinfo; SpaPortInputInfo iinfo;
SpaResult res; SpaResult res;
PinosRingbufferArea areas[2]; PinosRingbufferArea areas[2];
uint8_t *data; uint8_t *data;
size_t size, towrite, total; size_t size, towrite, total;
SpaEventNeedInput *ni = event->data; SpaNodeEventNeedInput *ni = event->data;
size = 0; size = 0;
data = NULL; data = NULL;
@ -127,7 +127,7 @@ on_sink_event (SpaNode *node, SpaEvent *event, void *user_data)
pinos_ringbuffer_read_advance (priv->ringbuffer, total); pinos_ringbuffer_read_advance (priv->ringbuffer, total);
iinfo.port_id = ni->port_id; iinfo.port_id = ni->port_id;
iinfo.flags = SPA_INPUT_FLAG_NONE; iinfo.flags = SPA_PORT_INPUT_FLAG_NONE;
iinfo.buffer_id = 0; iinfo.buffer_id = 0;
g_debug ("push sink %d", iinfo.buffer_id); g_debug ("push sink %d", iinfo.buffer_id);

View file

@ -215,8 +215,11 @@ on_port_added (PinosNode *node, PinosDirection direction, guint port_id, PinosCl
} }
new_port = pinos_node_get_free_port_id (target, pinos_direction_reverse (direction)); new_port = pinos_node_get_free_port_id (target, pinos_direction_reverse (direction));
if (new_port == SPA_ID_INVALID) {
g_debug ("daemon %p: can't create free port", this);
return;
}
link = pinos_node_link (node, port_id, target, new_port, NULL, NULL); link = pinos_node_link (node, port_id, target, new_port, NULL, NULL);
pinos_client_add_object (client, G_OBJECT (link)); pinos_client_add_object (client, G_OBJECT (link));
g_object_unref (link); g_object_unref (link);
} }

View file

@ -40,19 +40,13 @@ struct _PinosLinkPrivate
PinosLink1 *iface; PinosLink1 *iface;
gchar *object_path; gchar *object_path;
GPtrArray *format_filter;
gboolean active; PinosProperties *properties;
gboolean negotiated;
gboolean allocated;
gboolean started;
SpaBuffer *in_buffers[16]; SpaBuffer *in_buffers[16];
unsigned int n_in_buffers; unsigned int n_in_buffers;
SpaBuffer *out_buffers[16]; SpaBuffer *out_buffers[16];
unsigned int n_out_buffers; unsigned int n_out_buffers;
GPtrArray *format_filter;
PinosProperties *properties;
}; };
G_DEFINE_TYPE (PinosLink, pinos_link, G_TYPE_OBJECT); G_DEFINE_TYPE (PinosLink, pinos_link, G_TYPE_OBJECT);
@ -73,8 +67,6 @@ enum
enum enum
{ {
SIGNAL_REMOVE, SIGNAL_REMOVE,
SIGNAL_ACTIVATE,
SIGNAL_DEACTIVATE,
LAST_SIGNAL LAST_SIGNAL
}; };
@ -206,71 +198,89 @@ link_unregister_object (PinosLink *this)
} }
static SpaResult static SpaResult
do_negotiate (PinosLink *this) do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
{ {
PinosLinkPrivate *priv = this->priv;
SpaResult res; SpaResult res;
SpaFormat *filter, *format; SpaFormat *filter, *format;
void *istate = NULL, *ostate = NULL; void *istate = NULL, *ostate = NULL;
g_debug ("link %p: doing set format", this); /* both ports need a format */
if (in_state == SPA_NODE_STATE_CONFIGURE && out_state == SPA_NODE_STATE_CONFIGURE) {
priv->negotiated = TRUE; g_debug ("link %p: doing negotiate format", this);
again: again:
if ((res = spa_node_port_enum_formats (this->input_node->node, if ((res = spa_node_port_enum_formats (this->input_node->node,
this->input_port, this->input_port,
&filter, &filter,
NULL, NULL,
&istate)) < 0) { &istate)) < 0) {
g_warning ("error input enum formats: %d", res); g_warning ("error input enum formats: %d", res);
goto error; goto error;
}
spa_debug_format (filter);
if ((res = spa_node_port_enum_formats (this->output_node->node,
this->output_port,
&format,
filter,
&ostate)) < 0) {
if (res == SPA_RESULT_ENUM_END) {
ostate = NULL;
goto again;
} }
g_warning ("error output enum formats: %d", res); spa_debug_format (filter);
goto error;
}
spa_format_fixate (format);
if ((res = spa_node_port_enum_formats (this->output_node->node,
this->output_port,
&format,
filter,
&ostate)) < 0) {
if (res == SPA_RESULT_ENUM_END) {
ostate = NULL;
goto again;
}
g_warning ("error output enum formats: %d", res);
goto error;
}
spa_format_fixate (format);
} else if (in_state == SPA_NODE_STATE_CONFIGURE) {
/* only input needs format */
if ((res = spa_node_port_get_format (this->output_node->node, this->output_port, (const SpaFormat **)&format)) < 0) {
g_warning ("error get format output: %d", res);
goto error;
}
} else if (out_state == SPA_NODE_STATE_CONFIGURE) {
/* only output needs format */
if ((res = spa_node_port_get_format (this->input_node->node, this->input_port, (const SpaFormat **)&format)) < 0) {
g_warning ("error get format input: %d", res);
goto error;
}
} else
return SPA_RESULT_OK;
g_debug ("link %p: doing set format", this);
spa_debug_format (format); spa_debug_format (format);
if ((res = spa_node_port_set_format (this->output_node->node, this->output_port, 0, format)) < 0) { if (out_state == SPA_NODE_STATE_CONFIGURE) {
g_warning ("error set format output: %d", res); if ((res = spa_node_port_set_format (this->output_node->node, this->output_port, 0, format)) < 0) {
goto error; g_warning ("error set format output: %d", res);
goto error;
}
} }
if ((res = spa_node_port_set_format (this->input_node->node, this->input_port, 0, format)) < 0) { if (in_state == SPA_NODE_STATE_CONFIGURE) {
g_warning ("error set format input: %d", res); if ((res = spa_node_port_set_format (this->input_node->node, this->input_port, 0, format)) < 0) {
goto error; g_warning ("error set format input: %d", res);
goto error;
}
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
error: error:
{ {
priv->negotiated = FALSE;
return res; return res;
} }
} }
static SpaResult static SpaResult
do_allocation (PinosLink *this) do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
{ {
PinosLinkPrivate *priv = this->priv; PinosLinkPrivate *priv = this->priv;
SpaResult res; SpaResult res;
const SpaPortInfo *iinfo, *oinfo; const SpaPortInfo *iinfo, *oinfo;
SpaPortInfoFlags in_flags, out_flags; SpaPortInfoFlags in_flags, out_flags;
if (in_state != SPA_NODE_STATE_READY || out_state != SPA_NODE_STATE_READY)
return SPA_RESULT_OK;
g_debug ("link %p: doing alloc buffers %p %p", this, this->output_node, this->input_node); g_debug ("link %p: doing alloc buffers %p %p", this, this->output_node, this->input_node);
/* find out what's possible */ /* find out what's possible */
if ((res = spa_node_port_get_info (this->output_node->node, this->output_port, &oinfo)) < 0) { if ((res = spa_node_port_get_info (this->output_node->node, this->output_port, &oinfo)) < 0) {
@ -282,8 +292,6 @@ do_allocation (PinosLink *this)
goto error; goto error;
} }
priv->allocated = TRUE;
spa_debug_port_info (oinfo); spa_debug_port_info (oinfo);
spa_debug_port_info (iinfo); spa_debug_port_info (iinfo);
@ -356,49 +364,25 @@ do_allocation (PinosLink *this)
error: error:
{ {
priv->allocated = FALSE;
return res; return res;
} }
} }
static SpaResult static SpaResult
do_start (PinosLink *this) do_start (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state)
{ {
PinosLinkPrivate *priv = this->priv; SpaNodeCommand cmd;
SpaCommand cmd; SpaResult res = SPA_RESULT_OK;
SpaResult res;
if (priv->started) cmd.type = SPA_NODE_COMMAND_START;
return SPA_RESULT_OK; if (in_state == SPA_NODE_STATE_PAUSED) {
if ((res = spa_node_send_command (this->input_node->node, &cmd)) < 0)
priv->started = TRUE; g_warning ("got error %d", res);
}
cmd.type = SPA_COMMAND_START; if (out_state == SPA_NODE_STATE_PAUSED) {
if ((res = spa_node_send_command (this->input_node->node, &cmd)) < 0) if ((res = spa_node_send_command (this->output_node->node, &cmd)) < 0)
g_warning ("got error %d", res); g_warning ("got error %d", res);
if ((res = spa_node_send_command (this->output_node->node, &cmd)) < 0) }
g_warning ("got error %d", res);
return res;
}
static SpaResult
do_pause (PinosLink *this)
{
PinosLinkPrivate *priv = this->priv;
SpaCommand cmd;
SpaResult res;
if (!priv->started)
return SPA_RESULT_OK;
priv->started = FALSE;
cmd.type = SPA_COMMAND_PAUSE;
if ((res = spa_node_send_command (this->input_node->node, &cmd)) < 0)
g_warning ("got error %d", res);
if ((res = spa_node_send_command (this->output_node->node, &cmd)) < 0)
g_warning ("got error %d", res);
return res; return res;
} }
@ -406,7 +390,6 @@ do_pause (PinosLink *this)
static SpaResult static SpaResult
check_states (PinosLink *this) check_states (PinosLink *this)
{ {
PinosLinkPrivate *priv = this->priv;
SpaResult res; SpaResult res;
SpaNodeState in_state, out_state; SpaNodeState in_state, out_state;
@ -415,24 +398,15 @@ check_states (PinosLink *this)
g_debug ("link %p: input %d, output %d", this, in_state, out_state); g_debug ("link %p: input %d, output %d", this, in_state, out_state);
if (in_state == SPA_NODE_STATE_CONFIGURE && if ((res = do_negotiate (this, in_state, out_state)) < 0)
out_state == SPA_NODE_STATE_CONFIGURE && return res;
!priv->negotiated) {
if ((res = do_negotiate (this)) < 0) if ((res = do_allocation (this, in_state, out_state)) < 0)
return res; return res;
}
if (in_state == SPA_NODE_STATE_READY && if ((res = do_start (this, in_state, out_state)) < 0)
out_state == SPA_NODE_STATE_READY && return res;
!priv->allocated) {
if ((res = do_allocation (this)) < 0)
return res;
}
if (in_state == SPA_NODE_STATE_PAUSED &&
out_state == SPA_NODE_STATE_PAUSED &&
!priv->started) {
if ((res = do_start (this)) < 0)
return res;
}
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
@ -486,26 +460,25 @@ pinos_link_constructed (GObject * object)
g_debug ("link %p: constructed %p:%d -> %p:%d", this, this->output_node, this->output_port, g_debug ("link %p: constructed %p:%d -> %p:%d", this, this->output_node, this->output_port,
this->input_node, this->input_port); this->input_node, this->input_port);
link_register_object (this); link_register_object (this);
check_states (this);
} }
static void static void
pinos_link_dispose (GObject * object) pinos_link_dispose (GObject * object)
{ {
PinosLink *this = PINOS_LINK (object); PinosLink *this = PINOS_LINK (object);
PinosLinkPrivate *priv = this->priv;
g_debug ("link %p: dispose", this); g_debug ("link %p: dispose", this);
g_signal_emit (this, signals[SIGNAL_REMOVE], 0, NULL);
g_signal_handlers_disconnect_by_data (this->input_node, this); g_signal_handlers_disconnect_by_data (this->input_node, this);
g_signal_handlers_disconnect_by_data (this->output_node, this); g_signal_handlers_disconnect_by_data (this->output_node, this);
g_signal_emit (this, signals[SIGNAL_REMOVE], 0, NULL);
g_clear_object (&this->input_node); g_clear_object (&this->input_node);
g_clear_object (&this->output_node); g_clear_object (&this->output_node);
if (priv->active) {
priv->active = FALSE;
}
link_unregister_object (this); link_unregister_object (this);
G_OBJECT_CLASS (pinos_link_parent_class)->dispose (object); G_OBJECT_CLASS (pinos_link_parent_class)->dispose (object);
@ -623,26 +596,6 @@ pinos_link_class_init (PinosLinkClass * klass)
G_TYPE_NONE, G_TYPE_NONE,
0, 0,
G_TYPE_NONE); G_TYPE_NONE);
signals[SIGNAL_ACTIVATE] = g_signal_new ("activate",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
0,
G_TYPE_NONE);
signals[SIGNAL_DEACTIVATE] = g_signal_new ("deactivate",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
0,
G_TYPE_NONE);
} }
static void static void
@ -685,23 +638,3 @@ pinos_link_get_object_path (PinosLink *this)
return priv->object_path; return priv->object_path;
} }
gboolean
pinos_link_activate (PinosLink *this)
{
g_return_val_if_fail (PINOS_IS_LINK (this), FALSE);
g_signal_emit (this, signals[SIGNAL_ACTIVATE], 0, NULL);
return TRUE;
}
gboolean
pinos_link_deactivate (PinosLink *this)
{
g_return_val_if_fail (PINOS_IS_LINK (this), FALSE);
do_pause (this);
g_signal_emit (this, signals[SIGNAL_DEACTIVATE], 0, NULL);
return TRUE;
}

View file

@ -69,9 +69,6 @@ GType pinos_link_get_type (void);
void pinos_link_remove (PinosLink *link); void pinos_link_remove (PinosLink *link);
gboolean pinos_link_activate (PinosLink *link);
gboolean pinos_link_deactivate (PinosLink *link);
PinosProperties * pinos_link_get_properties (PinosLink *link); PinosProperties * pinos_link_get_properties (PinosLink *link);
const gchar * pinos_link_get_object_path (PinosLink *link); const gchar * pinos_link_get_object_path (PinosLink *link);

View file

@ -269,11 +269,11 @@ static void
pause_node (PinosNode *this) pause_node (PinosNode *this)
{ {
SpaResult res; SpaResult res;
SpaCommand cmd; SpaNodeCommand cmd;
g_debug ("node %p: pause node", this); g_debug ("node %p: pause node", this);
cmd.type = SPA_COMMAND_PAUSE; cmd.type = SPA_NODE_COMMAND_PAUSE;
if ((res = spa_node_send_command (this->node, &cmd)) < 0) if ((res = spa_node_send_command (this->node, &cmd)) < 0)
g_debug ("got error %d", res); g_debug ("got error %d", res);
} }
@ -319,64 +319,78 @@ node_set_state (PinosNode *this,
} }
typedef struct {
PinosNode *node;
PinosDirection direction;
guint port_id;
} PortData;
static gboolean
do_signal_port_added (PortData *data)
{
g_signal_emit (data->node, signals[SIGNAL_PORT_ADDED], 0, data->direction, data->port_id);
g_slice_free (PortData, data);
return FALSE;
}
static gboolean
do_signal_port_removed (PortData *data)
{
g_signal_emit (data->node, signals[SIGNAL_PORT_REMOVED], 0, data->port_id);
g_slice_free (PortData, data);
return FALSE;
}
static void static void
on_node_event (SpaNode *node, SpaEvent *event, void *user_data) on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
{ {
PinosNode *this = user_data; PinosNode *this = user_data;
PinosNodePrivate *priv = this->priv; PinosNodePrivate *priv = this->priv;
switch (event->type) { switch (event->type) {
case SPA_EVENT_TYPE_PORT_ADDED: case SPA_NODE_EVENT_TYPE_PORT_ADDED:
{ {
SpaEventPortAdded *pa = event->data; SpaNodeEventPortAdded *pa = event->data;
PortData *data;
update_port_ids (this, FALSE); update_port_ids (this, FALSE);
g_signal_emit (this, signals[SIGNAL_PORT_ADDED], 0, get_port_direction (this, pa->port_id), data = g_slice_new (PortData);
pa->port_id); data->node = this;
data->direction = get_port_direction (this, pa->port_id);
data->port_id = pa->port_id;
g_main_context_invoke (NULL, (GSourceFunc) do_signal_port_added, data);
break; break;
} }
case SPA_EVENT_TYPE_PORT_REMOVED: case SPA_NODE_EVENT_TYPE_PORT_REMOVED:
{ {
SpaEventPortRemoved *pr = event->data; SpaNodeEventPortRemoved *pr = event->data;
PortData *data;
update_port_ids (this, FALSE); update_port_ids (this, FALSE);
g_signal_emit (this, signals[SIGNAL_PORT_REMOVED], 0, pr->port_id); data = g_slice_new (PortData);
data->node = this;
data->port_id = pr->port_id;
g_main_context_invoke (NULL, (GSourceFunc) do_signal_port_removed, data);
break; break;
} }
case SPA_EVENT_TYPE_STATE_CHANGE: case SPA_NODE_EVENT_TYPE_STATE_CHANGE:
{ {
SpaEventStateChange *sc = event->data; SpaNodeEventStateChange *sc = event->data;
g_debug ("node %p: update SPA state to %d", this, sc->state); g_debug ("node %p: update SPA state to %d", this, sc->state);
g_object_notify (G_OBJECT (this), "node-state");
if (sc->state == SPA_NODE_STATE_CONFIGURE) { if (sc->state == SPA_NODE_STATE_CONFIGURE) {
update_port_ids (this, FALSE); update_port_ids (this, FALSE);
} }
switch (sc->state) { g_object_notify (G_OBJECT (this), "node-state");
case SPA_NODE_STATE_CONFIGURE:
{
GList *links, *walk;
links = pinos_node_get_links (this);
for (walk = links; walk; walk = g_list_next (walk)) {
PinosLink *link = walk->data;
pinos_link_activate (link);
}
g_list_free (links);
}
default:
break;
}
break; break;
} }
case SPA_EVENT_TYPE_ADD_POLL: case SPA_NODE_EVENT_TYPE_ADD_POLL:
{ {
SpaPollItem *poll = event->data; SpaPollItem *poll = event->data;
g_debug ("node %p: add poll %d", this, poll->n_fds); g_debug ("node %p: add poll %d, n_fds %d", this, poll->id, poll->n_fds);
priv->poll[priv->n_poll] = *poll; priv->poll[priv->n_poll] = *poll;
priv->n_poll++; priv->n_poll++;
if (poll->n_fds) if (poll->n_fds)
@ -386,7 +400,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
start_thread (this); start_thread (this);
break; break;
} }
case SPA_EVENT_TYPE_UPDATE_POLL: case SPA_NODE_EVENT_TYPE_UPDATE_POLL:
{ {
unsigned int i; unsigned int i;
SpaPollItem *poll = event->data; SpaPollItem *poll = event->data;
@ -400,12 +414,12 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
wakeup_thread (this); wakeup_thread (this);
break; break;
} }
case SPA_EVENT_TYPE_REMOVE_POLL: case SPA_NODE_EVENT_TYPE_REMOVE_POLL:
{ {
SpaPollItem *poll = event->data; SpaPollItem *poll = event->data;
unsigned int i; unsigned int i;
g_debug ("node %p: remove poll %d", this, poll->n_fds); g_debug ("node %p: remove poll %d %d", this, poll->n_fds, priv->n_poll);
for (i = 0; i < priv->n_poll; i++) { for (i = 0; i < priv->n_poll; i++) {
if (priv->poll[i].id == poll->id) { if (priv->poll[i].id == poll->id) {
priv->n_poll--; priv->n_poll--;
@ -422,33 +436,35 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
} }
break; break;
} }
case SPA_EVENT_TYPE_HAVE_OUTPUT: case SPA_NODE_EVENT_TYPE_HAVE_OUTPUT:
{ {
PinosLink *link; PinosLink *link;
SpaOutputInfo oinfo[1] = { 0, }; SpaPortOutputInfo oinfo[1] = { 0, };
SpaResult res; SpaResult res;
if ((res = spa_node_port_pull_output (node, 1, oinfo)) < 0) if ((res = spa_node_port_pull_output (node, 1, oinfo)) < 0) {
g_warning ("node %p: got pull error %d, %d", this, res, oinfo[0].status); g_warning ("node %p: got pull error %d, %d", this, res, oinfo[0].status);
break;
}
link = g_hash_table_lookup (priv->links, GUINT_TO_POINTER (oinfo[0].port_id)); link = g_hash_table_lookup (priv->links, GUINT_TO_POINTER (oinfo[0].port_id));
if (link) { if (link) {
SpaInputInfo iinfo[1]; SpaPortInputInfo iinfo[1];
iinfo[0].port_id = link->input_port; iinfo[0].port_id = link->input_port;
iinfo[0].buffer_id = oinfo[0].buffer_id; iinfo[0].buffer_id = oinfo[0].buffer_id;
iinfo[0].flags = SPA_INPUT_FLAG_NONE; iinfo[0].flags = SPA_PORT_INPUT_FLAG_NONE;
if ((res = spa_node_port_push_input (link->input_node->node, 1, iinfo)) < 0) if ((res = spa_node_port_push_input (link->input_node->node, 1, iinfo)) < 0)
g_warning ("node %p: error pushing buffer: %d, %d", this, res, iinfo[0].status); g_warning ("node %p: error pushing buffer: %d, %d", this, res, iinfo[0].status);
} }
break; break;
} }
case SPA_EVENT_TYPE_REUSE_BUFFER: case SPA_NODE_EVENT_TYPE_REUSE_BUFFER:
{ {
PinosLink *link; PinosLink *link;
SpaResult res; SpaResult res;
SpaEventReuseBuffer *rb = event->data; SpaNodeEventReuseBuffer *rb = event->data;
link = g_hash_table_lookup (priv->links, GUINT_TO_POINTER (rb->port_id)); link = g_hash_table_lookup (priv->links, GUINT_TO_POINTER (rb->port_id));
if (link) { if (link) {

View file

@ -1,104 +0,0 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_EVENT_H__
#define __SPA_EVENT_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpaEvent SpaEvent;
#include <spa/defs.h>
#include <spa/poll.h>
#include <spa/node.h>
/**
* SpaEventType:
* @SPA_EVENT_TYPE_INVALID: invalid event, should be ignored
* @SPA_EVENT_TYPE_PORT_ADDED: a new port is added
* @SPA_EVENT_TYPE_PORT_REMOVED: a port is removed
* @SPA_EVENT_TYPE_STATE_CHANGE: emited when the state changes
* @SPA_EVENT_TYPE_HAVE_OUTPUT: emited when an async node has output that can be pulled
* @SPA_EVENT_TYPE_NEED_INPUT: emited when more data can be pushed to an async node
* @SPA_EVENT_TYPE_REUSE_BUFFER: emited when a buffer can be reused
* @SPA_EVENT_TYPE_ADD_POLL: emited when a pollfd should be added. data points to #SpaPollItem
* @SPA_EVENT_TYPE_UPDATE_POLL: update the pollfd item
* @SPA_EVENT_TYPE_REMOVE_POLL: emited when a pollfd should be removed. data points to #SpaPollItem
* @SPA_EVENT_TYPE_DRAINED: emited when DRAIN command completed
* @SPA_EVENT_TYPE_MARKER: emited when MARK command completed
* @SPA_EVENT_TYPE_ERROR: emited when error occured
* @SPA_EVENT_TYPE_BUFFERING: emited when buffering is in progress
* @SPA_EVENT_TYPE_REQUEST_REFRESH: emited when a keyframe refresh is needed
*/
typedef enum {
SPA_EVENT_TYPE_INVALID = 0,
SPA_EVENT_TYPE_PORT_ADDED,
SPA_EVENT_TYPE_PORT_REMOVED,
SPA_EVENT_TYPE_STATE_CHANGE,
SPA_EVENT_TYPE_HAVE_OUTPUT,
SPA_EVENT_TYPE_NEED_INPUT,
SPA_EVENT_TYPE_REUSE_BUFFER,
SPA_EVENT_TYPE_ADD_POLL,
SPA_EVENT_TYPE_UPDATE_POLL,
SPA_EVENT_TYPE_REMOVE_POLL,
SPA_EVENT_TYPE_DRAINED,
SPA_EVENT_TYPE_MARKER,
SPA_EVENT_TYPE_ERROR,
SPA_EVENT_TYPE_BUFFERING,
SPA_EVENT_TYPE_REQUEST_REFRESH,
} SpaEventType;
struct _SpaEvent {
SpaEventType type;
void *data;
size_t size;
};
typedef struct {
uint32_t port_id;
} SpaEventPortAdded;
typedef struct {
uint32_t port_id;
} SpaEventPortRemoved;
typedef struct {
SpaNodeState state;
} SpaEventStateChange;
typedef struct {
uint32_t port_id;
} SpaEventHaveOutput;
typedef struct {
uint32_t port_id;
} SpaEventNeedInput;
typedef struct {
uint32_t port_id;
uint32_t buffer_id;
} SpaEventReuseBuffer;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_EVENT_H__ */

View file

@ -17,35 +17,35 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __SPA_COMMAND_H__ #ifndef __SPA_NODE_COMMAND_H__
#define __SPA_COMMAND_H__ #define __SPA_NODE_COMMAND_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct _SpaCommand SpaCommand; typedef struct _SpaNodeCommand SpaNodeCommand;
#include <spa/defs.h> #include <spa/defs.h>
typedef enum { typedef enum {
SPA_COMMAND_INVALID = 0, SPA_NODE_COMMAND_INVALID = 0,
SPA_COMMAND_PAUSE, SPA_NODE_COMMAND_PAUSE,
SPA_COMMAND_START, SPA_NODE_COMMAND_START,
SPA_COMMAND_FLUSH, SPA_NODE_COMMAND_FLUSH,
SPA_COMMAND_DRAIN, SPA_NODE_COMMAND_DRAIN,
SPA_COMMAND_MARKER, SPA_NODE_COMMAND_MARKER,
} SpaCommandType; } SpaNodeCommandType;
struct _SpaCommand { struct _SpaNodeCommand {
SpaCommandType type; SpaNodeCommandType type;
uint32_t port_id; uint32_t port_id;
void *data; void *data;
size_t size; size_t size;
}; };
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /* __SPA_COMMAND_H__ */ #endif /* __SPA_NODE_COMMAND_H__ */

View file

@ -0,0 +1,104 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_NODE_EVENT_H__
#define __SPA_NODE_EVENT_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpaNodeEvent SpaNodeEvent;
#include <spa/defs.h>
#include <spa/poll.h>
#include <spa/node.h>
/**
* SpaEventType:
* @SPA_NODE_EVENT_TYPE_INVALID: invalid event, should be ignored
* @SPA_NODE_EVENT_TYPE_PORT_ADDED: a new port is added
* @SPA_NODE_EVENT_TYPE_PORT_REMOVED: a port is removed
* @SPA_NODE_EVENT_TYPE_STATE_CHANGE: emited when the state changes
* @SPA_NODE_EVENT_TYPE_HAVE_OUTPUT: emited when an async node has output that can be pulled
* @SPA_NODE_EVENT_TYPE_NEED_INPUT: emited when more data can be pushed to an async node
* @SPA_NODE_EVENT_TYPE_REUSE_BUFFER: emited when a buffer can be reused
* @SPA_NODE_EVENT_TYPE_ADD_POLL: emited when a pollfd should be added. data points to #SpaPollItem
* @SPA_NODE_EVENT_TYPE_UPDATE_POLL: update the pollfd item
* @SPA_NODE_EVENT_TYPE_REMOVE_POLL: emited when a pollfd should be removed. data points to #SpaPollItem
* @SPA_NODE_EVENT_TYPE_DRAINED: emited when DRAIN command completed
* @SPA_NODE_EVENT_TYPE_MARKER: emited when MARK command completed
* @SPA_NODE_EVENT_TYPE_ERROR: emited when error occured
* @SPA_NODE_EVENT_TYPE_BUFFERING: emited when buffering is in progress
* @SPA_NODE_EVENT_TYPE_REQUEST_REFRESH: emited when a keyframe refresh is needed
*/
typedef enum {
SPA_NODE_EVENT_TYPE_INVALID = 0,
SPA_NODE_EVENT_TYPE_PORT_ADDED,
SPA_NODE_EVENT_TYPE_PORT_REMOVED,
SPA_NODE_EVENT_TYPE_STATE_CHANGE,
SPA_NODE_EVENT_TYPE_HAVE_OUTPUT,
SPA_NODE_EVENT_TYPE_NEED_INPUT,
SPA_NODE_EVENT_TYPE_REUSE_BUFFER,
SPA_NODE_EVENT_TYPE_ADD_POLL,
SPA_NODE_EVENT_TYPE_UPDATE_POLL,
SPA_NODE_EVENT_TYPE_REMOVE_POLL,
SPA_NODE_EVENT_TYPE_DRAINED,
SPA_NODE_EVENT_TYPE_MARKER,
SPA_NODE_EVENT_TYPE_ERROR,
SPA_NODE_EVENT_TYPE_BUFFERING,
SPA_NODE_EVENT_TYPE_REQUEST_REFRESH,
} SpaNodeEventType;
struct _SpaNodeEvent {
SpaNodeEventType type;
void *data;
size_t size;
};
typedef struct {
uint32_t port_id;
} SpaNodeEventPortAdded;
typedef struct {
uint32_t port_id;
} SpaNodeEventPortRemoved;
typedef struct {
SpaNodeState state;
} SpaNodeEventStateChange;
typedef struct {
uint32_t port_id;
} SpaNodeEventHaveOutput;
typedef struct {
uint32_t port_id;
} SpaNodeEventNeedInput;
typedef struct {
uint32_t port_id;
uint32_t buffer_id;
} SpaNodeEventReuseBuffer;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_NODE_EVENT_H__ */

View file

@ -49,9 +49,9 @@ typedef enum {
#include <spa/plugin.h> #include <spa/plugin.h>
#include <spa/props.h> #include <spa/props.h>
#include <spa/port.h> #include <spa/port.h>
#include <spa/event.h> #include <spa/node-event.h>
#include <spa/node-command.h>
#include <spa/buffer.h> #include <spa/buffer.h>
#include <spa/command.h>
#include <spa/format.h> #include <spa/format.h>
/** /**
@ -70,15 +70,15 @@ typedef enum {
} SpaPortFormatFlags; } SpaPortFormatFlags;
/** /**
* SpaInputFlags: * SpaPortInputFlags:
* @SPA_INPUT_FLAG_NONE: no flag * @SPA_INPUT_FLAG_NONE: no flag
*/ */
typedef enum { typedef enum {
SPA_INPUT_FLAG_NONE = 0, SPA_PORT_INPUT_FLAG_NONE = 0,
} SpaInputFlags; } SpaPortInputFlags;
/** /**
* SpaInputInfo: * SpaPortInputInfo:
* @port_id: the port id * @port_id: the port id
* @flags: extra flags * @flags: extra flags
* @buffer_id: a buffer id * @buffer_id: a buffer id
@ -87,29 +87,29 @@ typedef enum {
* Input information for a node. * Input information for a node.
*/ */
typedef struct { typedef struct {
uint32_t port_id; uint32_t port_id;
SpaInputFlags flags; SpaPortInputFlags flags;
uint32_t buffer_id; uint32_t buffer_id;
SpaResult status; SpaResult status;
} SpaInputInfo; } SpaPortInputInfo;
/** /**
* SpaOutputFlags: * SpaPortOutputFlags:
* @SPA_OUTPUT_FLAG_NONE: no flag * @SPA_PORT_OUTPUT_FLAG_NONE: no flag
* @SPA_OUTPUT_FLAG_PULL: force a #SPA_EVENT_NEED_INPUT event on the * @SPA_PORT_OUTPUT_FLAG_PULL: force a #SPA_NODE_EVENT_NEED_INPUT event on the
* peer input ports when no data is available. * peer input ports when no data is available.
* @SPA_OUTPUT_FLAG_DISCARD: discard the buffer data * @SPA_PORT_OUTPUT_FLAG_DISCARD: discard the buffer data
* @SPA_OUTPUT_FLAG_NO_BUFFER: no buffer was produced on the port * @SPA_PORT_OUTPUT_FLAG_NO_BUFFER: no buffer was produced on the port
*/ */
typedef enum { typedef enum {
SPA_OUTPUT_FLAG_NONE = 0, SPA_PORT_OUTPUT_FLAG_NONE = 0,
SPA_OUTPUT_FLAG_PULL = (1 << 0), SPA_PORT_OUTPUT_FLAG_PULL = (1 << 0),
SPA_OUTPUT_FLAG_DISCARD = (1 << 1), SPA_PORT_OUTPUT_FLAG_DISCARD = (1 << 1),
SPA_OUTPUT_FLAG_NO_BUFFER = (1 << 2), SPA_PORT_OUTPUT_FLAG_NO_BUFFER = (1 << 2),
} SpaOutputFlags; } SpaPortOutputFlags;
/** /**
* SpaOutputInfo: * SpaPortOutputInfo:
* @port_id: the port id * @port_id: the port id
* @flags: extra flags * @flags: extra flags
* @buffer_id: a buffer id will be set * @buffer_id: a buffer id will be set
@ -119,15 +119,15 @@ typedef enum {
* Output information for a node. * Output information for a node.
*/ */
typedef struct { typedef struct {
uint32_t port_id; uint32_t port_id;
SpaOutputFlags flags; SpaPortOutputFlags flags;
uint32_t buffer_id; uint32_t buffer_id;
SpaEvent *event; SpaNodeEvent *event;
SpaResult status; SpaResult status;
} SpaOutputInfo; } SpaPortOutputInfo;
/** /**
* SpaEventCallback: * SpaNodeCallback:
* @node: a #SpaNode emiting the event * @node: a #SpaNode emiting the event
* @event: the event that was emited * @event: the event that was emited
* @user_data: user data provided when registering the callback * @user_data: user data provided when registering the callback
@ -135,9 +135,9 @@ typedef struct {
* This will be called when an out-of-bound event is notified * This will be called when an out-of-bound event is notified
* on @node. * on @node.
*/ */
typedef void (*SpaEventCallback) (SpaNode *node, typedef void (*SpaNodeEventCallback) (SpaNode *node,
SpaEvent *event, SpaNodeEvent *event,
void *user_data); void *user_data);
#define SPA_INTERFACE_ID_NODE 0 #define SPA_INTERFACE_ID_NODE 0
#define SPA_INTERFACE_ID_NODE_NAME "Node interface" #define SPA_INTERFACE_ID_NODE_NAME "Node interface"
@ -205,7 +205,7 @@ struct _SpaNode {
/** /**
* SpaNode::send_command: * SpaNode::send_command:
* @node: a #SpaNode * @node: a #SpaNode
* @command: a #SpaCommand * @command: a #SpaNodeCommand
* *
* Send a command to @node. * Send a command to @node.
* *
@ -215,7 +215,7 @@ struct _SpaNode {
* #SPA_RESULT_INVALID_COMMAND @command is an invalid command * #SPA_RESULT_INVALID_COMMAND @command is an invalid command
*/ */
SpaResult (*send_command) (SpaNode *node, SpaResult (*send_command) (SpaNode *node,
SpaCommand *command); SpaNodeCommand *command);
/** /**
* SpaNode::set_event_callback: * SpaNode::set_event_callback:
* @node: a #SpaNode * @node: a #SpaNode
@ -231,9 +231,9 @@ struct _SpaNode {
* Returns: #SPA_RESULT_OK on success * Returns: #SPA_RESULT_OK on success
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
*/ */
SpaResult (*set_event_callback) (SpaNode *node, SpaResult (*set_event_callback) (SpaNode *node,
SpaEventCallback callback, SpaNodeEventCallback callback,
void *user_data); void *user_data);
/** /**
* SpaNode::get_n_ports: * SpaNode::get_n_ports:
* @node: a #SpaNode * @node: a #SpaNode
@ -450,8 +450,8 @@ struct _SpaNode {
/** /**
* SpaNode::port_push_input: * SpaNode::port_push_input:
* @node: a #SpaNode * @node: a #SpaNode
* @n_info: number of #SpaInputInfo in @info * @n_info: number of #SpaPortInputInfo in @info
* @info: array of #SpaInputInfo * @info: array of #SpaPortInputInfo
* *
* Push a buffer id into one or more input ports of @node. * Push a buffer id into one or more input ports of @node.
* *
@ -464,12 +464,12 @@ struct _SpaNode {
*/ */
SpaResult (*port_push_input) (SpaNode *node, SpaResult (*port_push_input) (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info); SpaPortInputInfo *info);
/** /**
* SpaNode::port_pull_output: * SpaNode::port_pull_output:
* @node: a #SpaNode * @node: a #SpaNode
* @n_info: number of #SpaOutputInfo in @info * @n_info: number of #SpaPortOutputInfo in @info
* @info: array of #SpaOutputInfo * @info: array of #SpaPortOutputInfo
* *
* Pull a buffer id from one or more output ports of @node. * Pull a buffer id from one or more output ports of @node.
* *
@ -486,13 +486,13 @@ struct _SpaNode {
* #SPA_RESULT_NEED_MORE_INPUT when no output can be produced * #SPA_RESULT_NEED_MORE_INPUT when no output can be produced
* because more input is needed. * because more input is needed.
*/ */
SpaResult (*port_pull_output) (SpaNode *node, SpaResult (*port_pull_output) (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info); SpaPortOutputInfo *info);
SpaResult (*port_push_event) (SpaNode *node, SpaResult (*port_push_event) (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event); SpaNodeEvent *event);
}; };

View file

@ -65,8 +65,8 @@ typedef int (*SpaPollNotify) (SpaPollNotifyData *data);
* @fds: array of file descriptors to watch * @fds: array of file descriptors to watch
* @n_fds: number of elements in @fds * @n_fds: number of elements in @fds
* @idle_cb: callback called when there is no other work * @idle_cb: callback called when there is no other work
* @idle_cb: callback called before starting the poll * @before_cb: callback called before starting the poll
* @idle_cb: callback called after the poll loop * @after_cb: callback called after the poll loop
* @user_data: user data pass to callbacks * @user_data: user data pass to callbacks
*/ */
typedef struct { typedef struct {

View file

@ -234,7 +234,6 @@ spa_format_audio_init (SpaMediaType type,
format->info.raw = default_raw_info; format->info.raw = default_raw_info;
break; break;
} }
case SPA_MEDIA_SUBTYPE_MP3: case SPA_MEDIA_SUBTYPE_MP3:
case SPA_MEDIA_SUBTYPE_AAC: case SPA_MEDIA_SUBTYPE_AAC:
case SPA_MEDIA_SUBTYPE_VORBIS: case SPA_MEDIA_SUBTYPE_VORBIS:

View file

@ -36,13 +36,18 @@ spa_format_to_string (const SpaFormat *format, char **result)
SpaResult SpaResult
spa_format_fixate (SpaFormat *format) spa_format_fixate (SpaFormat *format)
{ {
#if 0
unsigned int i, j; unsigned int i, j;
SpaProps *props; SpaProps *props;
uint32_t mask; uint32_t mask;
#endif
if (format == NULL) if (format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
format->props.unset_mask = 0;
#if 0
props = &format->props; props = &format->props;
mask = props->unset_mask; mask = props->unset_mask;
@ -75,5 +80,6 @@ spa_format_fixate (SpaFormat *format)
} }
mask >>= 1; mask >>= 1;
} }
#endif
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }

View file

@ -28,8 +28,8 @@
static const SpaVideoInfoRaw default_raw_info = { static const SpaVideoInfoRaw default_raw_info = {
SPA_VIDEO_FORMAT_UNKNOWN, SPA_VIDEO_FORMAT_UNKNOWN,
{ 320, 240 }, { 320, 240 },
{ 0, 1 }, { 1, 25 },
{ 0, 1 }, { 1, 25 },
1, 1,
SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE, SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE,
{ 1, 1}, { 1, 1},

View file

@ -79,7 +79,7 @@ struct _SpaALSASink {
SpaALSASinkProps props[2]; SpaALSASinkProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
bool have_format; bool have_format;
@ -203,8 +203,8 @@ spa_alsa_sink_node_set_props (SpaNode *node,
} }
static SpaResult static SpaResult
spa_alsa_sink_node_send_command (SpaNode *node, spa_alsa_sink_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaALSASink *this; SpaALSASink *this;
@ -214,17 +214,17 @@ spa_alsa_sink_node_send_command (SpaNode *node,
this = (SpaALSASink *) node->handle; this = (SpaALSASink *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
spa_alsa_start (this); spa_alsa_start (this);
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_STREAMING; sc.state = SPA_NODE_STATE_STREAMING;
@ -232,14 +232,14 @@ spa_alsa_sink_node_send_command (SpaNode *node,
this->event_cb (node, &event, this->user_data); this->event_cb (node, &event, this->user_data);
} }
break; break;
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
spa_alsa_stop (this); spa_alsa_stop (this);
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_PAUSED; sc.state = SPA_NODE_STATE_PAUSED;
@ -247,18 +247,18 @@ spa_alsa_sink_node_send_command (SpaNode *node,
this->event_cb (node, &event, this->user_data); this->event_cb (node, &event, this->user_data);
} }
break; break;
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_alsa_sink_node_set_event_callback (SpaNode *node, spa_alsa_sink_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaALSASink *this; SpaALSASink *this;
@ -579,9 +579,9 @@ spa_alsa_sink_node_port_get_status (SpaNode *node,
} }
static SpaResult static SpaResult
spa_alsa_sink_node_port_push_input (SpaNode *node, spa_alsa_sink_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
SpaALSASink *this; SpaALSASink *this;
unsigned int i; unsigned int i;
@ -624,9 +624,9 @@ spa_alsa_sink_node_port_push_input (SpaNode *node,
} }
static SpaResult static SpaResult
spa_alsa_sink_node_port_pull_output (SpaNode *node, spa_alsa_sink_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
} }

View file

@ -224,10 +224,10 @@ xrun_recovery (snd_pcm_t *handle, int err)
static void static void
pull_input (SpaALSASink *this, void *data, snd_pcm_uframes_t frames) pull_input (SpaALSASink *this, void *data, snd_pcm_uframes_t frames)
{ {
SpaEvent event; SpaNodeEvent event;
SpaEventNeedInput ni; SpaNodeEventNeedInput ni;
event.type = SPA_EVENT_TYPE_NEED_INPUT; event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
event.size = sizeof (ni); event.size = sizeof (ni);
event.data = &ni; event.data = &ni;
ni.port_id = 0; ni.port_id = 0;
@ -323,7 +323,7 @@ spa_alsa_start (SpaALSASink *this)
{ {
SpaALSAState *state = &this->state; SpaALSAState *state = &this->state;
int err; int err;
SpaEvent event; SpaNodeEvent event;
if (spa_alsa_open (this) < 0) if (spa_alsa_open (this) < 0)
return -1; return -1;
@ -344,7 +344,7 @@ spa_alsa_start (SpaALSASink *this)
return err; return err;
} }
event.type = SPA_EVENT_TYPE_ADD_POLL; event.type = SPA_NODE_EVENT_TYPE_ADD_POLL;
event.data = &state->poll; event.data = &state->poll;
event.size = sizeof (state->poll); event.size = sizeof (state->poll);
@ -367,14 +367,14 @@ static int
spa_alsa_stop (SpaALSASink *this) spa_alsa_stop (SpaALSASink *this)
{ {
SpaALSAState *state = &this->state; SpaALSAState *state = &this->state;
SpaEvent event; SpaNodeEvent event;
if (!state->opened) if (!state->opened)
return 0; return 0;
snd_pcm_drop (state->handle); snd_pcm_drop (state->handle);
event.type = SPA_EVENT_TYPE_REMOVE_POLL; event.type = SPA_NODE_EVENT_TYPE_REMOVE_POLL;
event.data = &state->poll; event.data = &state->poll;
event.size = sizeof (state->poll); event.size = sizeof (state->poll);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);

View file

@ -69,7 +69,7 @@ struct _SpaAudioMixer {
SpaAudioMixerProps props[2]; SpaAudioMixerProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
int port_count; int port_count;
@ -132,8 +132,8 @@ spa_audiomixer_node_set_props (SpaNode *node,
} }
static SpaResult static SpaResult
spa_audiomixer_node_send_command (SpaNode *node, spa_audiomixer_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
@ -143,15 +143,15 @@ spa_audiomixer_node_send_command (SpaNode *node,
this = (SpaAudioMixer *) node->handle; this = (SpaAudioMixer *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_STREAMING; sc.state = SPA_NODE_STATE_STREAMING;
@ -160,12 +160,12 @@ spa_audiomixer_node_send_command (SpaNode *node,
} }
break; break;
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_PAUSED; sc.state = SPA_NODE_STATE_PAUSED;
@ -174,18 +174,18 @@ spa_audiomixer_node_send_command (SpaNode *node,
} }
break; break;
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_audiomixer_node_set_event_callback (SpaNode *node, spa_audiomixer_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
@ -496,9 +496,9 @@ spa_audiomixer_node_port_get_status (SpaNode *node,
} }
static SpaResult static SpaResult
spa_audiomixer_node_port_push_input (SpaNode *node, spa_audiomixer_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
unsigned int i; unsigned int i;
@ -562,12 +562,12 @@ spa_audiomixer_node_port_push_input (SpaNode *node,
static void static void
pull_port (SpaAudioMixer *this, uint32_t port_id, SpaOutputInfo *info, size_t pull_size) pull_port (SpaAudioMixer *this, uint32_t port_id, SpaPortOutputInfo *info, size_t pull_size)
{ {
SpaEvent event; SpaNodeEvent event;
SpaEventNeedInput ni; SpaNodeEventNeedInput ni;
event.type = SPA_EVENT_TYPE_NEED_INPUT; event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
event.size = sizeof (ni); event.size = sizeof (ni);
event.data = &ni; event.data = &ni;
ni.port_id = port_id; ni.port_id = port_id;
@ -628,7 +628,7 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port)
} }
static SpaResult static SpaResult
mix_data (SpaAudioMixer *this, SpaOutputInfo *info) mix_data (SpaAudioMixer *this, SpaPortOutputInfo *info)
{ {
int i, min_size, min_port, pull_size; int i, min_size, min_port, pull_size;
SpaBuffer *buf; SpaBuffer *buf;
@ -645,7 +645,7 @@ mix_data (SpaAudioMixer *this, SpaOutputInfo *info)
continue; continue;
if (this->ports[i].buffer == NULL) { if (this->ports[i].buffer == NULL) {
if (pull_size && info->flags & SPA_OUTPUT_FLAG_PULL) { if (pull_size && info->flags & SPA_PORT_OUTPUT_FLAG_PULL) {
pull_port (this, i, info, pull_size); pull_port (this, i, info, pull_size);
} }
if (this->ports[i].buffer == NULL) if (this->ports[i].buffer == NULL)
@ -676,9 +676,9 @@ mix_data (SpaAudioMixer *this, SpaOutputInfo *info)
} }
static SpaResult static SpaResult
spa_audiomixer_node_port_pull_output (SpaNode *node, spa_audiomixer_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
SpaAudioMixerPort *port; SpaAudioMixerPort *port;
@ -715,9 +715,9 @@ spa_audiomixer_node_port_pull_output (SpaNode *node,
} }
static SpaResult static SpaResult
spa_audiomixer_node_port_push_event (SpaNode *node, spa_audiomixer_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }

View file

@ -53,7 +53,7 @@ struct _SpaAudioTestSrc {
SpaAudioTestSrcProps props[2]; SpaAudioTestSrcProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
SpaPollItem idle; SpaPollItem idle;
@ -185,11 +185,11 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
static SpaResult static SpaResult
send_have_output (SpaAudioTestSrc *this) send_have_output (SpaAudioTestSrc *this)
{ {
SpaEvent event; SpaNodeEvent event;
SpaEventHaveOutput ho; SpaNodeEventHaveOutput ho;
if (this->event_cb) { if (this->event_cb) {
event.type = SPA_EVENT_TYPE_HAVE_OUTPUT; event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
event.size = sizeof (ho); event.size = sizeof (ho);
event.data = &ho; event.data = &ho;
ho.port_id = 0; ho.port_id = 0;
@ -202,8 +202,8 @@ send_have_output (SpaAudioTestSrc *this)
static void static void
update_state (SpaAudioTestSrc *this, SpaNodeState state) update_state (SpaAudioTestSrc *this, SpaNodeState state)
{ {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
if (this->node.state == state) if (this->node.state == state)
return; return;
@ -211,7 +211,7 @@ update_state (SpaAudioTestSrc *this, SpaNodeState state)
this->node.state = state; this->node.state = state;
if (this->event_cb) { if (this->event_cb) {
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = state; sc.state = state;
@ -222,11 +222,11 @@ update_state (SpaAudioTestSrc *this, SpaNodeState state)
static SpaResult static SpaResult
update_idle_enabled (SpaAudioTestSrc *this, bool enabled) update_idle_enabled (SpaAudioTestSrc *this, bool enabled)
{ {
SpaEvent event; SpaNodeEvent event;
if (this->event_cb) { if (this->event_cb) {
this->idle.enabled = enabled; this->idle.enabled = enabled;
event.type = SPA_EVENT_TYPE_UPDATE_POLL; event.type = SPA_NODE_EVENT_TYPE_UPDATE_POLL;
event.data = &this->idle; event.data = &this->idle;
event.size = sizeof (this->idle); event.size = sizeof (this->idle);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
@ -235,8 +235,8 @@ update_idle_enabled (SpaAudioTestSrc *this, bool enabled)
} }
static SpaResult static SpaResult
spa_audiotestsrc_node_send_command (SpaNode *node, spa_audiotestsrc_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
@ -246,10 +246,10 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle; this = (SpaAudioTestSrc *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
{ {
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -262,7 +262,7 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
update_state (this, SPA_NODE_STATE_STREAMING); update_state (this, SPA_NODE_STATE_STREAMING);
break; break;
} }
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
{ {
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -275,21 +275,21 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
update_state (this, SPA_NODE_STATE_PAUSED); update_state (this, SPA_NODE_STATE_PAUSED);
break; break;
} }
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_audiotestsrc_node_set_event_callback (SpaNode *node, spa_audiotestsrc_node_set_event_callback (SpaNode *node,
SpaEventCallback event_cb, SpaNodeEventCallback event_cb,
void *user_data) void *user_data)
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
SpaEvent event; SpaNodeEvent event;
if (node == NULL || node->handle == NULL) if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
@ -297,7 +297,7 @@ spa_audiotestsrc_node_set_event_callback (SpaNode *node,
this = (SpaAudioTestSrc *) node->handle; this = (SpaAudioTestSrc *) node->handle;
if (event_cb == NULL && this->event_cb) { if (event_cb == NULL && this->event_cb) {
event.type = SPA_EVENT_TYPE_REMOVE_POLL; event.type = SPA_NODE_EVENT_TYPE_REMOVE_POLL;
event.data = &this->idle; event.data = &this->idle;
event.size = sizeof (this->idle); event.size = sizeof (this->idle);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
@ -307,7 +307,7 @@ spa_audiotestsrc_node_set_event_callback (SpaNode *node,
this->user_data = user_data; this->user_data = user_data;
if (this->event_cb) { if (this->event_cb) {
event.type = SPA_EVENT_TYPE_ADD_POLL; event.type = SPA_NODE_EVENT_TYPE_ADD_POLL;
event.data = &this->idle; event.data = &this->idle;
event.size = sizeof (this->idle); event.size = sizeof (this->idle);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
@ -663,9 +663,9 @@ spa_audiotestsrc_node_port_get_status (SpaNode *node,
static SpaResult static SpaResult
spa_audiotestsrc_node_port_push_input (SpaNode *node, spa_audiotestsrc_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
} }
@ -707,9 +707,9 @@ audiotestsrc_idle (SpaPollNotifyData *data)
} }
static SpaResult static SpaResult
spa_audiotestsrc_node_port_pull_output (SpaNode *node, spa_audiotestsrc_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
unsigned int i; unsigned int i;
@ -755,9 +755,9 @@ spa_audiotestsrc_node_port_pull_output (SpaNode *node,
} }
static SpaResult static SpaResult
spa_audiotestsrc_node_port_push_event (SpaNode *node, spa_audiotestsrc_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }

View file

@ -71,7 +71,7 @@ struct _SpaFFMpegDec {
SpaFFMpegDecProps props[2]; SpaFFMpegDecProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
SpaFFMpegState state[2]; SpaFFMpegState state[2];
@ -128,8 +128,8 @@ spa_ffmpeg_dec_node_set_props (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_dec_node_send_command (SpaNode *node, spa_ffmpeg_dec_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaFFMpegDec *this; SpaFFMpegDec *this;
@ -139,15 +139,15 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
this = (SpaFFMpegDec *) node->handle; this = (SpaFFMpegDec *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_STREAMING; sc.state = SPA_NODE_STATE_STREAMING;
@ -155,12 +155,12 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
this->event_cb (node, &event, this->user_data); this->event_cb (node, &event, this->user_data);
} }
break; break;
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_PAUSED; sc.state = SPA_NODE_STATE_PAUSED;
@ -169,18 +169,18 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
} }
break; break;
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_ffmpeg_dec_node_set_event_callback (SpaNode *node, spa_ffmpeg_dec_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaFFMpegDec *this; SpaFFMpegDec *this;
@ -447,17 +447,17 @@ spa_ffmpeg_dec_node_port_get_status (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_dec_node_port_push_input (SpaNode *node, spa_ffmpeg_dec_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
} }
static SpaResult static SpaResult
spa_ffmpeg_dec_node_port_pull_output (SpaNode *node, spa_ffmpeg_dec_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
SpaFFMpegDec *this; SpaFFMpegDec *this;
SpaFFMpegState *state; SpaFFMpegState *state;
@ -491,9 +491,9 @@ spa_ffmpeg_dec_node_port_pull_output (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_dec_node_port_push_event (SpaNode *node, spa_ffmpeg_dec_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }

View file

@ -71,7 +71,7 @@ struct _SpaFFMpegEnc {
SpaFFMpegEncProps props[2]; SpaFFMpegEncProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
SpaFFMpegState state[2]; SpaFFMpegState state[2];
@ -128,8 +128,8 @@ spa_ffmpeg_enc_node_set_props (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_enc_node_send_command (SpaNode *node, spa_ffmpeg_enc_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
@ -139,15 +139,15 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
this = (SpaFFMpegEnc *) node->handle; this = (SpaFFMpegEnc *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_STREAMING; sc.state = SPA_NODE_STATE_STREAMING;
@ -155,12 +155,12 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
this->event_cb (node, &event, this->user_data); this->event_cb (node, &event, this->user_data);
} }
break; break;
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_PAUSED; sc.state = SPA_NODE_STATE_PAUSED;
@ -169,18 +169,18 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
} }
break; break;
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_ffmpeg_enc_node_set_event_callback (SpaNode *node, spa_ffmpeg_enc_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
@ -450,17 +450,17 @@ spa_ffmpeg_enc_node_port_get_status (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_enc_node_port_push_input (SpaNode *node, spa_ffmpeg_enc_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
} }
static SpaResult static SpaResult
spa_ffmpeg_enc_node_port_pull_output (SpaNode *node, spa_ffmpeg_enc_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
SpaFFMpegState *state; SpaFFMpegState *state;
@ -495,9 +495,9 @@ spa_ffmpeg_enc_node_port_pull_output (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_enc_node_port_push_event (SpaNode *node, spa_ffmpeg_enc_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }

View file

@ -70,7 +70,7 @@ struct _SpaLibvaDec {
SpaLibvaDecProps props[2]; SpaLibvaDecProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
SpaLibvaState state[2]; SpaLibvaState state[2];
@ -136,11 +136,11 @@ spa_libva_dec_node_send_command (SpaHandle *handle,
case SPA_COMMAND_START: case SPA_COMMAND_START:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
event.refcount = 1; event.refcount = 1;
event.notify = NULL; event.notify = NULL;
event.type = SPA_EVENT_TYPE_STARTED; event.type = SPA_NODE_EVENT_TYPE_STARTED;
event.port_id = -1; event.port_id = -1;
event.data = NULL; event.data = NULL;
event.size = 0; event.size = 0;
@ -150,11 +150,11 @@ spa_libva_dec_node_send_command (SpaHandle *handle,
break; break;
case SPA_COMMAND_STOP: case SPA_COMMAND_STOP:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
event.refcount = 1; event.refcount = 1;
event.notify = NULL; event.notify = NULL;
event.type = SPA_EVENT_TYPE_STOPPED; event.type = SPA_NODE_EVENT_TYPE_STOPPED;
event.port_id = -1; event.port_id = -1;
event.data = NULL; event.data = NULL;
event.size = 0; event.size = 0;
@ -172,9 +172,9 @@ spa_libva_dec_node_send_command (SpaHandle *handle,
} }
static SpaResult static SpaResult
spa_libva_dec_node_set_event_callback (SpaHandle *handle, spa_libva_dec_node_set_event_callback (SpaHandle *handle,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaLibvaDec *this = (SpaLibvaDec *) handle; SpaLibvaDec *this = (SpaLibvaDec *) handle;

View file

@ -67,7 +67,7 @@ struct _SpaProxy {
SpaProxyProps props[2]; SpaProxyProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
SpaPollFd fds[1]; SpaPollFd fds[1];
@ -104,13 +104,13 @@ reset_proxy_props (SpaProxyProps *props)
static void static void
update_poll (SpaProxy *this, int socketfd) update_poll (SpaProxy *this, int socketfd)
{ {
SpaEvent event; SpaNodeEvent event;
SpaProxyProps *p; SpaProxyProps *p;
p = &this->props[1]; p = &this->props[1];
if (p->socketfd != -1) { if (p->socketfd != -1) {
event.type = SPA_EVENT_TYPE_REMOVE_POLL; event.type = SPA_NODE_EVENT_TYPE_REMOVE_POLL;
event.data = &this->poll; event.data = &this->poll;
event.size = sizeof (this->poll); event.size = sizeof (this->poll);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
@ -119,7 +119,7 @@ update_poll (SpaProxy *this, int socketfd)
if (p->socketfd != -1) { if (p->socketfd != -1) {
this->fds[0].fd = p->socketfd; this->fds[0].fd = p->socketfd;
event.type = SPA_EVENT_TYPE_ADD_POLL; event.type = SPA_NODE_EVENT_TYPE_ADD_POLL;
event.data = &this->poll; event.data = &this->poll;
event.size = sizeof (this->poll); event.size = sizeof (this->poll);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
@ -130,12 +130,12 @@ static SpaResult
update_state (SpaProxy *this, SpaNodeState state) update_state (SpaProxy *this, SpaNodeState state)
{ {
if (this->node.state != state) { if (this->node.state != state) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
this->node.state = state; this->node.state = state;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = state; sc.state = state;
@ -196,8 +196,8 @@ spa_proxy_node_set_props (SpaNode *node,
} }
static SpaResult static SpaResult
spa_proxy_node_send_command (SpaNode *node, spa_proxy_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaProxy *this; SpaProxy *this;
SpaResult res; SpaResult res;
@ -208,10 +208,10 @@ spa_proxy_node_send_command (SpaNode *node,
this = (SpaProxy *) node->handle; this = (SpaProxy *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
{ {
SpaControlBuilder builder; SpaControlBuilder builder;
SpaControl control; SpaControl control;
@ -229,7 +229,7 @@ spa_proxy_node_send_command (SpaNode *node,
break; break;
} }
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
{ {
SpaControlBuilder builder; SpaControlBuilder builder;
SpaControl control; SpaControl control;
@ -247,18 +247,18 @@ spa_proxy_node_send_command (SpaNode *node,
break; break;
} }
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_proxy_node_set_event_callback (SpaNode *node, spa_proxy_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaProxy *this; SpaProxy *this;
@ -332,9 +332,9 @@ static void
do_update_port (SpaProxy *this, do_update_port (SpaProxy *this,
SpaControlCmdPortUpdate *pu) SpaControlCmdPortUpdate *pu)
{ {
SpaEvent event; SpaNodeEvent event;
SpaProxyPort *port; SpaProxyPort *port;
SpaEventPortAdded pa; SpaNodeEventPortAdded pa;
unsigned int i; unsigned int i;
port = &this->ports[pu->port_id]; port = &this->ports[pu->port_id];
@ -364,7 +364,7 @@ do_update_port (SpaProxy *this,
else else
this->n_outputs++; this->n_outputs++;
event.type = SPA_EVENT_TYPE_PORT_ADDED; event.type = SPA_NODE_EVENT_TYPE_PORT_ADDED;
event.size = sizeof (pa); event.size = sizeof (pa);
event.data = &pa; event.data = &pa;
pa.port_id = pu->port_id; pa.port_id = pu->port_id;
@ -376,9 +376,9 @@ static void
do_uninit_port (SpaProxy *this, do_uninit_port (SpaProxy *this,
uint32_t port_id) uint32_t port_id)
{ {
SpaEvent event; SpaNodeEvent event;
SpaProxyPort *port; SpaProxyPort *port;
SpaEventPortRemoved pr; SpaNodeEventPortRemoved pr;
fprintf (stderr, "proxy %p: removing port %d\n", this, port_id); fprintf (stderr, "proxy %p: removing port %d\n", this, port_id);
port = &this->ports[port_id]; port = &this->ports[port_id];
@ -393,7 +393,7 @@ do_uninit_port (SpaProxy *this,
spa_format_unref (port->format); spa_format_unref (port->format);
port->format = NULL; port->format = NULL;
event.type = SPA_EVENT_TYPE_PORT_REMOVED; event.type = SPA_NODE_EVENT_TYPE_PORT_REMOVED;
event.size = sizeof (pr); event.size = sizeof (pr);
event.data = &pr; event.data = &pr;
pr.port_id = port_id; pr.port_id = port_id;
@ -755,13 +755,40 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id, uint32_t port_id,
uint32_t buffer_id) uint32_t buffer_id)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaProxy *this;
SpaControlCmdReuseBuffer crb;
SpaControlBuilder builder;
SpaControl control;
uint8_t buf[128];
SpaResult res;
if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle;
if (!CHECK_PORT_ID (this, port_id))
return SPA_RESULT_INVALID_PORT;
/* send start */
spa_control_builder_init_into (&builder, buf, sizeof (buf), NULL, 0);
crb.port_id = port_id;
crb.buffer_id = buffer_id;
spa_control_builder_add_cmd (&builder, SPA_CONTROL_CMD_REUSE_BUFFER, &crb);
spa_control_builder_end (&builder, &control);
if ((res = spa_control_write (&control, this->fds[0].fd)) < 0)
fprintf (stderr, "proxy %p: error writing control %d\n", this, res);
spa_control_clear (&control);
return res;
} }
static SpaResult static SpaResult
spa_proxy_node_port_push_input (SpaNode *node, spa_proxy_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
@ -826,9 +853,9 @@ spa_proxy_node_port_push_input (SpaNode *node,
} }
static SpaResult static SpaResult
spa_proxy_node_port_pull_output (SpaNode *node, spa_proxy_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
@ -868,9 +895,9 @@ spa_proxy_node_port_pull_output (SpaNode *node,
} }
static SpaResult static SpaResult
spa_proxy_node_port_push_event (SpaNode *node, spa_proxy_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
SpaProxy *this; SpaProxy *this;
SpaResult res; SpaResult res;
@ -881,9 +908,9 @@ spa_proxy_node_port_push_event (SpaNode *node,
this = (SpaProxy *) node->handle; this = (SpaProxy *) node->handle;
switch (event->type) { switch (event->type) {
case SPA_EVENT_TYPE_REUSE_BUFFER: case SPA_NODE_EVENT_TYPE_REUSE_BUFFER:
{ {
SpaEventReuseBuffer *rb = event->data; SpaNodeEventReuseBuffer *rb = event->data;
SpaControlCmdReuseBuffer crb; SpaControlCmdReuseBuffer crb;
SpaControlBuilder builder; SpaControlBuilder builder;
SpaControl control; SpaControl control;
@ -990,14 +1017,14 @@ parse_control (SpaProxy *this,
} }
case SPA_CONTROL_CMD_HAVE_OUTPUT: case SPA_CONTROL_CMD_HAVE_OUTPUT:
{ {
SpaEvent event; SpaNodeEvent event;
SpaEventHaveOutput hu; SpaNodeEventHaveOutput hu;
SpaControlCmdHaveOutput cmd; SpaControlCmdHaveOutput cmd;
if (spa_control_iter_parse_cmd (&it, &cmd) < 0) if (spa_control_iter_parse_cmd (&it, &cmd) < 0)
break; break;
event.type = SPA_EVENT_TYPE_HAVE_OUTPUT; event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
event.data = &hu; event.data = &hu;
event.size = sizeof (hu); event.size = sizeof (hu);
hu.port_id = cmd.port_id; hu.port_id = cmd.port_id;
@ -1026,14 +1053,14 @@ parse_control (SpaProxy *this,
} }
case SPA_CONTROL_CMD_REUSE_BUFFER: case SPA_CONTROL_CMD_REUSE_BUFFER:
{ {
SpaEvent event; SpaNodeEvent event;
SpaEventReuseBuffer rb; SpaNodeEventReuseBuffer rb;
SpaControlCmdReuseBuffer crb; SpaControlCmdReuseBuffer crb;
if (spa_control_iter_parse_cmd (&it, &crb) < 0) if (spa_control_iter_parse_cmd (&it, &crb) < 0)
break; break;
event.type = SPA_EVENT_TYPE_REUSE_BUFFER; event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
event.data = &rb; event.data = &rb;
event.size = sizeof (rb); event.size = sizeof (rb);
rb.port_id = crb.port_id; rb.port_id = crb.port_id;

View file

@ -123,12 +123,30 @@ struct _SpaV4l2Source {
SpaV4l2SourceProps props[2]; SpaV4l2SourceProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
SpaV4l2State state[1]; SpaV4l2State state[1];
}; };
static void
update_state (SpaV4l2Source *this, SpaNodeState state)
{
SpaNodeEvent event;
SpaNodeEventStateChange sc;
if (this->node.state == state)
return;
this->node.state = state;
event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc;
event.size = sizeof (sc);
sc.state = state;
this->event_cb (&this->node, &event, this->user_data);
}
#include "v4l2-utils.c" #include "v4l2-utils.c"
enum { enum {
@ -201,27 +219,9 @@ spa_v4l2_source_node_set_props (SpaNode *node,
return res; return res;
} }
static void
update_state (SpaV4l2Source *this, SpaNodeState state)
{
SpaEvent event;
SpaEventStateChange sc;
if (this->node.state == state)
return;
this->node.state = state;
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
event.data = &sc;
event.size = sizeof (sc);
sc.state = state;
this->event_cb (&this->node, &event, this->user_data);
}
static SpaResult static SpaResult
spa_v4l2_source_node_send_command (SpaNode *node, spa_v4l2_source_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaV4l2Source *this; SpaV4l2Source *this;
SpaResult res; SpaResult res;
@ -232,10 +232,10 @@ spa_v4l2_source_node_send_command (SpaNode *node,
this = (SpaV4l2Source *) node->handle; this = (SpaV4l2Source *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
{ {
SpaV4l2State *state = &this->state[0]; SpaV4l2State *state = &this->state[0];
@ -248,10 +248,9 @@ spa_v4l2_source_node_send_command (SpaNode *node,
if ((res = spa_v4l2_start (this)) < 0) if ((res = spa_v4l2_start (this)) < 0)
return res; return res;
update_state (this, SPA_NODE_STATE_STREAMING);
break; break;
} }
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
{ {
SpaV4l2State *state = &this->state[0]; SpaV4l2State *state = &this->state[0];
@ -264,22 +263,21 @@ spa_v4l2_source_node_send_command (SpaNode *node,
if ((res = spa_v4l2_pause (this)) < 0) if ((res = spa_v4l2_pause (this)) < 0)
return res; return res;
update_state (this, SPA_NODE_STATE_PAUSED);
break; break;
} }
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_v4l2_source_node_set_event_callback (SpaNode *node, spa_v4l2_source_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaV4l2Source *this; SpaV4l2Source *this;
@ -647,17 +645,17 @@ spa_v4l2_source_node_port_get_status (SpaNode *node,
} }
static SpaResult static SpaResult
spa_v4l2_source_node_port_push_input (SpaNode *node, spa_v4l2_source_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
} }
static SpaResult static SpaResult
spa_v4l2_source_node_port_pull_output (SpaNode *node, spa_v4l2_source_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
SpaV4l2Source *this; SpaV4l2Source *this;
SpaV4l2State *state; SpaV4l2State *state;
@ -706,9 +704,9 @@ spa_v4l2_source_node_port_pull_output (SpaNode *node,
} }
static SpaResult static SpaResult
spa_v4l2_source_node_port_push_event (SpaNode *node, spa_v4l2_source_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }

View file

@ -450,9 +450,8 @@ again:
i = ++state->frmival.index; i = ++state->frmival.index;
} }
fmt->infos[pi].n_range_values = i; fmt->infos[pi].n_range_values = i;
if (i == 1) { fmt->framerate = fmt->framerates[0];
fmt->framerate = fmt->framerates[0]; if (i > 1) {
} else {
SPA_PROPS_INDEX_UNSET (&fmt->fmt.props, pi); SPA_PROPS_INDEX_UNSET (&fmt->fmt.props, pi);
} }
pi = ++fmt->fmt.props.n_prop_info; pi = ++fmt->fmt.props.n_prop_info;
@ -561,10 +560,11 @@ mmap_read (SpaV4l2Source *this)
if (xioctl (state->fd, VIDIOC_DQBUF, &buf) < 0) { if (xioctl (state->fd, VIDIOC_DQBUF, &buf) < 0) {
switch (errno) { switch (errno) {
case EAGAIN: case EAGAIN:
return 0; return SPA_RESULT_ERROR;
case EIO: case EIO:
default: default:
perror ("VIDIOC_DQBUF"); perror ("VIDIOC_DQBUF");
usleep (50 * 1000);
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
} }
@ -583,13 +583,13 @@ static int
v4l2_on_fd_events (SpaPollNotifyData *data) v4l2_on_fd_events (SpaPollNotifyData *data)
{ {
SpaV4l2Source *this = data->user_data; SpaV4l2Source *this = data->user_data;
SpaEvent event; SpaNodeEvent event;
SpaEventHaveOutput ho; SpaNodeEventHaveOutput ho;
if (mmap_read (this) < 0) if (mmap_read (this) < 0)
return 0; return 0;
event.type = SPA_EVENT_TYPE_HAVE_OUTPUT; event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
event.size = sizeof (ho); event.size = sizeof (ho);
event.data = &ho; event.data = &ho;
ho.port_id = 0; ho.port_id = 0;
@ -849,7 +849,7 @@ spa_v4l2_start (SpaV4l2Source *this)
{ {
SpaV4l2State *state = &this->state[0]; SpaV4l2State *state = &this->state[0];
enum v4l2_buf_type type; enum v4l2_buf_type type;
SpaEvent event; SpaNodeEvent event;
if (state->started) if (state->started)
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -859,8 +859,10 @@ spa_v4l2_start (SpaV4l2Source *this)
perror ("VIDIOC_STREAMON"); perror ("VIDIOC_STREAMON");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
state->started = true;
update_state (this, SPA_NODE_STATE_STREAMING);
event.type = SPA_EVENT_TYPE_ADD_POLL; event.type = SPA_NODE_EVENT_TYPE_ADD_POLL;
event.data = &state->poll; event.data = &state->poll;
event.size = sizeof (state->poll); event.size = sizeof (state->poll);
@ -878,8 +880,6 @@ spa_v4l2_start (SpaV4l2Source *this)
state->poll.user_data = this; state->poll.user_data = this;
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
state->started = true;
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
@ -888,12 +888,12 @@ spa_v4l2_pause (SpaV4l2Source *this)
{ {
SpaV4l2State *state = &this->state[0]; SpaV4l2State *state = &this->state[0];
enum v4l2_buf_type type; enum v4l2_buf_type type;
SpaEvent event; SpaNodeEvent event;
if (!state->started) if (!state->started)
return SPA_RESULT_OK; return SPA_RESULT_OK;
event.type = SPA_EVENT_TYPE_REMOVE_POLL; event.type = SPA_NODE_EVENT_TYPE_REMOVE_POLL;
event.data = &state->poll; event.data = &state->poll;
event.size = sizeof (state->poll); event.size = sizeof (state->poll);
this->event_cb (&this->node, &event, this->user_data); this->event_cb (&this->node, &event, this->user_data);
@ -905,6 +905,7 @@ spa_v4l2_pause (SpaV4l2Source *this)
perror ("VIDIOC_STREAMOFF"); perror ("VIDIOC_STREAMOFF");
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
} }
update_state (this, SPA_NODE_STATE_PAUSED);
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }

View file

@ -47,7 +47,7 @@ struct _SpaVolume {
SpaVolumeProps props[2]; SpaVolumeProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
bool have_format; bool have_format;
@ -137,8 +137,8 @@ spa_volume_node_set_props (SpaNode *node,
} }
static SpaResult static SpaResult
spa_volume_node_send_command (SpaNode *node, spa_volume_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaVolume *this; SpaVolume *this;
@ -148,15 +148,15 @@ spa_volume_node_send_command (SpaNode *node,
this = (SpaVolume *) node->handle; this = (SpaVolume *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_STREAMING; sc.state = SPA_NODE_STATE_STREAMING;
@ -165,12 +165,12 @@ spa_volume_node_send_command (SpaNode *node,
} }
break; break;
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_PAUSED; sc.state = SPA_NODE_STATE_PAUSED;
@ -179,18 +179,18 @@ spa_volume_node_send_command (SpaNode *node,
} }
break; break;
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_volume_node_set_event_callback (SpaNode *node, spa_volume_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaVolume *this; SpaVolume *this;
@ -448,9 +448,9 @@ spa_volume_node_port_get_status (SpaNode *node,
static SpaResult static SpaResult
spa_volume_node_port_push_input (SpaNode *node, spa_volume_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
SpaVolume *this; SpaVolume *this;
unsigned int i; unsigned int i;
@ -517,10 +517,10 @@ find_free_buffer (SpaVolume *this, SpaVolumePort *port)
static void static void
release_buffer (SpaVolume *this, SpaBuffer *buffer) release_buffer (SpaVolume *this, SpaBuffer *buffer)
{ {
SpaEvent event; SpaNodeEvent event;
SpaEventReuseBuffer rb; SpaNodeEventReuseBuffer rb;
event.type = SPA_EVENT_TYPE_REUSE_BUFFER; event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
event.data = &rb; event.data = &rb;
event.size = sizeof (rb); event.size = sizeof (rb);
rb.port_id = 0; rb.port_id = 0;
@ -529,9 +529,9 @@ release_buffer (SpaVolume *this, SpaBuffer *buffer)
} }
static SpaResult static SpaResult
spa_volume_node_port_pull_output (SpaNode *node, spa_volume_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
SpaVolume *this; SpaVolume *this;
SpaVolumePort *port; SpaVolumePort *port;
@ -610,9 +610,9 @@ spa_volume_node_port_pull_output (SpaNode *node,
} }
static SpaResult static SpaResult
spa_volume_node_port_push_event (SpaNode *node, spa_volume_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }

View file

@ -73,7 +73,7 @@ struct _SpaXvSink {
SpaXvSinkProps props[2]; SpaXvSinkProps props[2];
SpaEventCallback event_cb; SpaNodeEventCallback event_cb;
void *user_data; void *user_data;
SpaFormatVideo format[2]; SpaFormatVideo format[2];
@ -159,8 +159,8 @@ spa_xv_sink_node_set_props (SpaNode *node,
} }
static SpaResult static SpaResult
spa_xv_sink_node_send_command (SpaNode *node, spa_xv_sink_node_send_command (SpaNode *node,
SpaCommand *command) SpaNodeCommand *command)
{ {
SpaXvSink *this; SpaXvSink *this;
@ -170,17 +170,17 @@ spa_xv_sink_node_send_command (SpaNode *node,
this = (SpaXvSink *) node->handle; this = (SpaXvSink *) node->handle;
switch (command->type) { switch (command->type) {
case SPA_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
return SPA_RESULT_INVALID_COMMAND; return SPA_RESULT_INVALID_COMMAND;
case SPA_COMMAND_START: case SPA_NODE_COMMAND_START:
spa_xv_start (this); spa_xv_start (this);
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_STREAMING; sc.state = SPA_NODE_STATE_STREAMING;
@ -188,14 +188,14 @@ spa_xv_sink_node_send_command (SpaNode *node,
this->event_cb (node, &event, this->user_data); this->event_cb (node, &event, this->user_data);
} }
break; break;
case SPA_COMMAND_PAUSE: case SPA_NODE_COMMAND_PAUSE:
spa_xv_stop (this); spa_xv_stop (this);
if (this->event_cb) { if (this->event_cb) {
SpaEvent event; SpaNodeEvent event;
SpaEventStateChange sc; SpaNodeEventStateChange sc;
event.type = SPA_EVENT_TYPE_STATE_CHANGE; event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE;
event.data = &sc; event.data = &sc;
event.size = sizeof (sc); event.size = sizeof (sc);
sc.state = SPA_NODE_STATE_PAUSED; sc.state = SPA_NODE_STATE_PAUSED;
@ -204,18 +204,18 @@ spa_xv_sink_node_send_command (SpaNode *node,
} }
break; break;
case SPA_COMMAND_FLUSH: case SPA_NODE_COMMAND_FLUSH:
case SPA_COMMAND_DRAIN: case SPA_NODE_COMMAND_DRAIN:
case SPA_COMMAND_MARKER: case SPA_NODE_COMMAND_MARKER:
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_xv_sink_node_set_event_callback (SpaNode *node, spa_xv_sink_node_set_event_callback (SpaNode *node,
SpaEventCallback event, SpaNodeEventCallback event,
void *user_data) void *user_data)
{ {
SpaXvSink *this; SpaXvSink *this;
@ -474,25 +474,25 @@ spa_xv_sink_node_port_get_status (SpaNode *node,
} }
static SpaResult static SpaResult
spa_xv_sink_node_port_push_input (SpaNode *node, spa_xv_sink_node_port_push_input (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaInputInfo *info) SpaPortInputInfo *info)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
static SpaResult static SpaResult
spa_xv_sink_node_port_pull_output (SpaNode *node, spa_xv_sink_node_port_pull_output (SpaNode *node,
unsigned int n_info, unsigned int n_info,
SpaOutputInfo *info) SpaPortOutputInfo *info)
{ {
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
} }
static SpaResult static SpaResult
spa_xv_sink_node_port_push_event (SpaNode *node, spa_xv_sink_node_port_push_event (SpaNode *node,
uint32_t port_id, uint32_t port_id,
SpaEvent *event) SpaNodeEvent *event)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }

View file

@ -89,20 +89,20 @@ make_node (SpaNode **node, const char *lib, const char *name)
} }
static void static void
on_mix_event (SpaNode *node, SpaEvent *event, void *user_data) on_mix_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
{ {
AppData *data = user_data; AppData *data = user_data;
switch (event->type) { switch (event->type) {
case SPA_EVENT_TYPE_NEED_INPUT: case SPA_NODE_EVENT_TYPE_NEED_INPUT:
{ {
SpaInputInfo iinfo; SpaPortInputInfo iinfo;
SpaOutputInfo oinfo; SpaPortOutputInfo oinfo;
SpaResult res; SpaResult res;
SpaEventNeedInput *ni = event->data; SpaNodeEventNeedInput *ni = event->data;
oinfo.port_id = 0; oinfo.port_id = 0;
oinfo.flags = SPA_OUTPUT_FLAG_NONE; oinfo.flags = SPA_PORT_OUTPUT_FLAG_NONE;
if (ni->port_id == data->mix_ports[0]) { if (ni->port_id == data->mix_ports[0]) {
if ((res = spa_node_port_pull_output (data->source1, 1, &oinfo)) < 0) if ((res = spa_node_port_pull_output (data->source1, 1, &oinfo)) < 0)
@ -113,7 +113,7 @@ on_mix_event (SpaNode *node, SpaEvent *event, void *user_data)
} }
iinfo.port_id = ni->port_id; iinfo.port_id = ni->port_id;
iinfo.flags = SPA_INPUT_FLAG_NONE; iinfo.flags = SPA_PORT_INPUT_FLAG_NONE;
iinfo.buffer_id = oinfo.buffer_id; iinfo.buffer_id = oinfo.buffer_id;
if ((res = spa_node_port_push_input (data->mix, 1, &iinfo)) < 0) if ((res = spa_node_port_push_input (data->mix, 1, &iinfo)) < 0)
@ -127,33 +127,33 @@ on_mix_event (SpaNode *node, SpaEvent *event, void *user_data)
} }
static void static void
on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) on_sink_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
{ {
AppData *data = user_data; AppData *data = user_data;
switch (event->type) { switch (event->type) {
case SPA_EVENT_TYPE_NEED_INPUT: case SPA_NODE_EVENT_TYPE_NEED_INPUT:
{ {
SpaInputInfo iinfo; SpaPortInputInfo iinfo;
SpaOutputInfo oinfo; SpaPortOutputInfo oinfo;
SpaResult res; SpaResult res;
SpaEventNeedInput *ni = event->data; SpaNodeEventNeedInput *ni = event->data;
oinfo.port_id = 0; oinfo.port_id = 0;
oinfo.flags = SPA_OUTPUT_FLAG_PULL; oinfo.flags = SPA_PORT_OUTPUT_FLAG_PULL;
if ((res = spa_node_port_pull_output (data->mix, 1, &oinfo)) < 0) if ((res = spa_node_port_pull_output (data->mix, 1, &oinfo)) < 0)
printf ("got error %d\n", res); printf ("got error %d\n", res);
iinfo.port_id = ni->port_id; iinfo.port_id = ni->port_id;
iinfo.flags = SPA_INPUT_FLAG_NONE; iinfo.flags = SPA_PORT_INPUT_FLAG_NONE;
iinfo.buffer_id = oinfo.buffer_id; iinfo.buffer_id = oinfo.buffer_id;
if ((res = spa_node_port_push_input (data->sink, 1, &iinfo)) < 0) if ((res = spa_node_port_push_input (data->sink, 1, &iinfo)) < 0)
printf ("got error %d\n", res); printf ("got error %d\n", res);
break; break;
} }
case SPA_EVENT_TYPE_ADD_POLL: case SPA_NODE_EVENT_TYPE_ADD_POLL:
{ {
SpaPollItem *poll = event->data; SpaPollItem *poll = event->data;
int i; int i;
@ -312,10 +312,10 @@ static void
run_async_sink (AppData *data) run_async_sink (AppData *data)
{ {
SpaResult res; SpaResult res;
SpaCommand cmd; SpaNodeCommand cmd;
int err; int err;
cmd.type = SPA_COMMAND_START; cmd.type = SPA_NODE_COMMAND_START;
if ((res = spa_node_send_command (data->sink, &cmd)) < 0) if ((res = spa_node_send_command (data->sink, &cmd)) < 0)
printf ("got error %d\n", res); printf ("got error %d\n", res);
@ -333,7 +333,7 @@ run_async_sink (AppData *data)
pthread_join (data->thread, NULL); pthread_join (data->thread, NULL);
} }
cmd.type = SPA_COMMAND_PAUSE; cmd.type = SPA_NODE_COMMAND_PAUSE;
if ((res = spa_node_send_command (data->sink, &cmd)) < 0) if ((res = spa_node_send_command (data->sink, &cmd)) < 0)
printf ("got error %d\n", res); printf ("got error %d\n", res);
} }

View file

@ -110,14 +110,14 @@ make_node (SpaNode **node, const char *lib, const char *name)
} }
static void static void
on_source_event (SpaNode *node, SpaEvent *event, void *user_data) on_source_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
{ {
AppData *data = user_data; AppData *data = user_data;
switch (event->type) { switch (event->type) {
case SPA_EVENT_TYPE_HAVE_OUTPUT: case SPA_NODE_EVENT_TYPE_HAVE_OUTPUT:
{ {
SpaOutputInfo info[1] = { 0, }; SpaPortOutputInfo info[1] = { 0, };
SpaResult res; SpaResult res;
SpaBuffer *b; SpaBuffer *b;
void *sdata, *ddata; void *sdata, *ddata;
@ -181,7 +181,7 @@ on_source_event (SpaNode *node, SpaEvent *event, void *user_data)
spa_node_port_reuse_buffer (data->source, 0, info->buffer_id); spa_node_port_reuse_buffer (data->source, 0, info->buffer_id);
break; break;
} }
case SPA_EVENT_TYPE_ADD_POLL: case SPA_NODE_EVENT_TYPE_ADD_POLL:
{ {
SpaPollItem *poll = event->data; SpaPollItem *poll = event->data;
@ -402,11 +402,11 @@ static void
run_async_source (AppData *data) run_async_source (AppData *data)
{ {
SpaResult res; SpaResult res;
SpaCommand cmd; SpaNodeCommand cmd;
bool done = false; bool done = false;
int err; int err;
cmd.type = SPA_COMMAND_START; cmd.type = SPA_NODE_COMMAND_START;
if ((res = spa_node_send_command (data->source, &cmd)) < 0) if ((res = spa_node_send_command (data->source, &cmd)) < 0)
printf ("got error %d\n", res); printf ("got error %d\n", res);
@ -439,7 +439,7 @@ run_async_source (AppData *data)
pthread_join (data->thread, NULL); pthread_join (data->thread, NULL);
} }
cmd.type = SPA_COMMAND_PAUSE; cmd.type = SPA_NODE_COMMAND_PAUSE;
if ((res = spa_node_send_command (data->source, &cmd)) < 0) if ((res = spa_node_send_command (data->source, &cmd)) < 0)
printf ("got error %d\n", res); printf ("got error %d\n", res);
} }