diff --git a/pinos/client/stream.c b/pinos/client/stream.c index c2de0aa39..b0c917657 100644 --- a/pinos/client/stream.c +++ b/pinos/client/stream.c @@ -883,7 +883,6 @@ parse_control (PinosStream *stream, if (spa_control_iter_parse_cmd (&it, &p) < 0) break; - g_debug ("reuse buffer %d", p.buffer_id); if ((bid = find_buffer (stream, p.buffer_id))) { bid->used = FALSE; g_signal_emit (stream, signals[SIGNAL_NEW_BUFFER], 0, p.buffer_id); diff --git a/pinos/gst/gstpinossink.c b/pinos/gst/gstpinossink.c index d24c1fe48..17b8babad 100644 --- a/pinos/gst/gstpinossink.c +++ b/pinos/gst/gstpinossink.c @@ -443,7 +443,6 @@ on_new_buffer (GObject *gobject, } buf = g_hash_table_lookup (pinossink->buf_ids, GINT_TO_POINTER (id)); - g_debug ("recycle buffer %d %p", id, buf); if (buf) { pinos_main_loop_signal (pinossink->loop, FALSE); } diff --git a/pinos/modules/spa/spa-alsa-sink.c b/pinos/modules/spa/spa-alsa-sink.c index 3c5e278f4..7c778b24d 100644 --- a/pinos/modules/spa/spa-alsa-sink.c +++ b/pinos/modules/spa/spa-alsa-sink.c @@ -92,20 +92,20 @@ make_node (SpaNode **node, const char *lib, const char *name) #if 0 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; PinosSpaAlsaSinkPrivate *priv = this->priv; switch (event->type) { - case SPA_EVENT_TYPE_NEED_INPUT: + case SPA_NODE_EVENT_TYPE_NEED_INPUT: { - SpaInputInfo iinfo; + SpaPortInputInfo iinfo; SpaResult res; PinosRingbufferArea areas[2]; uint8_t *data; size_t size, towrite, total; - SpaEventNeedInput *ni = event->data; + SpaNodeEventNeedInput *ni = event->data; size = 0; data = NULL; @@ -127,7 +127,7 @@ on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) pinos_ringbuffer_read_advance (priv->ringbuffer, total); iinfo.port_id = ni->port_id; - iinfo.flags = SPA_INPUT_FLAG_NONE; + iinfo.flags = SPA_PORT_INPUT_FLAG_NONE; iinfo.buffer_id = 0; g_debug ("push sink %d", iinfo.buffer_id); diff --git a/pinos/server/daemon.c b/pinos/server/daemon.c index dfb31e055..7fd8728e4 100644 --- a/pinos/server/daemon.c +++ b/pinos/server/daemon.c @@ -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)); + 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); - pinos_client_add_object (client, G_OBJECT (link)); g_object_unref (link); } diff --git a/pinos/server/link.c b/pinos/server/link.c index f975685b8..26378a01a 100644 --- a/pinos/server/link.c +++ b/pinos/server/link.c @@ -40,19 +40,13 @@ struct _PinosLinkPrivate PinosLink1 *iface; gchar *object_path; - - gboolean active; - gboolean negotiated; - gboolean allocated; - gboolean started; + GPtrArray *format_filter; + PinosProperties *properties; SpaBuffer *in_buffers[16]; unsigned int n_in_buffers; SpaBuffer *out_buffers[16]; unsigned int n_out_buffers; - - GPtrArray *format_filter; - PinosProperties *properties; }; G_DEFINE_TYPE (PinosLink, pinos_link, G_TYPE_OBJECT); @@ -73,8 +67,6 @@ enum enum { SIGNAL_REMOVE, - SIGNAL_ACTIVATE, - SIGNAL_DEACTIVATE, LAST_SIGNAL }; @@ -206,71 +198,89 @@ link_unregister_object (PinosLink *this) } static SpaResult -do_negotiate (PinosLink *this) +do_negotiate (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state) { - PinosLinkPrivate *priv = this->priv; SpaResult res; SpaFormat *filter, *format; void *istate = NULL, *ostate = NULL; - g_debug ("link %p: doing set format", this); - - priv->negotiated = TRUE; - + /* both ports need a format */ + if (in_state == SPA_NODE_STATE_CONFIGURE && out_state == SPA_NODE_STATE_CONFIGURE) { + g_debug ("link %p: doing negotiate format", this); again: - if ((res = spa_node_port_enum_formats (this->input_node->node, - this->input_port, - &filter, - NULL, - &istate)) < 0) { - g_warning ("error input enum formats: %d", res); - 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; + if ((res = spa_node_port_enum_formats (this->input_node->node, + this->input_port, + &filter, + NULL, + &istate)) < 0) { + g_warning ("error input enum formats: %d", res); + goto error; } - g_warning ("error output enum formats: %d", res); - goto error; - } - spa_format_fixate (format); + 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); + 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); - if ((res = spa_node_port_set_format (this->output_node->node, this->output_port, 0, format)) < 0) { - g_warning ("error set format output: %d", res); - goto error; + if (out_state == SPA_NODE_STATE_CONFIGURE) { + if ((res = spa_node_port_set_format (this->output_node->node, this->output_port, 0, format)) < 0) { + 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) { - g_warning ("error set format input: %d", res); - goto error; + if (in_state == SPA_NODE_STATE_CONFIGURE) { + if ((res = spa_node_port_set_format (this->input_node->node, this->input_port, 0, format)) < 0) { + g_warning ("error set format input: %d", res); + goto error; + } } - return SPA_RESULT_OK; error: { - priv->negotiated = FALSE; return res; } } static SpaResult -do_allocation (PinosLink *this) +do_allocation (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state) { PinosLinkPrivate *priv = this->priv; SpaResult res; const SpaPortInfo *iinfo, *oinfo; 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); /* find out what's possible */ 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; } - priv->allocated = TRUE; - spa_debug_port_info (oinfo); spa_debug_port_info (iinfo); @@ -356,49 +364,25 @@ do_allocation (PinosLink *this) error: { - priv->allocated = FALSE; return res; } } static SpaResult -do_start (PinosLink *this) +do_start (PinosLink *this, SpaNodeState in_state, SpaNodeState out_state) { - PinosLinkPrivate *priv = this->priv; - SpaCommand cmd; - SpaResult res; + SpaNodeCommand cmd; + SpaResult res = SPA_RESULT_OK; - if (priv->started) - return SPA_RESULT_OK; - - priv->started = TRUE; - - cmd.type = SPA_COMMAND_START; - 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; -} - -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); + cmd.type = SPA_NODE_COMMAND_START; + if (in_state == SPA_NODE_STATE_PAUSED) { + if ((res = spa_node_send_command (this->input_node->node, &cmd)) < 0) + g_warning ("got error %d", res); + } + if (out_state == SPA_NODE_STATE_PAUSED) { + if ((res = spa_node_send_command (this->output_node->node, &cmd)) < 0) + g_warning ("got error %d", res); + } return res; } @@ -406,7 +390,6 @@ do_pause (PinosLink *this) static SpaResult check_states (PinosLink *this) { - PinosLinkPrivate *priv = this->priv; SpaResult res; 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); - if (in_state == SPA_NODE_STATE_CONFIGURE && - out_state == SPA_NODE_STATE_CONFIGURE && - !priv->negotiated) { - if ((res = do_negotiate (this)) < 0) - return res; - } - if (in_state == SPA_NODE_STATE_READY && - out_state == SPA_NODE_STATE_READY && - !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; - } + if ((res = do_negotiate (this, in_state, out_state)) < 0) + return res; + + if ((res = do_allocation (this, in_state, out_state)) < 0) + return res; + + if ((res = do_start (this, in_state, out_state)) < 0) + return res; + 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, this->input_node, this->input_port); link_register_object (this); + + check_states (this); } static void pinos_link_dispose (GObject * object) { PinosLink *this = PINOS_LINK (object); - PinosLinkPrivate *priv = this->priv; 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->output_node, this); + g_signal_emit (this, signals[SIGNAL_REMOVE], 0, NULL); + g_clear_object (&this->input_node); g_clear_object (&this->output_node); - if (priv->active) { - priv->active = FALSE; - } link_unregister_object (this); G_OBJECT_CLASS (pinos_link_parent_class)->dispose (object); @@ -623,26 +596,6 @@ pinos_link_class_init (PinosLinkClass * klass) G_TYPE_NONE, 0, 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 @@ -685,23 +638,3 @@ pinos_link_get_object_path (PinosLink *this) 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; -} diff --git a/pinos/server/link.h b/pinos/server/link.h index 89b134f5c..f71956c42 100644 --- a/pinos/server/link.h +++ b/pinos/server/link.h @@ -69,9 +69,6 @@ GType pinos_link_get_type (void); 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); const gchar * pinos_link_get_object_path (PinosLink *link); diff --git a/pinos/server/node.c b/pinos/server/node.c index 4b7d322a1..96b21665f 100644 --- a/pinos/server/node.c +++ b/pinos/server/node.c @@ -269,11 +269,11 @@ static void pause_node (PinosNode *this) { SpaResult res; - SpaCommand cmd; + SpaNodeCommand cmd; 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) 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 -on_node_event (SpaNode *node, SpaEvent *event, void *user_data) +on_node_event (SpaNode *node, SpaNodeEvent *event, void *user_data) { PinosNode *this = user_data; PinosNodePrivate *priv = this->priv; 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); - g_signal_emit (this, signals[SIGNAL_PORT_ADDED], 0, get_port_direction (this, pa->port_id), - pa->port_id); + data = g_slice_new (PortData); + 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; } - 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); - 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; } - 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_object_notify (G_OBJECT (this), "node-state"); - if (sc->state == SPA_NODE_STATE_CONFIGURE) { update_port_ids (this, FALSE); } - switch (sc->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; - } + g_object_notify (G_OBJECT (this), "node-state"); break; } - case SPA_EVENT_TYPE_ADD_POLL: + case SPA_NODE_EVENT_TYPE_ADD_POLL: { 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->n_poll++; if (poll->n_fds) @@ -386,7 +400,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data) start_thread (this); break; } - case SPA_EVENT_TYPE_UPDATE_POLL: + case SPA_NODE_EVENT_TYPE_UPDATE_POLL: { unsigned int i; SpaPollItem *poll = event->data; @@ -400,12 +414,12 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data) wakeup_thread (this); break; } - case SPA_EVENT_TYPE_REMOVE_POLL: + case SPA_NODE_EVENT_TYPE_REMOVE_POLL: { SpaPollItem *poll = event->data; 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++) { if (priv->poll[i].id == poll->id) { priv->n_poll--; @@ -422,33 +436,35 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data) } break; } - case SPA_EVENT_TYPE_HAVE_OUTPUT: + case SPA_NODE_EVENT_TYPE_HAVE_OUTPUT: { PinosLink *link; - SpaOutputInfo oinfo[1] = { 0, }; + SpaPortOutputInfo oinfo[1] = { 0, }; 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); + break; + } link = g_hash_table_lookup (priv->links, GUINT_TO_POINTER (oinfo[0].port_id)); if (link) { - SpaInputInfo iinfo[1]; + SpaPortInputInfo iinfo[1]; iinfo[0].port_id = link->input_port; 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) g_warning ("node %p: error pushing buffer: %d, %d", this, res, iinfo[0].status); } break; } - case SPA_EVENT_TYPE_REUSE_BUFFER: + case SPA_NODE_EVENT_TYPE_REUSE_BUFFER: { PinosLink *link; SpaResult res; - SpaEventReuseBuffer *rb = event->data; + SpaNodeEventReuseBuffer *rb = event->data; link = g_hash_table_lookup (priv->links, GUINT_TO_POINTER (rb->port_id)); if (link) { diff --git a/spa/include/spa/event.h b/spa/include/spa/event.h deleted file mode 100644 index eeccb3e6a..000000000 --- a/spa/include/spa/event.h +++ /dev/null @@ -1,104 +0,0 @@ -/* Simple Plugin API - * Copyright (C) 2016 Wim Taymans - * - * 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 -#include -#include - -/** - * 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__ */ diff --git a/spa/include/spa/command.h b/spa/include/spa/node-command.h similarity index 66% rename from spa/include/spa/command.h rename to spa/include/spa/node-command.h index 70206b97b..6678744b2 100644 --- a/spa/include/spa/command.h +++ b/spa/include/spa/node-command.h @@ -17,35 +17,35 @@ * Boston, MA 02110-1301, USA. */ -#ifndef __SPA_COMMAND_H__ -#define __SPA_COMMAND_H__ +#ifndef __SPA_NODE_COMMAND_H__ +#define __SPA_NODE_COMMAND_H__ #ifdef __cplusplus extern "C" { #endif -typedef struct _SpaCommand SpaCommand; +typedef struct _SpaNodeCommand SpaNodeCommand; #include typedef enum { - SPA_COMMAND_INVALID = 0, - SPA_COMMAND_PAUSE, - SPA_COMMAND_START, - SPA_COMMAND_FLUSH, - SPA_COMMAND_DRAIN, - SPA_COMMAND_MARKER, -} SpaCommandType; + SPA_NODE_COMMAND_INVALID = 0, + SPA_NODE_COMMAND_PAUSE, + SPA_NODE_COMMAND_START, + SPA_NODE_COMMAND_FLUSH, + SPA_NODE_COMMAND_DRAIN, + SPA_NODE_COMMAND_MARKER, +} SpaNodeCommandType; -struct _SpaCommand { - SpaCommandType type; - uint32_t port_id; - void *data; - size_t size; +struct _SpaNodeCommand { + SpaNodeCommandType type; + uint32_t port_id; + void *data; + size_t size; }; #ifdef __cplusplus } /* extern "C" */ #endif -#endif /* __SPA_COMMAND_H__ */ +#endif /* __SPA_NODE_COMMAND_H__ */ diff --git a/spa/include/spa/node-event.h b/spa/include/spa/node-event.h new file mode 100644 index 000000000..474266e9a --- /dev/null +++ b/spa/include/spa/node-event.h @@ -0,0 +1,104 @@ +/* Simple Plugin API + * Copyright (C) 2016 Wim Taymans + * + * 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 +#include +#include + +/** + * 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__ */ diff --git a/spa/include/spa/node.h b/spa/include/spa/node.h index 26d168f06..58f35380a 100644 --- a/spa/include/spa/node.h +++ b/spa/include/spa/node.h @@ -49,9 +49,9 @@ typedef enum { #include #include #include -#include +#include +#include #include -#include #include /** @@ -70,15 +70,15 @@ typedef enum { } SpaPortFormatFlags; /** - * SpaInputFlags: + * SpaPortInputFlags: * @SPA_INPUT_FLAG_NONE: no flag */ typedef enum { - SPA_INPUT_FLAG_NONE = 0, -} SpaInputFlags; + SPA_PORT_INPUT_FLAG_NONE = 0, +} SpaPortInputFlags; /** - * SpaInputInfo: + * SpaPortInputInfo: * @port_id: the port id * @flags: extra flags * @buffer_id: a buffer id @@ -87,29 +87,29 @@ typedef enum { * Input information for a node. */ typedef struct { - uint32_t port_id; - SpaInputFlags flags; - uint32_t buffer_id; - SpaResult status; -} SpaInputInfo; + uint32_t port_id; + SpaPortInputFlags flags; + uint32_t buffer_id; + SpaResult status; +} SpaPortInputInfo; /** - * SpaOutputFlags: - * @SPA_OUTPUT_FLAG_NONE: no flag - * @SPA_OUTPUT_FLAG_PULL: force a #SPA_EVENT_NEED_INPUT event on the + * SpaPortOutputFlags: + * @SPA_PORT_OUTPUT_FLAG_NONE: no flag + * @SPA_PORT_OUTPUT_FLAG_PULL: force a #SPA_NODE_EVENT_NEED_INPUT event on the * peer input ports when no data is available. - * @SPA_OUTPUT_FLAG_DISCARD: discard the buffer data - * @SPA_OUTPUT_FLAG_NO_BUFFER: no buffer was produced on the port + * @SPA_PORT_OUTPUT_FLAG_DISCARD: discard the buffer data + * @SPA_PORT_OUTPUT_FLAG_NO_BUFFER: no buffer was produced on the port */ typedef enum { - SPA_OUTPUT_FLAG_NONE = 0, - SPA_OUTPUT_FLAG_PULL = (1 << 0), - SPA_OUTPUT_FLAG_DISCARD = (1 << 1), - SPA_OUTPUT_FLAG_NO_BUFFER = (1 << 2), -} SpaOutputFlags; + SPA_PORT_OUTPUT_FLAG_NONE = 0, + SPA_PORT_OUTPUT_FLAG_PULL = (1 << 0), + SPA_PORT_OUTPUT_FLAG_DISCARD = (1 << 1), + SPA_PORT_OUTPUT_FLAG_NO_BUFFER = (1 << 2), +} SpaPortOutputFlags; /** - * SpaOutputInfo: + * SpaPortOutputInfo: * @port_id: the port id * @flags: extra flags * @buffer_id: a buffer id will be set @@ -119,15 +119,15 @@ typedef enum { * Output information for a node. */ typedef struct { - uint32_t port_id; - SpaOutputFlags flags; - uint32_t buffer_id; - SpaEvent *event; - SpaResult status; -} SpaOutputInfo; + uint32_t port_id; + SpaPortOutputFlags flags; + uint32_t buffer_id; + SpaNodeEvent *event; + SpaResult status; +} SpaPortOutputInfo; /** - * SpaEventCallback: + * SpaNodeCallback: * @node: a #SpaNode emiting the event * @event: the event that was emited * @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 * on @node. */ -typedef void (*SpaEventCallback) (SpaNode *node, - SpaEvent *event, - void *user_data); +typedef void (*SpaNodeEventCallback) (SpaNode *node, + SpaNodeEvent *event, + void *user_data); #define SPA_INTERFACE_ID_NODE 0 #define SPA_INTERFACE_ID_NODE_NAME "Node interface" @@ -205,7 +205,7 @@ struct _SpaNode { /** * SpaNode::send_command: * @node: a #SpaNode - * @command: a #SpaCommand + * @command: a #SpaNodeCommand * * Send a command to @node. * @@ -215,7 +215,7 @@ struct _SpaNode { * #SPA_RESULT_INVALID_COMMAND @command is an invalid command */ SpaResult (*send_command) (SpaNode *node, - SpaCommand *command); + SpaNodeCommand *command); /** * SpaNode::set_event_callback: * @node: a #SpaNode @@ -231,9 +231,9 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL */ - SpaResult (*set_event_callback) (SpaNode *node, - SpaEventCallback callback, - void *user_data); + SpaResult (*set_event_callback) (SpaNode *node, + SpaNodeEventCallback callback, + void *user_data); /** * SpaNode::get_n_ports: * @node: a #SpaNode @@ -450,8 +450,8 @@ struct _SpaNode { /** * SpaNode::port_push_input: * @node: a #SpaNode - * @n_info: number of #SpaInputInfo in @info - * @info: array of #SpaInputInfo + * @n_info: number of #SpaPortInputInfo in @info + * @info: array of #SpaPortInputInfo * * Push a buffer id into one or more input ports of @node. * @@ -464,12 +464,12 @@ struct _SpaNode { */ SpaResult (*port_push_input) (SpaNode *node, unsigned int n_info, - SpaInputInfo *info); + SpaPortInputInfo *info); /** * SpaNode::port_pull_output: * @node: a #SpaNode - * @n_info: number of #SpaOutputInfo in @info - * @info: array of #SpaOutputInfo + * @n_info: number of #SpaPortOutputInfo in @info + * @info: array of #SpaPortOutputInfo * * 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 * because more input is needed. */ - SpaResult (*port_pull_output) (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info); + SpaResult (*port_pull_output) (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info); SpaResult (*port_push_event) (SpaNode *node, uint32_t port_id, - SpaEvent *event); + SpaNodeEvent *event); }; diff --git a/spa/include/spa/poll.h b/spa/include/spa/poll.h index f7e314c73..1aa94be62 100644 --- a/spa/include/spa/poll.h +++ b/spa/include/spa/poll.h @@ -65,8 +65,8 @@ typedef int (*SpaPollNotify) (SpaPollNotifyData *data); * @fds: array of file descriptors to watch * @n_fds: number of elements in @fds * @idle_cb: callback called when there is no other work - * @idle_cb: callback called before starting the poll - * @idle_cb: callback called after the poll loop + * @before_cb: callback called before starting the poll + * @after_cb: callback called after the poll loop * @user_data: user data pass to callbacks */ typedef struct { diff --git a/spa/lib/audio-raw.c b/spa/lib/audio-raw.c index b04d27ac3..7f32c2843 100644 --- a/spa/lib/audio-raw.c +++ b/spa/lib/audio-raw.c @@ -234,7 +234,6 @@ spa_format_audio_init (SpaMediaType type, format->info.raw = default_raw_info; break; } - case SPA_MEDIA_SUBTYPE_MP3: case SPA_MEDIA_SUBTYPE_AAC: case SPA_MEDIA_SUBTYPE_VORBIS: diff --git a/spa/lib/format.c b/spa/lib/format.c index 647817a45..0b572b775 100644 --- a/spa/lib/format.c +++ b/spa/lib/format.c @@ -36,13 +36,18 @@ spa_format_to_string (const SpaFormat *format, char **result) SpaResult spa_format_fixate (SpaFormat *format) { +#if 0 unsigned int i, j; SpaProps *props; uint32_t mask; +#endif if (format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; + format->props.unset_mask = 0; + +#if 0 props = &format->props; mask = props->unset_mask; @@ -75,5 +80,6 @@ spa_format_fixate (SpaFormat *format) } mask >>= 1; } +#endif return SPA_RESULT_OK; } diff --git a/spa/lib/video-raw.c b/spa/lib/video-raw.c index 04aa2cc97..30b8fbe69 100644 --- a/spa/lib/video-raw.c +++ b/spa/lib/video-raw.c @@ -28,8 +28,8 @@ static const SpaVideoInfoRaw default_raw_info = { SPA_VIDEO_FORMAT_UNKNOWN, { 320, 240 }, - { 0, 1 }, - { 0, 1 }, + { 1, 25 }, + { 1, 25 }, 1, SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE, { 1, 1}, diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 6480b91ba..2fce7ff6c 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -79,7 +79,7 @@ struct _SpaALSASink { SpaALSASinkProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; bool have_format; @@ -203,8 +203,8 @@ spa_alsa_sink_node_set_props (SpaNode *node, } static SpaResult -spa_alsa_sink_node_send_command (SpaNode *node, - SpaCommand *command) +spa_alsa_sink_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaALSASink *this; @@ -214,17 +214,17 @@ spa_alsa_sink_node_send_command (SpaNode *node, this = (SpaALSASink *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: spa_alsa_start (this); if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); 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); } break; - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: spa_alsa_stop (this); if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); 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); } break; - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_alsa_sink_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_alsa_sink_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaALSASink *this; @@ -579,9 +579,9 @@ spa_alsa_sink_node_port_get_status (SpaNode *node, } static SpaResult -spa_alsa_sink_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_alsa_sink_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { SpaALSASink *this; unsigned int i; @@ -624,9 +624,9 @@ spa_alsa_sink_node_port_push_input (SpaNode *node, } static SpaResult -spa_alsa_sink_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_alsa_sink_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { return SPA_RESULT_INVALID_PORT; } diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index 2fbdbb8bb..897a14920 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -224,10 +224,10 @@ xrun_recovery (snd_pcm_t *handle, int err) static void pull_input (SpaALSASink *this, void *data, snd_pcm_uframes_t frames) { - SpaEvent event; - SpaEventNeedInput ni; + SpaNodeEvent event; + SpaNodeEventNeedInput ni; - event.type = SPA_EVENT_TYPE_NEED_INPUT; + event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT; event.size = sizeof (ni); event.data = ∋ ni.port_id = 0; @@ -323,7 +323,7 @@ spa_alsa_start (SpaALSASink *this) { SpaALSAState *state = &this->state; int err; - SpaEvent event; + SpaNodeEvent event; if (spa_alsa_open (this) < 0) return -1; @@ -344,7 +344,7 @@ spa_alsa_start (SpaALSASink *this) return err; } - event.type = SPA_EVENT_TYPE_ADD_POLL; + event.type = SPA_NODE_EVENT_TYPE_ADD_POLL; event.data = &state->poll; event.size = sizeof (state->poll); @@ -367,14 +367,14 @@ static int spa_alsa_stop (SpaALSASink *this) { SpaALSAState *state = &this->state; - SpaEvent event; + SpaNodeEvent event; if (!state->opened) return 0; 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.size = sizeof (state->poll); this->event_cb (&this->node, &event, this->user_data); diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index b5076d51b..ff80a1615 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -69,7 +69,7 @@ struct _SpaAudioMixer { SpaAudioMixerProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; int port_count; @@ -132,8 +132,8 @@ spa_audiomixer_node_set_props (SpaNode *node, } static SpaResult -spa_audiomixer_node_send_command (SpaNode *node, - SpaCommand *command) +spa_audiomixer_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaAudioMixer *this; @@ -143,15 +143,15 @@ spa_audiomixer_node_send_command (SpaNode *node, this = (SpaAudioMixer *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = SPA_NODE_STATE_STREAMING; @@ -160,12 +160,12 @@ spa_audiomixer_node_send_command (SpaNode *node, } break; - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = SPA_NODE_STATE_PAUSED; @@ -174,18 +174,18 @@ spa_audiomixer_node_send_command (SpaNode *node, } break; - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_audiomixer_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_audiomixer_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaAudioMixer *this; @@ -496,9 +496,9 @@ spa_audiomixer_node_port_get_status (SpaNode *node, } static SpaResult -spa_audiomixer_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_audiomixer_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { SpaAudioMixer *this; unsigned int i; @@ -562,12 +562,12 @@ spa_audiomixer_node_port_push_input (SpaNode *node, 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; - SpaEventNeedInput ni; + SpaNodeEvent event; + SpaNodeEventNeedInput ni; - event.type = SPA_EVENT_TYPE_NEED_INPUT; + event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT; event.size = sizeof (ni); event.data = ∋ ni.port_id = port_id; @@ -628,7 +628,7 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port) } static SpaResult -mix_data (SpaAudioMixer *this, SpaOutputInfo *info) +mix_data (SpaAudioMixer *this, SpaPortOutputInfo *info) { int i, min_size, min_port, pull_size; SpaBuffer *buf; @@ -645,7 +645,7 @@ mix_data (SpaAudioMixer *this, SpaOutputInfo *info) continue; 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); } if (this->ports[i].buffer == NULL) @@ -676,9 +676,9 @@ mix_data (SpaAudioMixer *this, SpaOutputInfo *info) } static SpaResult -spa_audiomixer_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_audiomixer_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { SpaAudioMixer *this; SpaAudioMixerPort *port; @@ -715,9 +715,9 @@ spa_audiomixer_node_port_pull_output (SpaNode *node, } static SpaResult -spa_audiomixer_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_audiomixer_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { return SPA_RESULT_NOT_IMPLEMENTED; } diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index feb35d6cb..66a602929 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -53,7 +53,7 @@ struct _SpaAudioTestSrc { SpaAudioTestSrcProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; SpaPollItem idle; @@ -185,11 +185,11 @@ spa_audiotestsrc_node_set_props (SpaNode *node, static SpaResult send_have_output (SpaAudioTestSrc *this) { - SpaEvent event; - SpaEventHaveOutput ho; + SpaNodeEvent event; + SpaNodeEventHaveOutput ho; if (this->event_cb) { - event.type = SPA_EVENT_TYPE_HAVE_OUTPUT; + event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT; event.size = sizeof (ho); event.data = &ho; ho.port_id = 0; @@ -202,8 +202,8 @@ send_have_output (SpaAudioTestSrc *this) static void update_state (SpaAudioTestSrc *this, SpaNodeState state) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; if (this->node.state == state) return; @@ -211,7 +211,7 @@ update_state (SpaAudioTestSrc *this, SpaNodeState state) this->node.state = state; if (this->event_cb) { - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = state; @@ -222,11 +222,11 @@ update_state (SpaAudioTestSrc *this, SpaNodeState state) static SpaResult update_idle_enabled (SpaAudioTestSrc *this, bool enabled) { - SpaEvent event; + SpaNodeEvent event; if (this->event_cb) { this->idle.enabled = enabled; - event.type = SPA_EVENT_TYPE_UPDATE_POLL; + event.type = SPA_NODE_EVENT_TYPE_UPDATE_POLL; event.data = &this->idle; event.size = sizeof (this->idle); this->event_cb (&this->node, &event, this->user_data); @@ -235,8 +235,8 @@ update_idle_enabled (SpaAudioTestSrc *this, bool enabled) } static SpaResult -spa_audiotestsrc_node_send_command (SpaNode *node, - SpaCommand *command) +spa_audiotestsrc_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaAudioTestSrc *this; @@ -246,10 +246,10 @@ spa_audiotestsrc_node_send_command (SpaNode *node, this = (SpaAudioTestSrc *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: { if (!this->have_format) return SPA_RESULT_NO_FORMAT; @@ -262,7 +262,7 @@ spa_audiotestsrc_node_send_command (SpaNode *node, update_state (this, SPA_NODE_STATE_STREAMING); break; } - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: { if (!this->have_format) return SPA_RESULT_NO_FORMAT; @@ -275,21 +275,21 @@ spa_audiotestsrc_node_send_command (SpaNode *node, update_state (this, SPA_NODE_STATE_PAUSED); break; } - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_audiotestsrc_node_set_event_callback (SpaNode *node, - SpaEventCallback event_cb, - void *user_data) +spa_audiotestsrc_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event_cb, + void *user_data) { SpaAudioTestSrc *this; - SpaEvent event; + SpaNodeEvent event; if (node == NULL || node->handle == NULL) return SPA_RESULT_INVALID_ARGUMENTS; @@ -297,7 +297,7 @@ spa_audiotestsrc_node_set_event_callback (SpaNode *node, this = (SpaAudioTestSrc *) node->handle; 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.size = sizeof (this->idle); 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; if (this->event_cb) { - event.type = SPA_EVENT_TYPE_ADD_POLL; + event.type = SPA_NODE_EVENT_TYPE_ADD_POLL; event.data = &this->idle; event.size = sizeof (this->idle); this->event_cb (&this->node, &event, this->user_data); @@ -663,9 +663,9 @@ spa_audiotestsrc_node_port_get_status (SpaNode *node, static SpaResult -spa_audiotestsrc_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_audiotestsrc_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { return SPA_RESULT_INVALID_PORT; } @@ -707,9 +707,9 @@ audiotestsrc_idle (SpaPollNotifyData *data) } static SpaResult -spa_audiotestsrc_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_audiotestsrc_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { SpaAudioTestSrc *this; unsigned int i; @@ -755,9 +755,9 @@ spa_audiotestsrc_node_port_pull_output (SpaNode *node, } static SpaResult -spa_audiotestsrc_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_audiotestsrc_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { return SPA_RESULT_NOT_IMPLEMENTED; } diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index c25a605a6..be8eb7ced 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -71,7 +71,7 @@ struct _SpaFFMpegDec { SpaFFMpegDecProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; SpaFFMpegState state[2]; @@ -128,8 +128,8 @@ spa_ffmpeg_dec_node_set_props (SpaNode *node, } static SpaResult -spa_ffmpeg_dec_node_send_command (SpaNode *node, - SpaCommand *command) +spa_ffmpeg_dec_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaFFMpegDec *this; @@ -139,15 +139,15 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node, this = (SpaFFMpegDec *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); 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); } break; - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = SPA_NODE_STATE_PAUSED; @@ -169,18 +169,18 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node, } break; - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_ffmpeg_dec_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_ffmpeg_dec_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaFFMpegDec *this; @@ -447,17 +447,17 @@ spa_ffmpeg_dec_node_port_get_status (SpaNode *node, } static SpaResult -spa_ffmpeg_dec_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_ffmpeg_dec_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { return SPA_RESULT_INVALID_PORT; } static SpaResult -spa_ffmpeg_dec_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_ffmpeg_dec_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { SpaFFMpegDec *this; SpaFFMpegState *state; @@ -491,9 +491,9 @@ spa_ffmpeg_dec_node_port_pull_output (SpaNode *node, } static SpaResult -spa_ffmpeg_dec_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_ffmpeg_dec_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { return SPA_RESULT_NOT_IMPLEMENTED; } diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index 3fc0e551f..de73585b0 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -71,7 +71,7 @@ struct _SpaFFMpegEnc { SpaFFMpegEncProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; SpaFFMpegState state[2]; @@ -128,8 +128,8 @@ spa_ffmpeg_enc_node_set_props (SpaNode *node, } static SpaResult -spa_ffmpeg_enc_node_send_command (SpaNode *node, - SpaCommand *command) +spa_ffmpeg_enc_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaFFMpegEnc *this; @@ -139,15 +139,15 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node, this = (SpaFFMpegEnc *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); 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); } break; - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = SPA_NODE_STATE_PAUSED; @@ -169,18 +169,18 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node, } break; - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_ffmpeg_enc_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_ffmpeg_enc_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaFFMpegEnc *this; @@ -450,17 +450,17 @@ spa_ffmpeg_enc_node_port_get_status (SpaNode *node, } static SpaResult -spa_ffmpeg_enc_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_ffmpeg_enc_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { return SPA_RESULT_INVALID_PORT; } static SpaResult -spa_ffmpeg_enc_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_ffmpeg_enc_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { SpaFFMpegEnc *this; SpaFFMpegState *state; @@ -495,9 +495,9 @@ spa_ffmpeg_enc_node_port_pull_output (SpaNode *node, } static SpaResult -spa_ffmpeg_enc_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_ffmpeg_enc_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { return SPA_RESULT_NOT_IMPLEMENTED; } diff --git a/spa/plugins/libva/libva-dec.c b/spa/plugins/libva/libva-dec.c index 6ab3e69e1..ef7dd2864 100644 --- a/spa/plugins/libva/libva-dec.c +++ b/spa/plugins/libva/libva-dec.c @@ -70,7 +70,7 @@ struct _SpaLibvaDec { SpaLibvaDecProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; SpaLibvaState state[2]; @@ -136,11 +136,11 @@ spa_libva_dec_node_send_command (SpaHandle *handle, case SPA_COMMAND_START: if (this->event_cb) { - SpaEvent event; + SpaNodeEvent event; event.refcount = 1; event.notify = NULL; - event.type = SPA_EVENT_TYPE_STARTED; + event.type = SPA_NODE_EVENT_TYPE_STARTED; event.port_id = -1; event.data = NULL; event.size = 0; @@ -150,11 +150,11 @@ spa_libva_dec_node_send_command (SpaHandle *handle, break; case SPA_COMMAND_STOP: if (this->event_cb) { - SpaEvent event; + SpaNodeEvent event; event.refcount = 1; event.notify = NULL; - event.type = SPA_EVENT_TYPE_STOPPED; + event.type = SPA_NODE_EVENT_TYPE_STOPPED; event.port_id = -1; event.data = NULL; event.size = 0; @@ -172,9 +172,9 @@ spa_libva_dec_node_send_command (SpaHandle *handle, } static SpaResult -spa_libva_dec_node_set_event_callback (SpaHandle *handle, - SpaEventCallback event, - void *user_data) +spa_libva_dec_node_set_event_callback (SpaHandle *handle, + SpaNodeEventCallback event, + void *user_data) { SpaLibvaDec *this = (SpaLibvaDec *) handle; diff --git a/spa/plugins/remote/proxy.c b/spa/plugins/remote/proxy.c index ef781fed3..a490f1ecd 100644 --- a/spa/plugins/remote/proxy.c +++ b/spa/plugins/remote/proxy.c @@ -67,7 +67,7 @@ struct _SpaProxy { SpaProxyProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; SpaPollFd fds[1]; @@ -104,13 +104,13 @@ reset_proxy_props (SpaProxyProps *props) static void update_poll (SpaProxy *this, int socketfd) { - SpaEvent event; + SpaNodeEvent event; SpaProxyProps *p; p = &this->props[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.size = sizeof (this->poll); this->event_cb (&this->node, &event, this->user_data); @@ -119,7 +119,7 @@ update_poll (SpaProxy *this, int socketfd) if (p->socketfd != -1) { 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.size = sizeof (this->poll); this->event_cb (&this->node, &event, this->user_data); @@ -130,12 +130,12 @@ static SpaResult update_state (SpaProxy *this, SpaNodeState state) { if (this->node.state != state) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; this->node.state = state; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = state; @@ -196,8 +196,8 @@ spa_proxy_node_set_props (SpaNode *node, } static SpaResult -spa_proxy_node_send_command (SpaNode *node, - SpaCommand *command) +spa_proxy_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaProxy *this; SpaResult res; @@ -208,10 +208,10 @@ spa_proxy_node_send_command (SpaNode *node, this = (SpaProxy *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: { SpaControlBuilder builder; SpaControl control; @@ -229,7 +229,7 @@ spa_proxy_node_send_command (SpaNode *node, break; } - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: { SpaControlBuilder builder; SpaControl control; @@ -247,18 +247,18 @@ spa_proxy_node_send_command (SpaNode *node, break; } - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_proxy_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_proxy_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaProxy *this; @@ -332,9 +332,9 @@ static void do_update_port (SpaProxy *this, SpaControlCmdPortUpdate *pu) { - SpaEvent event; + SpaNodeEvent event; SpaProxyPort *port; - SpaEventPortAdded pa; + SpaNodeEventPortAdded pa; unsigned int i; port = &this->ports[pu->port_id]; @@ -364,7 +364,7 @@ do_update_port (SpaProxy *this, else this->n_outputs++; - event.type = SPA_EVENT_TYPE_PORT_ADDED; + event.type = SPA_NODE_EVENT_TYPE_PORT_ADDED; event.size = sizeof (pa); event.data = &pa; pa.port_id = pu->port_id; @@ -376,9 +376,9 @@ static void do_uninit_port (SpaProxy *this, uint32_t port_id) { - SpaEvent event; + SpaNodeEvent event; SpaProxyPort *port; - SpaEventPortRemoved pr; + SpaNodeEventPortRemoved pr; fprintf (stderr, "proxy %p: removing port %d\n", this, port_id); port = &this->ports[port_id]; @@ -393,7 +393,7 @@ do_uninit_port (SpaProxy *this, spa_format_unref (port->format); port->format = NULL; - event.type = SPA_EVENT_TYPE_PORT_REMOVED; + event.type = SPA_NODE_EVENT_TYPE_PORT_REMOVED; event.size = sizeof (pr); event.data = ≺ pr.port_id = port_id; @@ -755,13 +755,40 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node, uint32_t port_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 -spa_proxy_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_proxy_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { SpaProxy *this; SpaProxyPort *port; @@ -826,9 +853,9 @@ spa_proxy_node_port_push_input (SpaNode *node, } static SpaResult -spa_proxy_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_proxy_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { SpaProxy *this; SpaProxyPort *port; @@ -868,9 +895,9 @@ spa_proxy_node_port_pull_output (SpaNode *node, } static SpaResult -spa_proxy_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_proxy_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { SpaProxy *this; SpaResult res; @@ -881,9 +908,9 @@ spa_proxy_node_port_push_event (SpaNode *node, this = (SpaProxy *) node->handle; 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; SpaControlBuilder builder; SpaControl control; @@ -990,14 +1017,14 @@ parse_control (SpaProxy *this, } case SPA_CONTROL_CMD_HAVE_OUTPUT: { - SpaEvent event; - SpaEventHaveOutput hu; + SpaNodeEvent event; + SpaNodeEventHaveOutput hu; SpaControlCmdHaveOutput cmd; if (spa_control_iter_parse_cmd (&it, &cmd) < 0) break; - event.type = SPA_EVENT_TYPE_HAVE_OUTPUT; + event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT; event.data = &hu; event.size = sizeof (hu); hu.port_id = cmd.port_id; @@ -1026,14 +1053,14 @@ parse_control (SpaProxy *this, } case SPA_CONTROL_CMD_REUSE_BUFFER: { - SpaEvent event; - SpaEventReuseBuffer rb; + SpaNodeEvent event; + SpaNodeEventReuseBuffer rb; SpaControlCmdReuseBuffer crb; if (spa_control_iter_parse_cmd (&it, &crb) < 0) break; - event.type = SPA_EVENT_TYPE_REUSE_BUFFER; + event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER; event.data = &rb; event.size = sizeof (rb); rb.port_id = crb.port_id; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 0bee4adc1..58dbc0902 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -123,12 +123,30 @@ struct _SpaV4l2Source { SpaV4l2SourceProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; 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 = ≻ + event.size = sizeof (sc); + sc.state = state; + this->event_cb (&this->node, &event, this->user_data); +} #include "v4l2-utils.c" enum { @@ -201,27 +219,9 @@ spa_v4l2_source_node_set_props (SpaNode *node, 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 = ≻ - event.size = sizeof (sc); - sc.state = state; - this->event_cb (&this->node, &event, this->user_data); -} - static SpaResult -spa_v4l2_source_node_send_command (SpaNode *node, - SpaCommand *command) +spa_v4l2_source_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaV4l2Source *this; SpaResult res; @@ -232,10 +232,10 @@ spa_v4l2_source_node_send_command (SpaNode *node, this = (SpaV4l2Source *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: { SpaV4l2State *state = &this->state[0]; @@ -248,10 +248,9 @@ spa_v4l2_source_node_send_command (SpaNode *node, if ((res = spa_v4l2_start (this)) < 0) return res; - update_state (this, SPA_NODE_STATE_STREAMING); break; } - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: { SpaV4l2State *state = &this->state[0]; @@ -264,22 +263,21 @@ spa_v4l2_source_node_send_command (SpaNode *node, if ((res = spa_v4l2_pause (this)) < 0) return res; - update_state (this, SPA_NODE_STATE_PAUSED); break; } - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_v4l2_source_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_v4l2_source_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaV4l2Source *this; @@ -647,17 +645,17 @@ spa_v4l2_source_node_port_get_status (SpaNode *node, } static SpaResult -spa_v4l2_source_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_v4l2_source_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { return SPA_RESULT_INVALID_PORT; } static SpaResult -spa_v4l2_source_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_v4l2_source_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { SpaV4l2Source *this; SpaV4l2State *state; @@ -706,9 +704,9 @@ spa_v4l2_source_node_port_pull_output (SpaNode *node, } static SpaResult -spa_v4l2_source_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_v4l2_source_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { return SPA_RESULT_NOT_IMPLEMENTED; } diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 6ddede5e7..7e8534296 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -450,9 +450,8 @@ again: i = ++state->frmival.index; } fmt->infos[pi].n_range_values = i; - if (i == 1) { - fmt->framerate = fmt->framerates[0]; - } else { + fmt->framerate = fmt->framerates[0]; + if (i > 1) { SPA_PROPS_INDEX_UNSET (&fmt->fmt.props, pi); } pi = ++fmt->fmt.props.n_prop_info; @@ -561,10 +560,11 @@ mmap_read (SpaV4l2Source *this) if (xioctl (state->fd, VIDIOC_DQBUF, &buf) < 0) { switch (errno) { case EAGAIN: - return 0; + return SPA_RESULT_ERROR; case EIO: default: perror ("VIDIOC_DQBUF"); + usleep (50 * 1000); return SPA_RESULT_ERROR; } } @@ -583,13 +583,13 @@ static int v4l2_on_fd_events (SpaPollNotifyData *data) { SpaV4l2Source *this = data->user_data; - SpaEvent event; - SpaEventHaveOutput ho; + SpaNodeEvent event; + SpaNodeEventHaveOutput ho; if (mmap_read (this) < 0) return 0; - event.type = SPA_EVENT_TYPE_HAVE_OUTPUT; + event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT; event.size = sizeof (ho); event.data = &ho; ho.port_id = 0; @@ -849,7 +849,7 @@ spa_v4l2_start (SpaV4l2Source *this) { SpaV4l2State *state = &this->state[0]; enum v4l2_buf_type type; - SpaEvent event; + SpaNodeEvent event; if (state->started) return SPA_RESULT_OK; @@ -859,8 +859,10 @@ spa_v4l2_start (SpaV4l2Source *this) perror ("VIDIOC_STREAMON"); 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.size = sizeof (state->poll); @@ -878,8 +880,6 @@ spa_v4l2_start (SpaV4l2Source *this) state->poll.user_data = this; this->event_cb (&this->node, &event, this->user_data); - state->started = true; - return SPA_RESULT_OK; } @@ -888,12 +888,12 @@ spa_v4l2_pause (SpaV4l2Source *this) { SpaV4l2State *state = &this->state[0]; enum v4l2_buf_type type; - SpaEvent event; + SpaNodeEvent event; if (!state->started) return SPA_RESULT_OK; - event.type = SPA_EVENT_TYPE_REMOVE_POLL; + event.type = SPA_NODE_EVENT_TYPE_REMOVE_POLL; event.data = &state->poll; event.size = sizeof (state->poll); this->event_cb (&this->node, &event, this->user_data); @@ -905,6 +905,7 @@ spa_v4l2_pause (SpaV4l2Source *this) perror ("VIDIOC_STREAMOFF"); return SPA_RESULT_ERROR; } + update_state (this, SPA_NODE_STATE_PAUSED); return SPA_RESULT_OK; } diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 1728c53a8..686341523 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -47,7 +47,7 @@ struct _SpaVolume { SpaVolumeProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; bool have_format; @@ -137,8 +137,8 @@ spa_volume_node_set_props (SpaNode *node, } static SpaResult -spa_volume_node_send_command (SpaNode *node, - SpaCommand *command) +spa_volume_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaVolume *this; @@ -148,15 +148,15 @@ spa_volume_node_send_command (SpaNode *node, this = (SpaVolume *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = SPA_NODE_STATE_STREAMING; @@ -165,12 +165,12 @@ spa_volume_node_send_command (SpaNode *node, } break; - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = SPA_NODE_STATE_PAUSED; @@ -179,18 +179,18 @@ spa_volume_node_send_command (SpaNode *node, } break; - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_volume_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_volume_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaVolume *this; @@ -448,9 +448,9 @@ spa_volume_node_port_get_status (SpaNode *node, static SpaResult -spa_volume_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_volume_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { SpaVolume *this; unsigned int i; @@ -517,10 +517,10 @@ find_free_buffer (SpaVolume *this, SpaVolumePort *port) static void release_buffer (SpaVolume *this, SpaBuffer *buffer) { - SpaEvent event; - SpaEventReuseBuffer rb; + SpaNodeEvent event; + SpaNodeEventReuseBuffer rb; - event.type = SPA_EVENT_TYPE_REUSE_BUFFER; + event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER; event.data = &rb; event.size = sizeof (rb); rb.port_id = 0; @@ -529,9 +529,9 @@ release_buffer (SpaVolume *this, SpaBuffer *buffer) } static SpaResult -spa_volume_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_volume_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { SpaVolume *this; SpaVolumePort *port; @@ -610,9 +610,9 @@ spa_volume_node_port_pull_output (SpaNode *node, } static SpaResult -spa_volume_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_volume_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { return SPA_RESULT_NOT_IMPLEMENTED; } diff --git a/spa/plugins/xv/xv-sink.c b/spa/plugins/xv/xv-sink.c index 8305dd564..052bed829 100644 --- a/spa/plugins/xv/xv-sink.c +++ b/spa/plugins/xv/xv-sink.c @@ -73,7 +73,7 @@ struct _SpaXvSink { SpaXvSinkProps props[2]; - SpaEventCallback event_cb; + SpaNodeEventCallback event_cb; void *user_data; SpaFormatVideo format[2]; @@ -159,8 +159,8 @@ spa_xv_sink_node_set_props (SpaNode *node, } static SpaResult -spa_xv_sink_node_send_command (SpaNode *node, - SpaCommand *command) +spa_xv_sink_node_send_command (SpaNode *node, + SpaNodeCommand *command) { SpaXvSink *this; @@ -170,17 +170,17 @@ spa_xv_sink_node_send_command (SpaNode *node, this = (SpaXvSink *) node->handle; switch (command->type) { - case SPA_COMMAND_INVALID: + case SPA_NODE_COMMAND_INVALID: return SPA_RESULT_INVALID_COMMAND; - case SPA_COMMAND_START: + case SPA_NODE_COMMAND_START: spa_xv_start (this); if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); 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); } break; - case SPA_COMMAND_PAUSE: + case SPA_NODE_COMMAND_PAUSE: spa_xv_stop (this); if (this->event_cb) { - SpaEvent event; - SpaEventStateChange sc; + SpaNodeEvent event; + SpaNodeEventStateChange sc; - event.type = SPA_EVENT_TYPE_STATE_CHANGE; + event.type = SPA_NODE_EVENT_TYPE_STATE_CHANGE; event.data = ≻ event.size = sizeof (sc); sc.state = SPA_NODE_STATE_PAUSED; @@ -204,18 +204,18 @@ spa_xv_sink_node_send_command (SpaNode *node, } break; - case SPA_COMMAND_FLUSH: - case SPA_COMMAND_DRAIN: - case SPA_COMMAND_MARKER: + case SPA_NODE_COMMAND_FLUSH: + case SPA_NODE_COMMAND_DRAIN: + case SPA_NODE_COMMAND_MARKER: return SPA_RESULT_NOT_IMPLEMENTED; } return SPA_RESULT_OK; } static SpaResult -spa_xv_sink_node_set_event_callback (SpaNode *node, - SpaEventCallback event, - void *user_data) +spa_xv_sink_node_set_event_callback (SpaNode *node, + SpaNodeEventCallback event, + void *user_data) { SpaXvSink *this; @@ -474,25 +474,25 @@ spa_xv_sink_node_port_get_status (SpaNode *node, } static SpaResult -spa_xv_sink_node_port_push_input (SpaNode *node, - unsigned int n_info, - SpaInputInfo *info) +spa_xv_sink_node_port_push_input (SpaNode *node, + unsigned int n_info, + SpaPortInputInfo *info) { return SPA_RESULT_NOT_IMPLEMENTED; } static SpaResult -spa_xv_sink_node_port_pull_output (SpaNode *node, - unsigned int n_info, - SpaOutputInfo *info) +spa_xv_sink_node_port_pull_output (SpaNode *node, + unsigned int n_info, + SpaPortOutputInfo *info) { return SPA_RESULT_INVALID_PORT; } static SpaResult -spa_xv_sink_node_port_push_event (SpaNode *node, - uint32_t port_id, - SpaEvent *event) +spa_xv_sink_node_port_push_event (SpaNode *node, + uint32_t port_id, + SpaNodeEvent *event) { return SPA_RESULT_NOT_IMPLEMENTED; } diff --git a/spa/tests/test-mixer.c b/spa/tests/test-mixer.c index e12814c56..9094fca6f 100644 --- a/spa/tests/test-mixer.c +++ b/spa/tests/test-mixer.c @@ -89,20 +89,20 @@ make_node (SpaNode **node, const char *lib, const char *name) } 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; switch (event->type) { - case SPA_EVENT_TYPE_NEED_INPUT: + case SPA_NODE_EVENT_TYPE_NEED_INPUT: { - SpaInputInfo iinfo; - SpaOutputInfo oinfo; + SpaPortInputInfo iinfo; + SpaPortOutputInfo oinfo; SpaResult res; - SpaEventNeedInput *ni = event->data; + SpaNodeEventNeedInput *ni = event->data; 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 ((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.flags = SPA_INPUT_FLAG_NONE; + iinfo.flags = SPA_PORT_INPUT_FLAG_NONE; iinfo.buffer_id = oinfo.buffer_id; 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 -on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) +on_sink_event (SpaNode *node, SpaNodeEvent *event, void *user_data) { AppData *data = user_data; switch (event->type) { - case SPA_EVENT_TYPE_NEED_INPUT: + case SPA_NODE_EVENT_TYPE_NEED_INPUT: { - SpaInputInfo iinfo; - SpaOutputInfo oinfo; + SpaPortInputInfo iinfo; + SpaPortOutputInfo oinfo; SpaResult res; - SpaEventNeedInput *ni = event->data; + SpaNodeEventNeedInput *ni = event->data; 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) printf ("got error %d\n", res); 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; if ((res = spa_node_port_push_input (data->sink, 1, &iinfo)) < 0) printf ("got error %d\n", res); break; } - case SPA_EVENT_TYPE_ADD_POLL: + case SPA_NODE_EVENT_TYPE_ADD_POLL: { SpaPollItem *poll = event->data; int i; @@ -312,10 +312,10 @@ static void run_async_sink (AppData *data) { SpaResult res; - SpaCommand cmd; + SpaNodeCommand cmd; int err; - cmd.type = SPA_COMMAND_START; + cmd.type = SPA_NODE_COMMAND_START; if ((res = spa_node_send_command (data->sink, &cmd)) < 0) printf ("got error %d\n", res); @@ -333,7 +333,7 @@ run_async_sink (AppData *data) 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) printf ("got error %d\n", res); } diff --git a/spa/tests/test-v4l2.c b/spa/tests/test-v4l2.c index b1f1d0428..fcf67738c 100644 --- a/spa/tests/test-v4l2.c +++ b/spa/tests/test-v4l2.c @@ -110,14 +110,14 @@ make_node (SpaNode **node, const char *lib, const char *name) } 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; 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; SpaBuffer *b; 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); break; } - case SPA_EVENT_TYPE_ADD_POLL: + case SPA_NODE_EVENT_TYPE_ADD_POLL: { SpaPollItem *poll = event->data; @@ -402,11 +402,11 @@ static void run_async_source (AppData *data) { SpaResult res; - SpaCommand cmd; + SpaNodeCommand cmd; bool done = false; int err; - cmd.type = SPA_COMMAND_START; + cmd.type = SPA_NODE_COMMAND_START; if ((res = spa_node_send_command (data->source, &cmd)) < 0) printf ("got error %d\n", res); @@ -439,7 +439,7 @@ run_async_source (AppData *data) 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) printf ("got error %d\n", res); }