mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Add versions to structures
Use versions instead of size Remove user_data from callbacks, we can simply pass the callback struct.
This commit is contained in:
parent
4a219e81dd
commit
c3b73ba47d
45 changed files with 344 additions and 303 deletions
|
|
@ -17,10 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <spa/log.h>
|
||||
|
||||
#include <pipewire/client/log.h>
|
||||
#include <pipewire/client/type.h>
|
||||
|
||||
#define DEFAULT_LOG_LEVEL SPA_LOG_LEVEL_ERROR
|
||||
|
||||
|
|
|
|||
|
|
@ -17,18 +17,6 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/timerfd.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/signalfd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <spa/loop.h>
|
||||
#include <spa/type-map.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/list.h>
|
||||
#include <spa/loop.h>
|
||||
|
||||
#include <pipewire/client/sig.h>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ static void after(const struct spa_loop_control_hooks *hooks)
|
|||
}
|
||||
|
||||
static const struct spa_loop_control_hooks impl_hooks = {
|
||||
SPA_VERSION_LOOP_CONTROL_HOOKS,
|
||||
{ NULL, },
|
||||
before,
|
||||
after,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ struct impl {
|
|||
void *hnd;
|
||||
|
||||
struct spa_list item_list;
|
||||
struct spa_monitor_callbacks callbacks;
|
||||
};
|
||||
|
||||
static void add_item(struct pw_spa_monitor *this, struct spa_monitor_item *item)
|
||||
|
|
@ -149,10 +150,11 @@ static void remove_item(struct pw_spa_monitor *this, struct spa_monitor_item *it
|
|||
destroy_item(mitem);
|
||||
}
|
||||
|
||||
static void on_monitor_event(struct spa_monitor *monitor, struct spa_event *event, void *user_data)
|
||||
static void on_monitor_event(const struct spa_monitor_callbacks *callbacks,
|
||||
struct spa_monitor *monitor, struct spa_event *event)
|
||||
{
|
||||
struct pw_spa_monitor *this = user_data;
|
||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||
struct impl *impl = SPA_CONTAINER_OF(callbacks, struct impl, callbacks);
|
||||
struct pw_spa_monitor *this = &impl->this;
|
||||
|
||||
if (SPA_EVENT_TYPE(event) == impl->core->type.monitor.Added) {
|
||||
struct spa_monitor_item *item = SPA_POD_CONTENTS(struct spa_event, event);
|
||||
|
|
@ -195,6 +197,7 @@ static void update_monitor(struct pw_core *core, const char *name)
|
|||
}
|
||||
|
||||
static const struct spa_monitor_callbacks callbacks = {
|
||||
SPA_VERSION_MONITOR_CALLBACKS,
|
||||
on_monitor_event,
|
||||
};
|
||||
|
||||
|
|
@ -269,7 +272,8 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
|
|||
}
|
||||
add_item(this, item);
|
||||
}
|
||||
spa_monitor_set_callbacks(this->monitor, &callbacks, sizeof(callbacks), this);
|
||||
impl->callbacks = callbacks;
|
||||
spa_monitor_set_callbacks(this->monitor, &impl->callbacks);
|
||||
|
||||
return this;
|
||||
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ struct proxy {
|
|||
struct spa_loop *main_loop;
|
||||
struct spa_loop *data_loop;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct pw_resource *resource;
|
||||
|
||||
|
|
@ -210,8 +209,7 @@ static int spa_proxy_node_send_command(struct spa_node *node, struct spa_command
|
|||
|
||||
static int
|
||||
spa_proxy_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct proxy *this;
|
||||
|
||||
|
|
@ -219,8 +217,7 @@ spa_proxy_node_set_callbacks(struct spa_node *node,
|
|||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct proxy, node);
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -850,14 +847,14 @@ static int handle_node_event(struct proxy *this, struct spa_event *event)
|
|||
*io = impl->transport->outputs[i];
|
||||
pw_log_trace("%d %d", io->status, io->buffer_id);
|
||||
}
|
||||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks, &this->node);
|
||||
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.NeedInput) {
|
||||
this->callbacks.need_input(&this->node, this->user_data);
|
||||
this->callbacks->need_input(this->callbacks, &this->node);
|
||||
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.ReuseBuffer) {
|
||||
struct pw_event_transport_reuse_buffer *p =
|
||||
(struct pw_event_transport_reuse_buffer *) event;
|
||||
this->callbacks.reuse_buffer(&this->node, p->body.port_id.value,
|
||||
p->body.buffer_id.value, this->user_data);
|
||||
this->callbacks->reuse_buffer(this->callbacks, &this->node, p->body.port_id.value,
|
||||
p->body.buffer_id.value);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -870,7 +867,7 @@ client_node_done(void *object, int seq, int res)
|
|||
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
||||
struct proxy *this = &impl->proxy;
|
||||
|
||||
this->callbacks.done(&this->node, seq, res, this->user_data);
|
||||
this->callbacks->done(this->callbacks, &this->node, seq, res);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -936,7 +933,7 @@ static void client_node_event(void *object, struct spa_event *event)
|
|||
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
||||
struct proxy *this = &impl->proxy;
|
||||
|
||||
this->callbacks.event(&this->node, event, this->user_data);
|
||||
this->callbacks->event(this->callbacks, &this->node, event);
|
||||
}
|
||||
|
||||
static void client_node_destroy(void *object)
|
||||
|
|
@ -979,7 +976,7 @@ static void proxy_on_data_fd_events(struct spa_source *source)
|
|||
}
|
||||
|
||||
static const struct spa_node proxy_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
spa_proxy_node_get_props,
|
||||
spa_proxy_node_set_props,
|
||||
|
|
|
|||
|
|
@ -17,16 +17,9 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <limits.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "pipewire/client/log.h"
|
||||
#include "pipewire/client/rtkit.h"
|
||||
|
|
|
|||
|
|
@ -17,13 +17,6 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include "spa/list.h"
|
||||
#include "spa/ringbuffer.h"
|
||||
#include "pipewire/client/log.h"
|
||||
#include "pipewire/server/main-loop.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/include/spa/loop.h>
|
||||
#include <pipewire/client/loop.h>
|
||||
|
||||
/** \class pw_main_loop
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ struct impl {
|
|||
struct pw_work_queue *work;
|
||||
|
||||
bool async_init;
|
||||
struct spa_node_callbacks callbacks;
|
||||
};
|
||||
|
||||
/** \endcond */
|
||||
|
|
@ -313,35 +314,42 @@ static int do_pull(struct pw_node *this)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void on_node_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_node_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
struct pw_node *this = user_data;
|
||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||
struct impl *impl = SPA_CONTAINER_OF(callbacks, struct impl, callbacks);
|
||||
struct pw_node *this = &impl->this;
|
||||
|
||||
pw_log_debug("node %p: async complete event %d %d", this, seq, res);
|
||||
pw_work_queue_complete(impl->work, this, seq, res);
|
||||
pw_signal_emit(&this->async_complete, this, seq, res);
|
||||
}
|
||||
|
||||
static void on_node_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_node_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
struct pw_node *this = user_data;
|
||||
struct impl *impl = SPA_CONTAINER_OF(callbacks, struct impl, callbacks);
|
||||
struct pw_node *this = &impl->this;
|
||||
|
||||
if (SPA_EVENT_TYPE(event) == this->core->type.event_node.RequestClockUpdate) {
|
||||
send_clock_update(this);
|
||||
}
|
||||
}
|
||||
|
||||
static void on_node_need_input(struct spa_node *node, void *user_data)
|
||||
static void on_node_need_input(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct pw_node *this = user_data;
|
||||
struct impl *impl = SPA_CONTAINER_OF(callbacks, struct impl, callbacks);
|
||||
struct pw_node *this = &impl->this;
|
||||
|
||||
do_pull(this);
|
||||
}
|
||||
|
||||
static void on_node_have_output(struct spa_node *node, void *user_data)
|
||||
static void on_node_have_output(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct pw_node *this = user_data;
|
||||
struct impl *impl = SPA_CONTAINER_OF(callbacks, struct impl, callbacks);
|
||||
struct pw_node *this = &impl->this;
|
||||
int res;
|
||||
struct pw_port *outport;
|
||||
|
||||
|
|
@ -376,9 +384,11 @@ static void on_node_have_output(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
on_node_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
|
||||
on_node_reuse_buffer(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct pw_node *this = user_data;
|
||||
struct impl *impl = SPA_CONTAINER_OF(callbacks, struct impl, callbacks);
|
||||
struct pw_node *this = &impl->this;
|
||||
struct pw_port *inport;
|
||||
|
||||
pw_log_trace("node %p: reuse buffer %u", this, buffer_id);
|
||||
|
|
@ -510,6 +520,7 @@ void pw_node_set_data_loop(struct pw_node *node, struct pw_data_loop *loop)
|
|||
}
|
||||
|
||||
static const struct spa_node_callbacks node_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_node_done,
|
||||
&on_node_event,
|
||||
&on_node_need_input,
|
||||
|
|
@ -547,7 +558,8 @@ struct pw_node *pw_node_new(struct pw_core *core,
|
|||
|
||||
spa_list_init(&this->resource_list);
|
||||
|
||||
if (spa_node_set_callbacks(this->node, &node_callbacks, sizeof(node_callbacks), this) < 0)
|
||||
impl->callbacks = node_callbacks;
|
||||
if (spa_node_set_callbacks(this->node, &impl->callbacks) < 0)
|
||||
pw_log_warn("node %p: error setting callback", this);
|
||||
|
||||
pw_signal_init(&this->destroy_signal);
|
||||
|
|
|
|||
|
|
@ -43,15 +43,17 @@ enum spa_clock_state {
|
|||
#include <spa/plugin.h>
|
||||
#include <spa/props.h>
|
||||
|
||||
#define SPA_VERSION_CLOCK 0
|
||||
|
||||
/**
|
||||
* spa_clock:
|
||||
*
|
||||
* A time provider.
|
||||
*/
|
||||
struct spa_clock {
|
||||
/* the total size of this clock. This can be used to expand this
|
||||
/* the version of this clock. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
const struct spa_dict *info;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ struct { \
|
|||
} name
|
||||
|
||||
#define SPA_LOG_IMPL_INIT \
|
||||
{ { sizeof(struct spa_log), \
|
||||
{ { SPA_VERSION_LOG, \
|
||||
NULL, \
|
||||
SPA_LOG_LEVEL_INFO, \
|
||||
spa_log_impl_log, \
|
||||
|
|
|
|||
|
|
@ -42,15 +42,17 @@ enum spa_log_level {
|
|||
SPA_LOG_LEVEL_TRACE,
|
||||
};
|
||||
|
||||
#define SPA_VERSION_LOG 0
|
||||
|
||||
/**
|
||||
* struct spa_log:
|
||||
*
|
||||
* The Log interface
|
||||
*/
|
||||
struct spa_log {
|
||||
/* the total size of this log. This can be used to expand this
|
||||
/* the version of this log. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
/**
|
||||
* struct spa_log::info
|
||||
*
|
||||
|
|
|
|||
|
|
@ -65,15 +65,18 @@ typedef int (*spa_invoke_func_t) (struct spa_loop *loop,
|
|||
size_t size,
|
||||
void *data,
|
||||
void *user_data);
|
||||
|
||||
#define SPA_VERSION_LOOP 0
|
||||
|
||||
/**
|
||||
* spa_loop:
|
||||
*
|
||||
* Register sources and work items to an event loop
|
||||
*/
|
||||
struct spa_loop {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
int (*add_source) (struct spa_loop *loop,
|
||||
struct spa_source *source);
|
||||
|
|
@ -96,24 +99,31 @@ struct spa_loop {
|
|||
#define spa_loop_remove_source(l,...) (l)->remove_source(__VA_ARGS__)
|
||||
#define spa_loop_invoke(l,...) (l)->invoke((l),__VA_ARGS__)
|
||||
|
||||
#define SPA_VERSION_LOOP_CONTROL_HOOKS 0
|
||||
|
||||
/** Control hooks */
|
||||
struct spa_loop_control_hooks {
|
||||
uint32_t version;
|
||||
|
||||
struct spa_list link;
|
||||
|
||||
/** Executed right before waiting for events */
|
||||
void (*before) (const struct spa_loop_control_hooks *hooks);
|
||||
/** Executed right after waiting for events */
|
||||
void (*after) (const struct spa_loop_control_hooks *hooks);
|
||||
};
|
||||
|
||||
#define SPA_VERSION_LOOP_CONTROL 0
|
||||
|
||||
/**
|
||||
* spa_loop_control:
|
||||
*
|
||||
* Control an event loop
|
||||
*/
|
||||
struct spa_loop_control {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
int (*get_fd) (struct spa_loop_control *ctrl);
|
||||
|
||||
|
|
@ -150,15 +160,17 @@ typedef void (*spa_source_signal_func_t) (struct spa_loop_utils *utils,
|
|||
struct spa_source *source,
|
||||
int signal_number, void *data);
|
||||
|
||||
#define SPA_VERSION_LOOP_UTILS 0
|
||||
|
||||
/**
|
||||
* struct spa_loop_utils:
|
||||
*
|
||||
* Create sources for an event loop
|
||||
*/
|
||||
struct spa_loop_utils {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
struct spa_source *(*add_io) (struct spa_loop_utils *utils,
|
||||
int fd,
|
||||
|
|
|
|||
|
|
@ -104,19 +104,31 @@ enum spa_monitor_item_state {
|
|||
SPA_MONITOR_ITEM_STATE_UNAVAILABLE,
|
||||
};
|
||||
|
||||
#define SPA_VERSION_MONITOR_CALLBACKS 0
|
||||
|
||||
/**
|
||||
* spa_monitor_callbacks:
|
||||
*/
|
||||
struct spa_monitor_callbacks {
|
||||
void (*event) (struct spa_monitor *monitor, struct spa_event *event, void *user_data);
|
||||
uint32_t version; /**< version of the structure */
|
||||
|
||||
void (*event) (const struct spa_monitor_callbacks *callbacks,
|
||||
struct spa_monitor *monitor,
|
||||
struct spa_event *event);
|
||||
};
|
||||
|
||||
#define SPA_VERSION_MONITOR 0
|
||||
|
||||
/**
|
||||
* spa_monitor:
|
||||
*
|
||||
* The device monitor interface.
|
||||
*/
|
||||
struct spa_monitor {
|
||||
/* the version of this monitor. This can be used to expand this
|
||||
* structure in the future */
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
* spa_monitor::info
|
||||
*
|
||||
|
|
@ -124,15 +136,10 @@ struct spa_monitor {
|
|||
*/
|
||||
const struct spa_dict *info;
|
||||
|
||||
/* the total size of this monitor. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
|
||||
/**
|
||||
* spa_monitor::set_callbacks:
|
||||
* @monitor: a #spa_monitor
|
||||
* @callback: a #callbacks
|
||||
* @user_data: extra user data
|
||||
*
|
||||
* Set callbacks to receive asynchronous notifications from
|
||||
* the monitor.
|
||||
|
|
@ -140,8 +147,7 @@ struct spa_monitor {
|
|||
* Returns: #SPA_RESULT_OK on success
|
||||
*/
|
||||
int (*set_callbacks) (struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data);
|
||||
const struct spa_monitor_callbacks *callbacks);
|
||||
|
||||
int (*enum_items) (struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item, uint32_t index);
|
||||
|
|
|
|||
|
|
@ -78,23 +78,27 @@ struct spa_port_info {
|
|||
const struct spa_dict *props; /**< extra port properties */
|
||||
};
|
||||
|
||||
#define SPA_VERSION_NODE_CALLBACKS 0
|
||||
|
||||
struct spa_node_callbacks {
|
||||
void (*done) (struct spa_node *node, int seq, int res, void *user_data);
|
||||
uint32_t version; /**< version of this structure */
|
||||
|
||||
/** Emited when an async operation completed */
|
||||
void (*done) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res);
|
||||
/**
|
||||
* struct spa_node_callbacks::event:
|
||||
* @node: a #struct spa_node
|
||||
* @event: the event that was emited
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* This will be called when an out-of-bound event is notified
|
||||
* on @node. the callback can be called from any thread.
|
||||
*/
|
||||
void (*event) (struct spa_node *node, struct spa_event *event, void *user_data);
|
||||
void (*event) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event);
|
||||
/**
|
||||
* struct spa_node_callbacks::need_input:
|
||||
* @node: a #struct spa_node
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* The node needs more input. This callback is called from the
|
||||
* data thread.
|
||||
|
|
@ -102,11 +106,11 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, synchronous operation is requested
|
||||
* on the input ports.
|
||||
*/
|
||||
void (*need_input) (struct spa_node *node, void *user_data);
|
||||
void (*need_input) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node);
|
||||
/**
|
||||
* struct spa_node_callbacks::have_output:
|
||||
* @node: a #struct spa_node
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* The node has output input. This callback is called from the
|
||||
* data thread.
|
||||
|
|
@ -114,13 +118,13 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, synchronous operation is requested
|
||||
* on the output ports.
|
||||
*/
|
||||
void (*have_output) (struct spa_node *node, void *user_data);
|
||||
void (*have_output) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node);
|
||||
/**
|
||||
* struct spa_node_callbacks::reuse_buffer:
|
||||
* @node: a #struct spa_node
|
||||
* @port_id: an input port_id
|
||||
* @buffer_id: the buffer id to be reused
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* The node has a buffer that can be reused. This callback is called
|
||||
* from the data thread.
|
||||
|
|
@ -128,12 +132,15 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, the buffers to reuse will be set in
|
||||
* the io area or the input ports.
|
||||
*/
|
||||
void (*reuse_buffer) (struct spa_node *node,
|
||||
void (*reuse_buffer) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id, void *user_data);
|
||||
uint32_t buffer_id);
|
||||
|
||||
};
|
||||
|
||||
#define SPA_VERSION_NODE 0
|
||||
|
||||
/**
|
||||
* struct spa_node:
|
||||
*
|
||||
|
|
@ -143,9 +150,9 @@ struct spa_node_callbacks {
|
|||
*
|
||||
*/
|
||||
struct spa_node {
|
||||
/* the total size of this node. This can be used to expand this
|
||||
/* the version of this node. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
/**
|
||||
* spa_node::info
|
||||
*
|
||||
|
|
@ -218,8 +225,6 @@ struct spa_node {
|
|||
* struct spa_node::set_event_callback:
|
||||
* @node: a #struct spa_node
|
||||
* @callbacks: callbacks to set
|
||||
* @callbacks_size: size of the callbacks structure
|
||||
* @user_data: user data passed to the callback functions
|
||||
*
|
||||
* Set callbacks to receive events and scheduling callbacks from @node.
|
||||
* if @callbacks is %NULL, the current callbacks are removed.
|
||||
|
|
@ -230,9 +235,7 @@ struct spa_node {
|
|||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
*/
|
||||
int (*set_callbacks) (struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data);
|
||||
const struct spa_node_callbacks *callbacks);
|
||||
/**
|
||||
* struct spa_node::get_n_ports:
|
||||
* @node: a #struct spa_node
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@ extern "C" {
|
|||
#define SPA_TYPE__Handle SPA_TYPE_INTERFACE_BASE "Handle"
|
||||
#define SPA_TYPE__HandleFactory SPA_TYPE_INTERFACE_BASE "HandleFactory"
|
||||
|
||||
#define SPA_VERSION_HANDLE 0
|
||||
|
||||
struct spa_handle {
|
||||
/** Version of this struct */
|
||||
uint32_t version;
|
||||
|
||||
/* user_data that can be set by the application */
|
||||
void *user_data;
|
||||
/**
|
||||
|
|
@ -98,7 +103,11 @@ static inline void *spa_support_find(const struct spa_support *support,
|
|||
|
||||
#define SPA_SUPPORT_INIT(type,data) (struct spa_support) { (type), (data) }
|
||||
|
||||
#define SPA_VERSION_HANDLE_FACTORY 0
|
||||
|
||||
struct spa_handle_factory {
|
||||
/** The version of this structure */
|
||||
uint32_t version;
|
||||
/**
|
||||
* spa_handle_factory::name
|
||||
*
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ struct { \
|
|||
} name
|
||||
|
||||
#define SPA_TYPE_MAP_IMPL_INIT \
|
||||
{ { sizeof(struct spa_type_map), \
|
||||
{ { SPA_VERSION_TYPE_MAP, \
|
||||
NULL, \
|
||||
spa_type_map_impl_get_id, \
|
||||
spa_type_map_impl_get_type, \
|
||||
|
|
|
|||
|
|
@ -30,15 +30,17 @@ extern "C" {
|
|||
|
||||
#define SPA_TYPE__TypeMap SPA_TYPE_INTERFACE_BASE "TypeMap"
|
||||
|
||||
#define SPA_VERSION_TYPE_MAP 0
|
||||
|
||||
/**
|
||||
* spa_type_map:
|
||||
*
|
||||
* Maps between string types and their type id
|
||||
*/
|
||||
struct spa_type_map {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
/**
|
||||
* spa_type_map::info
|
||||
*
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
struct spa_monitor_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -350,15 +349,14 @@ static void impl_on_fd_events(struct spa_source *source)
|
|||
|
||||
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->item);
|
||||
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
|
||||
this->callbacks.event(&this->monitor, event, this->user_data);
|
||||
this->callbacks->event(this->callbacks, &this->monitor, event);
|
||||
}
|
||||
close_card(this);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_monitor_callbacks *callbacks)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -367,10 +365,9 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
if (callbacks) {
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
|
|
@ -389,7 +386,6 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
spa_loop_add_source(this->main_loop, &this->source);
|
||||
} else {
|
||||
spa_zero(this->callbacks);
|
||||
spa_loop_remove_source(this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
|
|
@ -454,8 +450,8 @@ static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
|||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
SPA_VERSION_MONITOR,
|
||||
NULL,
|
||||
sizeof(struct spa_monitor),
|
||||
impl_monitor_set_callbacks,
|
||||
impl_monitor_enum_items,
|
||||
};
|
||||
|
|
@ -542,6 +538,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_monitor_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
|
|||
{
|
||||
struct state *this = user_data;
|
||||
|
||||
this->callbacks.done(&this->node, seq, *(int*)data, this->user_data);
|
||||
this->callbacks->done(this->callbacks, &this->node, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -150,8 +150,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
|
|
@ -159,8 +158,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -569,7 +567,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -692,6 +690,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_sink_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct state),
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
|
|||
{
|
||||
struct state *this = user_data;
|
||||
|
||||
this->callbacks.done(&this->node, seq, *(int*)data, this->user_data);
|
||||
this->callbacks->done(this->callbacks, &this->node, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
|
|
@ -176,8 +176,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -578,7 +577,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -635,7 +634,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -746,7 +745,9 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_source_factory = { NAME,
|
||||
const struct spa_handle_factory spa_alsa_source_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct state),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ pull_frames(struct state *state,
|
|||
io->range.offset = state->sample_count * state->frame_size;
|
||||
io->range.min_size = state->threshold * state->frame_size;
|
||||
io->range.max_size = frames * state->frame_size;
|
||||
state->callbacks.need_input(&state->node, state->user_data);
|
||||
state->callbacks->need_input(state->callbacks, &state->node);
|
||||
}
|
||||
while (!spa_list_is_empty(&state->ready) && to_write > 0) {
|
||||
uint8_t *src, *dst;
|
||||
|
|
@ -371,7 +371,10 @@ pull_frames(struct state *state,
|
|||
b->outstanding = true;
|
||||
state->io->buffer_id = b->outbuf->id;
|
||||
spa_log_trace(state->log, "alsa-util %p: reuse buffer %u", state, b->outbuf->id);
|
||||
state->callbacks.reuse_buffer(&state->node, 0, b->outbuf->id, state->user_data);
|
||||
state->callbacks->reuse_buffer(state->callbacks,
|
||||
&state->node,
|
||||
0,
|
||||
b->outbuf->id);
|
||||
state->ready_offset = 0;
|
||||
}
|
||||
total_frames += n_frames;
|
||||
|
|
@ -427,7 +430,7 @@ push_frames(struct state *state,
|
|||
b->outstanding = true;
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
state->callbacks.have_output(&state->node, state->user_data);
|
||||
state->callbacks->have_output(state->callbacks, &state->node);
|
||||
}
|
||||
}
|
||||
return total_frames;
|
||||
|
|
|
|||
|
|
@ -118,8 +118,7 @@ struct state {
|
|||
snd_pcm_stream_t stream;
|
||||
snd_output_t *output;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
uint8_t props_buffer[1024];
|
||||
struct props props;
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ struct impl {
|
|||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
int port_count;
|
||||
int port_queued;
|
||||
|
|
@ -153,9 +152,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -163,8 +160,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -774,7 +770,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -884,6 +880,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_audiomixer_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -122,8 +122,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -241,7 +240,7 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -263,7 +262,7 @@ static void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -351,7 +350,7 @@ static void on_output(struct spa_source *source)
|
|||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks, &this->node);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
|
|
@ -405,9 +404,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -415,12 +412,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->have_output != NULL) {
|
||||
if (this->data_loop == NULL && (callbacks && callbacks->have_output != NULL)) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -867,14 +863,14 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (!this->callbacks.have_output && (io->status == SPA_RESULT_NEED_BUFFER))
|
||||
if ((this->callbacks == NULL || this->callbacks->have_output == NULL) && (io->status == SPA_RESULT_NEED_BUFFER))
|
||||
return make_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -935,7 +931,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -1061,6 +1057,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_audiotestsrc_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -71,8 +71,7 @@ struct impl {
|
|||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct port in_ports[1];
|
||||
struct port out_ports[1];
|
||||
|
|
@ -111,9 +110,7 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, struct spa_co
|
|||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -122,8 +119,7 @@ spa_ffmpeg_dec_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -432,7 +428,7 @@ spa_ffmpeg_dec_node_port_send_command(struct spa_node *node,
|
|||
|
||||
|
||||
static const struct spa_node ffmpeg_dec_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
spa_ffmpeg_dec_node_get_props,
|
||||
spa_ffmpeg_dec_node_set_props,
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ struct impl {
|
|||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct port in_ports[1];
|
||||
struct port out_ports[1];
|
||||
|
|
@ -115,8 +114,7 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, struct spa_co
|
|||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -125,8 +123,7 @@ spa_ffmpeg_enc_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -426,7 +423,7 @@ static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node ffmpeg_enc_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
spa_ffmpeg_enc_node_get_props,
|
||||
spa_ffmpeg_enc_node_set_props,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ static void on_trace_event(struct spa_source *source)
|
|||
}
|
||||
|
||||
static const struct spa_log impl_log = {
|
||||
sizeof(struct spa_log),
|
||||
SPA_VERSION_LOG,
|
||||
NULL,
|
||||
DEFAULT_LOG_LEVEL,
|
||||
impl_log_log,
|
||||
|
|
@ -256,6 +256,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
static const struct spa_handle_factory logger_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ static void loop_destroy_source(struct spa_source *source)
|
|||
}
|
||||
|
||||
static const struct spa_loop impl_loop = {
|
||||
sizeof(struct spa_loop),
|
||||
SPA_VERSION_LOOP,
|
||||
loop_add_source,
|
||||
loop_update_source,
|
||||
loop_remove_source,
|
||||
|
|
@ -600,7 +600,7 @@ static const struct spa_loop impl_loop = {
|
|||
};
|
||||
|
||||
static const struct spa_loop_control impl_loop_control = {
|
||||
sizeof(struct spa_loop_control),
|
||||
SPA_VERSION_LOOP_CONTROL,
|
||||
loop_get_fd,
|
||||
loop_add_hooks,
|
||||
loop_enter,
|
||||
|
|
@ -609,7 +609,7 @@ static const struct spa_loop_control impl_loop_control = {
|
|||
};
|
||||
|
||||
static const struct spa_loop_utils impl_loop_utils = {
|
||||
sizeof(struct spa_loop_utils),
|
||||
SPA_VERSION_LOOP_UTILS,
|
||||
loop_add_io,
|
||||
loop_update_io,
|
||||
loop_add_idle,
|
||||
|
|
@ -734,11 +734,12 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
static const struct spa_handle_factory loop_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
impl_enum_interface_info,
|
||||
impl_enum_interface_info
|
||||
};
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ impl_type_map_get_size(const struct spa_type_map *map)
|
|||
}
|
||||
|
||||
static const struct spa_type_map impl_type_map = {
|
||||
sizeof(struct spa_type_map),
|
||||
SPA_VERSION_TYPE_MAP,
|
||||
NULL,
|
||||
impl_type_map_get_id,
|
||||
impl_type_map_get_type,
|
||||
|
|
@ -208,6 +208,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
static const struct spa_handle_factory type_map_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -91,8 +91,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -183,7 +182,7 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.need_input || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->need_input) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -205,7 +204,7 @@ static inline void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.need_input || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->need_input) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -225,8 +224,8 @@ static int consume_buffer(struct impl *this)
|
|||
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
if (this->callbacks.need_input)
|
||||
this->callbacks.need_input(&this->node, this->user_data);
|
||||
if (this->callbacks->need_input)
|
||||
this->callbacks->need_input(this->callbacks, &this->node);
|
||||
}
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
spa_log_error(this->log, NAME " %p: no buffers", this);
|
||||
|
|
@ -321,9 +320,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -331,12 +328,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->need_input != NULL) {
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->need_input != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -675,7 +671,7 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
input->buffer_id = SPA_ID_INVALID;
|
||||
input->status = SPA_RESULT_OK;
|
||||
}
|
||||
if (this->callbacks.need_input == NULL)
|
||||
if (this->callbacks == NULL || this->callbacks->need_input == NULL)
|
||||
return consume_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -687,7 +683,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -748,7 +744,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -874,6 +870,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesink_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -199,7 +198,7 @@ static int fill_buffer(struct impl *this, struct buffer *b)
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -221,7 +220,7 @@ static inline void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -278,8 +277,8 @@ static void on_output(struct spa_source *source)
|
|||
|
||||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks.have_output)
|
||||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks && this->callbacks->have_output)
|
||||
this->callbacks->have_output(this->callbacks, &this->node);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
|
|
@ -333,9 +332,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -343,12 +340,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->have_output != NULL) {
|
||||
if (this->data_loop == NULL && (callbacks != NULL && callbacks->have_output != NULL)) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -717,14 +713,15 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (this->callbacks.have_output == NULL && (io->status == SPA_RESULT_NEED_BUFFER))
|
||||
if ((this->callbacks == NULL || this->callbacks->have_output == NULL) &&
|
||||
(io->status == SPA_RESULT_NEED_BUFFER))
|
||||
return make_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -785,7 +782,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -911,6 +908,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesrc_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -60,8 +60,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
struct spa_monitor_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -231,13 +230,12 @@ static void impl_on_fd_events(struct spa_source *source)
|
|||
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->uitem.item);
|
||||
|
||||
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
|
||||
this->callbacks.event(&this->monitor, event, this->user_data);
|
||||
this->callbacks->event(this->callbacks, &this->monitor, event);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_monitor_callbacks *callbacks)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -246,10 +244,8 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
if (callbacks) {
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
|
|
@ -268,7 +264,6 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
spa_loop_add_source(this->main_loop, &this->source);
|
||||
} else {
|
||||
spa_zero(this->callbacks);
|
||||
spa_loop_remove_source(this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
|
|
@ -325,8 +320,8 @@ impl_monitor_enum_items(struct spa_monitor *monitor, struct spa_monitor_item **i
|
|||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
SPA_VERSION_MONITOR,
|
||||
NULL,
|
||||
sizeof(struct spa_monitor),
|
||||
impl_monitor_set_callbacks,
|
||||
impl_monitor_enum_items,
|
||||
};
|
||||
|
|
@ -413,6 +408,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_monitor_factory = {
|
||||
SPA_VERSION_MONITOR,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -157,8 +157,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct port out_ports[1];
|
||||
};
|
||||
|
|
@ -237,7 +236,7 @@ static int do_pause_done(struct spa_loop *loop,
|
|||
if (SPA_RESULT_IS_OK(res))
|
||||
res = spa_v4l2_stream_off(this);
|
||||
|
||||
this->callbacks.done(&this->node, seq, res, this->user_data);
|
||||
this->callbacks->done(this->callbacks, &this->node, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -276,7 +275,7 @@ static int do_start_done(struct spa_loop *loop,
|
|||
struct impl *this = user_data;
|
||||
int res = *(int*)data;
|
||||
|
||||
this->callbacks.done(&this->node, seq, res, this->user_data);
|
||||
this->callbacks->done(this->callbacks, &this->node, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -355,9 +354,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
}
|
||||
|
||||
static int impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -365,8 +362,7 @@ static int impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -821,7 +817,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -880,7 +876,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -991,6 +987,7 @@ static int impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_source_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -934,7 +934,7 @@ static int mmap_read(struct impl *this)
|
|||
b->outstanding = true;
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks, &this->node);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,8 +111,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -222,7 +221,7 @@ static int fill_buffer(struct impl *this, struct buffer *b)
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -244,7 +243,7 @@ static void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -301,7 +300,7 @@ static void on_output(struct spa_source *source)
|
|||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks, &this->node);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
|
|
@ -355,9 +354,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -365,12 +362,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->have_output != NULL) {
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->have_output != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -810,14 +806,15 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (!this->callbacks.have_output && (io->status == SPA_RESULT_NEED_BUFFER))
|
||||
if ((this->callbacks == NULL || this->callbacks->have_output == NULL) &&
|
||||
(io->status == SPA_RESULT_NEED_BUFFER))
|
||||
return make_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -878,7 +875,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -1004,6 +1001,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_videotestsrc_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -108,8 +108,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
uint8_t format_buffer[1024];
|
||||
struct spa_audio_info current_format;
|
||||
|
|
@ -208,8 +207,7 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
|
|||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -217,8 +215,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -647,8 +644,8 @@ static struct spa_buffer *find_free_buffer(struct impl *this, struct port *port)
|
|||
|
||||
static inline void release_buffer(struct impl *this, struct spa_buffer *buffer)
|
||||
{
|
||||
if (this->callbacks.reuse_buffer)
|
||||
this->callbacks.reuse_buffer(&this->node, 0, buffer->id, this->user_data);
|
||||
if (this->callbacks && this->callbacks->reuse_buffer)
|
||||
this->callbacks->reuse_buffer(this->callbacks, &this->node, 0, buffer->id);
|
||||
}
|
||||
|
||||
static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf)
|
||||
|
|
@ -765,7 +762,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -879,6 +876,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_volume_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ struct data {
|
|||
|
||||
struct spa_node *sink;
|
||||
struct spa_port_io volume_sink_io[1];
|
||||
struct spa_node_callbacks sink_callbacks;
|
||||
|
||||
struct spa_node *volume;
|
||||
struct spa_buffer *volume_buffers[1];
|
||||
|
|
@ -215,19 +216,22 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
static void on_sink_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_sink_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
printf("got done %d %d\n", seq, res);
|
||||
}
|
||||
|
||||
static void on_sink_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_sink_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
printf("got event %d\n", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_sink_need_input(struct spa_node *node, void *user_data)
|
||||
static void on_sink_need_input(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
|
||||
data->sink_node.action = SPA_GRAPH_ACTION_CHECK;
|
||||
data->sink_node.state = SPA_RESULT_NEED_BUFFER;
|
||||
|
|
@ -236,14 +240,16 @@ static void on_sink_need_input(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
on_sink_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
|
||||
on_sink_reuse_buffer(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
|
||||
data->volume_sink_io[0].buffer_id = buffer_id;
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks sink_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_sink_done,
|
||||
&on_sink_event,
|
||||
&on_sink_need_input,
|
||||
|
|
@ -291,7 +297,8 @@ static int make_nodes(struct data *data, const char *device)
|
|||
printf("can't create alsa-sink: %d\n", res);
|
||||
return res;
|
||||
}
|
||||
spa_node_set_callbacks(data->sink, &sink_callbacks, sizeof(sink_callbacks), data);
|
||||
data->sink_callbacks = sink_callbacks;
|
||||
spa_node_set_callbacks(data->sink, &data->sink_callbacks);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_props(&b, &f[0], data->type.props,
|
||||
|
|
@ -531,7 +538,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.data_loop.size = sizeof(struct spa_loop);
|
||||
data.data_loop.version = SPA_VERSION_LOOP;
|
||||
data.data_loop.add_source = do_add_source;
|
||||
data.data_loop.update_source = do_update_source;
|
||||
data.data_loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ struct data {
|
|||
struct spa_graph_node sink_node;
|
||||
|
||||
struct spa_node *sink;
|
||||
struct spa_node_callbacks sink_callbacks;
|
||||
struct spa_port_io mix_sink_io[1];
|
||||
|
||||
struct spa_node *mix;
|
||||
|
|
@ -226,19 +227,22 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
static void on_sink_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_sink_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
printf("got done %d %d\n", seq, res);
|
||||
}
|
||||
|
||||
static void on_sink_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_sink_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
printf("got event %d\n", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_sink_need_input(struct spa_node *node, void *user_data)
|
||||
static void on_sink_need_input(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
#ifdef USE_GRAPH
|
||||
data->sink_node.action = PROCESS_CHECK;
|
||||
data->sink_node.state = SPA_RESULT_NEED_BUFFER;
|
||||
|
|
@ -278,14 +282,18 @@ static void on_sink_need_input(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
on_sink_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
|
||||
on_sink_reuse_buffer(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
|
||||
data->mix_sink_io[0].buffer_id = buffer_id;
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks sink_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_sink_done,
|
||||
&on_sink_event,
|
||||
&on_sink_need_input,
|
||||
|
|
@ -333,7 +341,8 @@ static int make_nodes(struct data *data, const char *device)
|
|||
printf("can't create alsa-sink: %d\n", res);
|
||||
return res;
|
||||
}
|
||||
spa_node_set_callbacks(data->sink, &sink_callbacks, sizeof(sink_callbacks), data);
|
||||
data->sink_callbacks = sink_callbacks;
|
||||
spa_node_set_callbacks(data->sink, &data->sink_callbacks);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_props(&b, &f[0], data->type.props,
|
||||
|
|
@ -636,7 +645,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.data_loop.size = sizeof(struct spa_loop);
|
||||
data.data_loop.version = SPA_VERSION_LOOP;
|
||||
data.data_loop.add_source = do_add_source;
|
||||
data.data_loop.update_source = do_update_source;
|
||||
data.data_loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
|
|
@ -109,10 +109,12 @@ struct data {
|
|||
|
||||
struct spa_node *sink;
|
||||
struct spa_port_io source_sink_io[1];
|
||||
struct spa_node_callbacks sink_callbacks;
|
||||
|
||||
struct spa_node *source;
|
||||
struct spa_buffer *source_buffers[1];
|
||||
struct buffer source_buffer[1];
|
||||
struct spa_node_callbacks source_callbacks;
|
||||
|
||||
bool running;
|
||||
pthread_t thread;
|
||||
|
|
@ -240,21 +242,24 @@ static void on_source_push(struct data *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void on_sink_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_sink_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
spa_log_trace(data->log, "got sink done %d %d", seq, res);
|
||||
}
|
||||
|
||||
static void on_sink_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_sink_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
spa_log_trace(data->log, "got sink event %d", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_sink_need_input(struct spa_node *node, void *user_data)
|
||||
static void on_sink_need_input(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
spa_log_trace(data->log, "need input");
|
||||
on_sink_pull(data);
|
||||
if (--data->iterations == 0)
|
||||
|
|
@ -262,14 +267,16 @@ static void on_sink_need_input(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
on_sink_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
|
||||
on_sink_reuse_buffer(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
|
||||
data->source_sink_io[0].buffer_id = buffer_id;
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks sink_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_sink_done,
|
||||
&on_sink_event,
|
||||
&on_sink_need_input,
|
||||
|
|
@ -277,21 +284,24 @@ static const struct spa_node_callbacks sink_callbacks = {
|
|||
&on_sink_reuse_buffer
|
||||
};
|
||||
|
||||
static void on_source_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_source_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, source_callbacks);
|
||||
spa_log_trace(data->log, "got source done %d %d", seq, res);
|
||||
}
|
||||
|
||||
static void on_source_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_source_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, source_callbacks);
|
||||
spa_log_trace(data->log, "got source event %d", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_source_have_output(struct spa_node *node, void *user_data)
|
||||
static void on_source_have_output(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, source_callbacks);
|
||||
spa_log_trace(data->log, "have_output");
|
||||
on_source_push(data);
|
||||
if (--data->iterations == 0)
|
||||
|
|
@ -299,6 +309,7 @@ static void on_source_have_output(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static const struct spa_node_callbacks source_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_source_done,
|
||||
&on_source_event,
|
||||
NULL,
|
||||
|
|
@ -344,8 +355,9 @@ static int make_nodes(struct data *data)
|
|||
return res;
|
||||
}
|
||||
|
||||
data->sink_callbacks = sink_callbacks;
|
||||
if (data->mode & MODE_ASYNC_PULL)
|
||||
spa_node_set_callbacks(data->sink, &sink_callbacks, sizeof(sink_callbacks), data);
|
||||
spa_node_set_callbacks(data->sink, &data->sink_callbacks);
|
||||
|
||||
if ((res = make_node(data, &data->source,
|
||||
"build/spa/plugins/test/libspa-test.so", "fakesrc")) < 0) {
|
||||
|
|
@ -353,9 +365,9 @@ static int make_nodes(struct data *data)
|
|||
return res;
|
||||
}
|
||||
|
||||
data->source_callbacks = source_callbacks;
|
||||
if (data->mode & MODE_ASYNC_PUSH)
|
||||
spa_node_set_callbacks(data->source, &source_callbacks, sizeof(source_callbacks),
|
||||
data);
|
||||
spa_node_set_callbacks(data->source, &data->source_callbacks);
|
||||
|
||||
data->source_sink_io[0] = SPA_PORT_IO_INIT;
|
||||
data->source_sink_io[0].status = SPA_RESULT_NEED_BUFFER;
|
||||
|
|
@ -528,7 +540,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.data_loop.size = sizeof(struct spa_loop);
|
||||
data.data_loop.version = SPA_VERSION_LOOP;
|
||||
data.data_loop.add_source = do_add_source;
|
||||
data.data_loop.update_source = do_update_source;
|
||||
data.data_loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ struct data {
|
|||
uint32_t n_support;
|
||||
|
||||
struct spa_node *sink;
|
||||
struct spa_node_callbacks sink_callbacks;
|
||||
struct spa_port_io source_sink_io[1];
|
||||
|
||||
struct spa_node *source;
|
||||
|
|
@ -205,19 +206,22 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
static void on_sink_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_sink_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
printf("got done %d %d\n", seq, res);
|
||||
}
|
||||
|
||||
static void on_sink_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_sink_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
printf("got event %d\n", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_sink_need_input(struct spa_node *node, void *user_data)
|
||||
static void on_sink_need_input(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
int res;
|
||||
|
||||
res = spa_node_process_output(data->source);
|
||||
|
|
@ -229,13 +233,17 @@ static void on_sink_need_input(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
on_sink_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
|
||||
on_sink_reuse_buffer(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, sink_callbacks);
|
||||
data->source_sink_io[0].buffer_id = buffer_id;
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks sink_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_sink_done,
|
||||
&on_sink_event,
|
||||
&on_sink_need_input,
|
||||
|
|
@ -283,7 +291,8 @@ static int make_nodes(struct data *data, const char *device)
|
|||
printf("can't create alsa-sink: %d\n", res);
|
||||
return res;
|
||||
}
|
||||
spa_node_set_callbacks(data->sink, &sink_callbacks, sizeof(sink_callbacks), data);
|
||||
data->sink_callbacks = sink_callbacks;
|
||||
spa_node_set_callbacks(data->sink, &data->sink_callbacks);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_props(&b, &f[0], data->type.props,
|
||||
|
|
@ -465,7 +474,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.data_loop.size = sizeof(struct spa_loop);
|
||||
data.data_loop.version = SPA_VERSION_LOOP;
|
||||
data.data_loop.add_source = do_add_source;
|
||||
data.data_loop.update_source = do_update_source;
|
||||
data.data_loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ struct data {
|
|||
|
||||
struct spa_node *source;
|
||||
struct spa_port_io source_output[1];
|
||||
struct spa_node_callbacks source_callbacks;
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Window *window;
|
||||
|
|
@ -176,23 +177,26 @@ static void handle_events(struct data *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void on_source_done(struct spa_node *node, int seq, int res, void *user_data)
|
||||
static void on_source_done(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res)
|
||||
{
|
||||
printf("got done %d %d\n", seq, res);
|
||||
}
|
||||
|
||||
static void on_source_event(struct spa_node *node, struct spa_event *event, void *user_data)
|
||||
static void on_source_event(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, source_callbacks);
|
||||
|
||||
handle_events(data);
|
||||
|
||||
printf("got event %d\n", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_source_have_output(struct spa_node *node, void *user_data)
|
||||
static void on_source_have_output(const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, source_callbacks);
|
||||
int res;
|
||||
struct spa_buffer *b;
|
||||
void *sdata, *ddata;
|
||||
|
|
@ -261,6 +265,7 @@ static void on_source_have_output(struct spa_node *node, void *user_data)
|
|||
}
|
||||
|
||||
static const struct spa_node_callbacks source_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
&on_source_done,
|
||||
&on_source_event,
|
||||
NULL,
|
||||
|
|
@ -309,7 +314,9 @@ static int make_nodes(struct data *data, const char *device)
|
|||
printf("can't create v4l2-source: %d\n", res);
|
||||
return res;
|
||||
}
|
||||
spa_node_set_callbacks(data->source, &source_callbacks, sizeof(source_callbacks), data);
|
||||
|
||||
data->source_callbacks = source_callbacks;
|
||||
spa_node_set_callbacks(data->source, &data->source_callbacks);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_props(&b, &f[0], data->type.props,
|
||||
|
|
@ -549,7 +556,7 @@ int main(int argc, char *argv[])
|
|||
if ((str = getenv("SPA_DEBUG")))
|
||||
data.log->level = atoi(str);
|
||||
|
||||
data.data_loop.size = sizeof(struct spa_loop);
|
||||
data.data_loop.version = SPA_VERSION_LOOP;
|
||||
data.data_loop.add_source = do_add_source;
|
||||
data.data_loop.update_source = do_update_source;
|
||||
data.data_loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.loop.size = sizeof(struct spa_loop);
|
||||
data.loop.version = SPA_VERSION_LOOP;
|
||||
data.loop.add_source = do_add_source;
|
||||
data.loop.update_source = do_update_source;
|
||||
data.loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ struct data {
|
|||
struct spa_log *log;
|
||||
struct spa_loop main_loop;
|
||||
|
||||
struct spa_monitor_callbacks callbacks;
|
||||
|
||||
struct spa_support support[3];
|
||||
uint32_t n_support;
|
||||
|
||||
|
|
@ -63,9 +65,11 @@ static void inspect_item(struct data *data, struct spa_monitor_item *item)
|
|||
spa_debug_pod(&item->object.pod);
|
||||
}
|
||||
|
||||
static void on_monitor_event(struct spa_monitor *monitor, struct spa_event *event, void *user_data)
|
||||
static void on_monitor_event(const struct spa_monitor_callbacks *callbacks,
|
||||
struct spa_monitor *monitor,
|
||||
struct spa_event *event)
|
||||
{
|
||||
struct data *data = user_data;
|
||||
struct data *data = SPA_CONTAINER_OF(callbacks, struct data, callbacks);
|
||||
|
||||
if (SPA_EVENT_TYPE(event) == data->type.monitor.Added) {
|
||||
fprintf(stderr, "added:\n");
|
||||
|
|
@ -99,7 +103,8 @@ static void do_remove_source(struct spa_source *source)
|
|||
{
|
||||
}
|
||||
|
||||
static const struct spa_monitor_callbacks callbacks = {
|
||||
static const struct spa_monitor_callbacks impl_callbacks = {
|
||||
SPA_VERSION_MONITOR_CALLBACKS,
|
||||
on_monitor_event,
|
||||
};
|
||||
|
||||
|
|
@ -121,8 +126,8 @@ static void handle_monitor(struct data *data, struct spa_monitor *monitor)
|
|||
}
|
||||
inspect_item(data, item);
|
||||
}
|
||||
|
||||
spa_monitor_set_callbacks(monitor, &callbacks, sizeof(callbacks), &data);
|
||||
data->callbacks = impl_callbacks;
|
||||
spa_monitor_set_callbacks(monitor, &data->callbacks);
|
||||
|
||||
while (true) {
|
||||
int i, r;
|
||||
|
|
@ -167,7 +172,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
data.map = &default_map.map;
|
||||
data.log = &default_log.log;
|
||||
data.main_loop.size = sizeof(struct spa_loop);
|
||||
data.main_loop.version = SPA_VERSION_LOOP;
|
||||
data.main_loop.add_source = do_add_source;
|
||||
data.main_loop.update_source = do_update_source;
|
||||
data.main_loop.remove_source = do_remove_source;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue