summaryrefslogtreecommitdiff
path: root/spa
diff options
context:
space:
mode:
Diffstat (limited to 'spa')
-rw-r--r--spa/include/spa/monitor.h40
-rw-r--r--spa/include/spa/node-command.h20
-rw-r--r--spa/include/spa/node-event.h6
-rw-r--r--spa/include/spa/poll.h2
-rw-r--r--spa/plugins/alsa/alsa-monitor.c15
-rw-r--r--spa/plugins/alsa/alsa-utils.c16
-rw-r--r--spa/plugins/audiomixer/audiomixer.c8
-rw-r--r--spa/plugins/audiotestsrc/audiotestsrc.c8
-rw-r--r--spa/plugins/v4l2/v4l2-monitor.c16
-rw-r--r--spa/plugins/v4l2/v4l2-source.c60
-rw-r--r--spa/plugins/v4l2/v4l2-utils.c8
-rw-r--r--spa/plugins/videotestsrc/videotestsrc.c8
-rw-r--r--spa/plugins/volume/volume.c8
-rw-r--r--spa/tests/test-mixer.c4
-rw-r--r--spa/tools/spa-monitor.c6
15 files changed, 112 insertions, 113 deletions
diff --git a/spa/include/spa/monitor.h b/spa/include/spa/monitor.h
index bac7aecd..6c04c774 100644
--- a/spa/include/spa/monitor.h
+++ b/spa/include/spa/monitor.h
@@ -33,6 +33,25 @@ typedef struct _SpaMonitor SpaMonitor;
#include <spa/dict.h>
#include <spa/plugin.h>
+/**
+ * SpaMonitorEventType:
+ * @SPA_MONITOR_EVENT_TYPE_INVALID: invalid event
+ * @SPA_MONITOR_EVENT_TYPE_ADDED: an item was added, data points to #SpaMonitorItem
+ * @SPA_MONITOR_EVENT_TYPE_REMOVED: an item was removed, data points to #SpaMonitorItem
+ * @SPA_MONITOR_EVENT_TYPE_CHANGED: an item was changed, data points to #SpaMonitorItem
+ */
+typedef enum {
+ SPA_MONITOR_EVENT_TYPE_INVALID = 0,
+ SPA_MONITOR_EVENT_TYPE_ADDED,
+ SPA_MONITOR_EVENT_TYPE_REMOVED,
+ SPA_MONITOR_EVENT_TYPE_CHANGED,
+} SpaMonitorEventType;
+
+typedef struct {
+ SpaMonitorEventType type;
+ size_t size;
+} SpaMonitorEvent;
+
typedef enum {
SPA_MONITOR_ITEM_FLAG_NONE = 0,
} SpaMonitorItemFlags;
@@ -50,6 +69,7 @@ typedef enum {
} SpaMonitorItemState;
typedef struct {
+ SpaMonitorEvent event;
const char *id;
SpaMonitorItemFlags flags;
SpaMonitorItemState state;
@@ -60,26 +80,6 @@ typedef struct {
} SpaMonitorItem;
/**
- * SpaMonitorEventType:
- * @SPA_MONITOR_EVENT_TYPE_INVALID: invalid event
- * @SPA_MONITOR_EVENT_TYPE_ADDED: an item was added, data points to #SpaMonitorItem
- * @SPA_MONITOR_EVENT_TYPE_REMOVED: an item was removed, data points to #SpaMonitorItem
- * @SPA_MONITOR_EVENT_TYPE_CHANGED: an item was changed, data points to #SpaMonitorItem
- */
-typedef enum {
- SPA_MONITOR_EVENT_TYPE_INVALID = 0,
- SPA_MONITOR_EVENT_TYPE_ADDED,
- SPA_MONITOR_EVENT_TYPE_REMOVED,
- SPA_MONITOR_EVENT_TYPE_CHANGED,
-} SpaMonitorEventType;
-
-typedef struct {
- SpaMonitorEventType type;
- void *data;
- size_t size;
-} SpaMonitorEvent;
-
-/**
* SpaMonitorCallback:
* @node: a #SpaMonitor emiting the event
* @event: the event that was emited
diff --git a/spa/include/spa/node-command.h b/spa/include/spa/node-command.h
index c9e728e6..77d243de 100644
--- a/spa/include/spa/node-command.h
+++ b/spa/include/spa/node-command.h
@@ -51,7 +51,6 @@ typedef enum {
struct _SpaNodeCommand {
SpaNodeCommandType type;
- void *data;
size_t size;
};
@@ -68,20 +67,21 @@ struct _SpaNodeCommand {
* @state: the new clock state, when @change_mask = 1<<2
*/
typedef struct {
+ SpaNodeCommand command;
#define SPA_NODE_COMMAND_CLOCK_UPDATE_TIME (1 << 0)
#define SPA_NODE_COMMAND_CLOCK_UPDATE_SCALE (1 << 1)
#define SPA_NODE_COMMAND_CLOCK_UPDATE_STATE (1 << 2)
#define SPA_NODE_COMMAND_CLOCK_UPDATE_LATENCY (1 << 3)
- uint32_t change_mask;
- int32_t rate;
- int64_t ticks;
- int64_t monotonic_time;
- int64_t offset;
- int32_t scale;
- SpaClockState state;
+ uint32_t change_mask;
+ int32_t rate;
+ int64_t ticks;
+ int64_t monotonic_time;
+ int64_t offset;
+ int32_t scale;
+ SpaClockState state;
#define SPA_NODE_COMMAND_CLOCK_UPDATE_FLAG_LIVE (1 << 0)
- uint32_t flags;
- int64_t latency;
+ uint32_t flags;
+ int64_t latency;
} SpaNodeCommandClockUpdate;
#ifdef __cplusplus
diff --git a/spa/include/spa/node-event.h b/spa/include/spa/node-event.h
index 9a4bf7d1..090a00d4 100644
--- a/spa/include/spa/node-event.h
+++ b/spa/include/spa/node-event.h
@@ -68,29 +68,33 @@ typedef enum {
struct _SpaNodeEvent {
SpaNodeEventType type;
- void *data;
size_t size;
};
typedef struct {
+ SpaNodeEvent event;
uint32_t seq;
SpaResult res;
} SpaNodeEventAsyncComplete;
typedef struct {
+ SpaNodeEvent event;
uint32_t port_id;
} SpaNodeEventHaveOutput;
typedef struct {
+ SpaNodeEvent event;
uint32_t port_id;
} SpaNodeEventNeedInput;
typedef struct {
+ SpaNodeEvent event;
uint32_t port_id;
uint32_t buffer_id;
} SpaNodeEventReuseBuffer;
typedef struct {
+ SpaNodeEvent event;
#define SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME (1 << 0)
#define SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_SCALE (1 << 1)
#define SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_STATE (1 << 2)
diff --git a/spa/include/spa/poll.h b/spa/include/spa/poll.h
index df65152b..b1831606 100644
--- a/spa/include/spa/poll.h
+++ b/spa/include/spa/poll.h
@@ -88,6 +88,7 @@ typedef struct {
typedef SpaResult (*SpaPollInvokeFunc) (SpaPoll *poll,
+ bool async,
uint32_t seq,
size_t size,
void *data,
@@ -131,7 +132,6 @@ struct _SpaPoll {
SpaResult (*remove_item) (SpaPoll *poll,
SpaPollItem *item);
-
SpaResult (*invoke) (SpaPoll *poll,
SpaPollInvokeFunc func,
uint32_t seq,
diff --git a/spa/plugins/alsa/alsa-monitor.c b/spa/plugins/alsa/alsa-monitor.c
index 447822c3..ab961b07 100644
--- a/spa/plugins/alsa/alsa-monitor.c
+++ b/spa/plugins/alsa/alsa-monitor.c
@@ -216,7 +216,7 @@ alsa_on_fd_events (SpaPollNotifyData *data)
SpaALSAMonitor *this = data->user_data;
struct udev_device *dev;
const char *str;
- SpaMonitorEvent event;
+ SpaMonitorItem *item;
dev = udev_monitor_receive_device (this->umonitor);
if (fill_item (&this->uitem, dev) < 0)
@@ -225,16 +225,17 @@ alsa_on_fd_events (SpaPollNotifyData *data)
if ((str = udev_device_get_action (dev)) == NULL)
str = "change";
+ item = &this->uitem.item;
+
if (strcmp (str, "add") == 0) {
- event.type = SPA_MONITOR_EVENT_TYPE_ADDED;
+ item->event.type = SPA_MONITOR_EVENT_TYPE_ADDED;
} else if (strcmp (str, "change") == 0) {
- event.type = SPA_MONITOR_EVENT_TYPE_CHANGED;
+ item->event.type = SPA_MONITOR_EVENT_TYPE_CHANGED;
} else if (strcmp (str, "remove") == 0) {
- event.type = SPA_MONITOR_EVENT_TYPE_REMOVED;
+ item->event.type = SPA_MONITOR_EVENT_TYPE_REMOVED;
}
- event.data = &this->uitem.item;
- event.size = sizeof (this->uitem);
- this->event_cb (&this->monitor, &event, this->user_data);
+ item->event.size = sizeof (this->uitem);
+ this->event_cb (&this->monitor, &item->event, this->user_data);
return 0;
}
diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c
index 08234a05..258e6d01 100644
--- a/spa/plugins/alsa/alsa-utils.c
+++ b/spa/plugins/alsa/alsa-utils.c
@@ -241,14 +241,12 @@ xrun_recovery (SpaALSAState *state, snd_pcm_t *hndl, int err)
static void
pull_input (SpaALSAState *state, void *data, snd_pcm_uframes_t frames)
{
- SpaNodeEvent event;
SpaNodeEventNeedInput ni;
- event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
- event.size = sizeof (ni);
- event.data = &ni;
+ ni.event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
+ ni.event.size = sizeof (ni);
ni.port_id = 0;
- state->event_cb (&state->node, &event, state->user_data);
+ state->event_cb (&state->node, &ni.event, state->user_data);
}
static int
@@ -370,7 +368,6 @@ mmap_read (SpaALSAState *state)
if (b) {
- SpaNodeEvent event;
SpaNodeEventHaveOutput ho;
SpaData *d;
@@ -380,11 +377,10 @@ mmap_read (SpaALSAState *state)
b->next = NULL;
SPA_QUEUE_PUSH_TAIL (&state->ready, SpaALSABuffer, next, b);
- event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
- event.size = sizeof (ho);
- event.data = &ho;
+ ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
+ ho.event.size = sizeof (ho);
ho.port_id = 0;
- state->event_cb (&state->node, &event, state->user_data);
+ state->event_cb (&state->node, &ho.event, state->user_data);
}
return 0;
}
diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c
index 814171b6..2d285a61 100644
--- a/spa/plugins/audiomixer/audiomixer.c
+++ b/spa/plugins/audiomixer/audiomixer.c
@@ -566,14 +566,12 @@ spa_audiomixer_node_port_push_input (SpaNode *node,
static void
pull_port (SpaAudioMixer *this, uint32_t port_id, SpaPortOutputInfo *info, size_t pull_size)
{
- SpaNodeEvent event;
SpaNodeEventNeedInput ni;
- event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
- event.size = sizeof (ni);
- event.data = &ni;
+ ni.event.type = SPA_NODE_EVENT_TYPE_NEED_INPUT;
+ ni.event.size = sizeof (ni);
ni.port_id = port_id;
- this->event_cb (&this->node, &event, this->user_data);
+ this->event_cb (&this->node, &ni.event, this->user_data);
}
static void
diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c
index 1d9089bc..17705523 100644
--- a/spa/plugins/audiotestsrc/audiotestsrc.c
+++ b/spa/plugins/audiotestsrc/audiotestsrc.c
@@ -229,15 +229,13 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
static SpaResult
send_have_output (SpaAudioTestSrc *this)
{
- SpaNodeEvent event;
SpaNodeEventHaveOutput ho;
if (this->event_cb) {
- event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
- event.size = sizeof (ho);
- event.data = &ho;
+ ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
+ ho.event.size = sizeof (ho);
ho.port_id = 0;
- this->event_cb (&this->node, &event, this->user_data);
+ this->event_cb (&this->node, &ho.event, this->user_data);
}
return SPA_RESULT_OK;
diff --git a/spa/plugins/v4l2/v4l2-monitor.c b/spa/plugins/v4l2/v4l2-monitor.c
index 06a7eeb0..eda1043e 100644
--- a/spa/plugins/v4l2/v4l2-monitor.c
+++ b/spa/plugins/v4l2/v4l2-monitor.c
@@ -186,7 +186,8 @@ v4l2_on_fd_events (SpaPollNotifyData *data)
SpaV4l2Monitor *this = data->user_data;
struct udev_device *dev;
const char *action;
- SpaMonitorEvent event;
+ SpaMonitorItem *item;
+
dev = udev_monitor_receive_device (this->umonitor);
fill_item (&this->uitem, dev);
@@ -196,16 +197,17 @@ v4l2_on_fd_events (SpaPollNotifyData *data)
if ((action = udev_device_get_action (dev)) == NULL)
action = "change";
+ item = &this->uitem.item;
+
if (strcmp (action, "add") == 0) {
- event.type = SPA_MONITOR_EVENT_TYPE_ADDED;
+ item->event.type = SPA_MONITOR_EVENT_TYPE_ADDED;
} else if (strcmp (action, "change") == 0) {
- event.type = SPA_MONITOR_EVENT_TYPE_CHANGED;
+ item->event.type = SPA_MONITOR_EVENT_TYPE_CHANGED;
} else if (strcmp (action, "remove") == 0) {
- event.type = SPA_MONITOR_EVENT_TYPE_REMOVED;
+ item->event.type = SPA_MONITOR_EVENT_TYPE_REMOVED;
}
- event.data = &this->uitem.item;
- event.size = sizeof (this->uitem);
- this->event_cb (&this->monitor, &event, this->user_data);
+ item->event.size = sizeof (this->uitem);
+ this->event_cb (&this->monitor, &item->event, this->user_data);
return 0;
}
diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c
index 026c0e60..ccd1b103 100644
--- a/spa/plugins/v4l2/v4l2-source.c
+++ b/spa/plugins/v4l2/v4l2-source.c
@@ -225,25 +225,23 @@ spa_v4l2_source_node_set_props (SpaNode *node,
}
static SpaResult
-do_command_complete (SpaPoll *poll,
- uint32_t seq,
- size_t size,
- void *data,
- void *user_data)
+do_send_event (SpaPoll *poll,
+ bool async,
+ uint32_t seq,
+ size_t size,
+ void *data,
+ void *user_data)
{
SpaV4l2Source *this = user_data;
- SpaNodeEvent event;
- event.type = SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE;
- event.size = size;
- event.data = data;
- this->event_cb (&this->node, &event, this->user_data);
+ this->event_cb (&this->node, data, this->user_data);
return SPA_RESULT_OK;
}
static SpaResult
do_start (SpaPoll *poll,
+ bool async,
uint32_t seq,
size_t size,
void *data,
@@ -255,19 +253,24 @@ do_start (SpaPoll *poll,
res = spa_v4l2_start (this);
- ac.seq = seq;
- ac.res = res;
- spa_poll_invoke (this->state[0].main_loop,
- do_command_complete,
- seq,
- sizeof (ac),
- &ac,
- this);
+ if (async) {
+ ac.event.type = SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE;
+ ac.event.size = sizeof (SpaNodeEventAsyncComplete);
+ ac.seq = seq;
+ ac.res = res;
+ spa_poll_invoke (this->state[0].main_loop,
+ do_send_event,
+ seq,
+ sizeof (ac),
+ &ac,
+ this);
+ }
return res;
}
static SpaResult
do_pause (SpaPoll *poll,
+ bool async,
uint32_t seq,
size_t size,
void *data,
@@ -279,18 +282,21 @@ do_pause (SpaPoll *poll,
res = spa_v4l2_pause (this);
- ac.seq = seq;
- ac.res = res;
- spa_poll_invoke (this->state[0].main_loop,
- do_command_complete,
- seq,
- sizeof (ac),
- &ac,
- this);
+ if (async) {
+ ac.event.type = SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE;
+ ac.event.size = sizeof (SpaNodeEventAsyncComplete);
+ ac.seq = seq;
+ ac.res = res;
+ spa_poll_invoke (this->state[0].main_loop,
+ do_send_event,
+ seq,
+ sizeof (ac),
+ &ac,
+ this);
+ }
return res;
}
-
static SpaResult
spa_v4l2_source_node_send_command (SpaNode *node,
SpaNodeCommand *command)
diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c
index fe7333d6..7ff9f043 100644
--- a/spa/plugins/v4l2/v4l2-utils.c
+++ b/spa/plugins/v4l2/v4l2-utils.c
@@ -895,7 +895,6 @@ static int
v4l2_on_fd_events (SpaPollNotifyData *data)
{
SpaV4l2Source *this = data->user_data;
- SpaNodeEvent event;
SpaNodeEventHaveOutput ho;
if (data->fds[0].revents & POLLERR)
@@ -907,11 +906,10 @@ v4l2_on_fd_events (SpaPollNotifyData *data)
if (mmap_read (this) < 0)
return 0;
- event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
- event.size = sizeof (ho);
- event.data = &ho;
+ ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
+ ho.event.size = sizeof (ho);
ho.port_id = 0;
- this->event_cb (&this->node, &event, this->user_data);
+ this->event_cb (&this->node, &ho.event, this->user_data);
return 0;
}
diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c
index dafe1a89..601a0177 100644
--- a/spa/plugins/videotestsrc/videotestsrc.c
+++ b/spa/plugins/videotestsrc/videotestsrc.c
@@ -182,15 +182,13 @@ spa_videotestsrc_node_set_props (SpaNode *node,
static SpaResult
send_have_output (SpaVideoTestSrc *this)
{
- SpaNodeEvent event;
SpaNodeEventHaveOutput ho;
if (this->event_cb) {
- event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
- event.size = sizeof (ho);
- event.data = &ho;
+ ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
+ ho.event.size = sizeof (ho);
ho.port_id = 0;
- this->event_cb (&this->node, &event, this->user_data);
+ this->event_cb (&this->node, &ho.event, this->user_data);
}
return SPA_RESULT_OK;
diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c
index a84f5fa3..0a193b95 100644
--- a/spa/plugins/volume/volume.c
+++ b/spa/plugins/volume/volume.c
@@ -521,15 +521,13 @@ find_free_buffer (SpaVolume *this, SpaVolumePort *port)
static void
release_buffer (SpaVolume *this, SpaBuffer *buffer)
{
- SpaNodeEvent event;
SpaNodeEventReuseBuffer rb;
- event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
- event.data = &rb;
- event.size = sizeof (rb);
+ rb.event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
+ rb.event.size = sizeof (rb);
rb.port_id = 0;
rb.buffer_id = buffer->id;
- this->event_cb (&this->node, &event, this->user_data);
+ this->event_cb (&this->node, &rb.event, this->user_data);
}
static SpaResult
diff --git a/spa/tests/test-mixer.c b/spa/tests/test-mixer.c
index 2ac3e41d..6b161cd8 100644
--- a/spa/tests/test-mixer.c
+++ b/spa/tests/test-mixer.c
@@ -112,7 +112,7 @@ on_mix_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
SpaPortInputInfo iinfo;
SpaPortOutputInfo oinfo;
SpaResult res;
- SpaNodeEventNeedInput *ni = event->data;
+ SpaNodeEventNeedInput *ni = (SpaNodeEventNeedInput *) event;
oinfo.port_id = 0;
oinfo.flags = SPA_PORT_OUTPUT_FLAG_NONE;
@@ -150,7 +150,7 @@ on_sink_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
SpaPortInputInfo iinfo;
SpaPortOutputInfo oinfo;
SpaResult res;
- SpaNodeEventNeedInput *ni = event->data;
+ SpaNodeEventNeedInput *ni = (SpaNodeEventNeedInput *)event;
oinfo.port_id = 0;
oinfo.flags = SPA_PORT_OUTPUT_FLAG_PULL;
diff --git a/spa/tools/spa-monitor.c b/spa/tools/spa-monitor.c
index 1c23cb97..4c04fbcb 100644
--- a/spa/tools/spa-monitor.c
+++ b/spa/tools/spa-monitor.c
@@ -71,21 +71,21 @@ on_monitor_event (SpaMonitor *monitor,
switch (event->type) {
case SPA_MONITOR_EVENT_TYPE_ADDED:
{
- SpaMonitorItem *item = event->data;
+ SpaMonitorItem *item = (SpaMonitorItem *) event;
fprintf (stderr, "added:\n");
inspect_item (item);
break;
}
case SPA_MONITOR_EVENT_TYPE_REMOVED:
{
- SpaMonitorItem *item = event->data;
+ SpaMonitorItem *item = (SpaMonitorItem *) event;
fprintf (stderr, "removed:\n");
inspect_item (item);
break;
}
case SPA_MONITOR_EVENT_TYPE_CHANGED:
{
- SpaMonitorItem *item = event->data;
+ SpaMonitorItem *item = (SpaMonitorItem *) event;
fprintf (stderr, "changed:\n");
inspect_item (item);
break;