node: improve callbacks

Make separate callbacks for events and RT notifications.
This commit is contained in:
Wim Taymans 2017-05-11 10:29:20 +02:00
parent fb0919b8b7
commit 3b33e3d362
32 changed files with 557 additions and 481 deletions

View file

@ -33,9 +33,6 @@ extern "C" {
#define SPA_TYPE_EVENT_NODE_BASE SPA_TYPE_EVENT__Node ":"
#define SPA_TYPE_EVENT_NODE__AsyncComplete SPA_TYPE_EVENT_NODE_BASE "AsyncComplete"
#define SPA_TYPE_EVENT_NODE__HaveOutput SPA_TYPE_EVENT_NODE_BASE "HaveOutput"
#define SPA_TYPE_EVENT_NODE__NeedInput SPA_TYPE_EVENT_NODE_BASE "NeedInput"
#define SPA_TYPE_EVENT_NODE__ReuseBuffer SPA_TYPE_EVENT_NODE_BASE "ReuseBuffer"
#define SPA_TYPE_EVENT_NODE__Error SPA_TYPE_EVENT_NODE_BASE "Error"
#define SPA_TYPE_EVENT_NODE__Buffering SPA_TYPE_EVENT_NODE_BASE "Buffering"
#define SPA_TYPE_EVENT_NODE__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh"
@ -43,9 +40,6 @@ extern "C" {
typedef struct {
uint32_t AsyncComplete;
uint32_t HaveOutput;
uint32_t NeedInput;
uint32_t ReuseBuffer;
uint32_t Error;
uint32_t Buffering;
uint32_t RequestRefresh;
@ -57,9 +51,6 @@ spa_type_event_node_map (SpaTypeMap *map, SpaTypeEventNode *type)
{
if (type->AsyncComplete == 0) {
type->AsyncComplete = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__AsyncComplete);
type->HaveOutput = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__HaveOutput);
type->NeedInput = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__NeedInput);
type->ReuseBuffer = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__ReuseBuffer);
type->Error = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__Error);
type->Buffering = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__Buffering);
type->RequestRefresh = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__RequestRefresh);
@ -83,22 +74,6 @@ typedef struct {
SPA_POD_INT_INIT (seq), \
SPA_POD_INT_INIT (res))
typedef struct {
SpaPODObjectBody body;
SpaPODInt port_id;
SpaPODInt buffer_id;
} SpaEventNodeReuseBufferBody;
typedef struct {
SpaPOD pod;
SpaEventNodeReuseBufferBody body;
} SpaEventNodeReuseBuffer;
#define SPA_EVENT_NODE_REUSE_BUFFER_INIT(type,port_id,buffer_id) \
SPA_EVENT_INIT_COMPLEX (sizeof (SpaEventNodeReuseBufferBody), type, \
SPA_POD_INT_INIT (port_id), \
SPA_POD_INT_INIT (buffer_id))
typedef struct {
SpaPODObjectBody body;
#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_TIME (1 << 0)

View file

@ -38,21 +38,6 @@ typedef struct _SpaNode SpaNode;
#include <spa/buffer.h>
#include <spa/format.h>
/**
* SpaPortFormatFlags:
* @SPA_PORT_FORMAT_FLAG_NONE: no flags
* @SPA_PORT_FORMAT_FLAG_TEST_ONLY: just check if the format is accepted
* @SPA_PORT_FORMAT_FLAG_FIXATE: fixate the non-optional unset fields
* @SPA_PORT_FORMAT_FLAG_NEAREST: allow set fields to be rounded to the
* nearest allowed field value.
*/
typedef enum {
SPA_PORT_FORMAT_FLAG_NONE = 0,
SPA_PORT_FORMAT_FLAG_TEST_ONLY = (1 << 0),
SPA_PORT_FORMAT_FLAG_FIXATE = (1 << 1),
SPA_PORT_FORMAT_FLAG_NEAREST = (1 << 2),
} SpaPortFormatFlags;
typedef struct {
uint64_t offset;
uint32_t min_size;
@ -75,30 +60,6 @@ typedef struct {
SpaRange range;
} SpaPortIO;
/**
* SpaPortInfoFlags:
* @SPA_PORT_INFO_FLAG_NONE: no flags
* @SPA_PORT_INFO_FLAG_REMOVABLE: port can be removed
* @SPA_PORT_INFO_FLAG_OPTIONAL: processing on port is optional
* @SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS: the port can give a buffer
* @SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS: the port can use a provided buffer
* @SPA_PORT_INFO_FLAG_IN_PLACE: the port can process data in-place and will need
* a writable input buffer
* @SPA_PORT_INFO_FLAG_NO_REF: the port does not keep a ref on the buffer
* @SPA_PORT_INFO_FLAG_LIVE: output buffers from this port are timestamped against
* a live clock.
*/
typedef enum {
SPA_PORT_INFO_FLAG_NONE = 0,
SPA_PORT_INFO_FLAG_REMOVABLE = 1 << 0,
SPA_PORT_INFO_FLAG_OPTIONAL = 1 << 1,
SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS = 1 << 2,
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS = 1 << 3,
SPA_PORT_INFO_FLAG_IN_PLACE = 1 << 4,
SPA_PORT_INFO_FLAG_NO_REF = 1 << 5,
SPA_PORT_INFO_FLAG_LIVE = 1 << 6,
} SpaPortInfoFlags;
/**
* SpaPortInfo
* @flags: extra port flags
@ -111,7 +72,16 @@ typedef enum {
* @extra: a dictionary of extra port info
*/
typedef struct {
SpaPortInfoFlags flags;
#define SPA_PORT_INFO_FLAG_REMOVABLE (1<<0) /* port can be removed */
#define SPA_PORT_INFO_FLAG_OPTIONAL (1<<1) /* processing on port is optional */
#define SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS (1<<2) /* the port can allocate buffer data */
#define SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS (1<<3) /* the port can use a provided buffer */
#define SPA_PORT_INFO_FLAG_IN_PLACE (1<<4) /* the port can process data in-place and will need
* a writable input buffer */
#define SPA_PORT_INFO_FLAG_NO_REF (1<<5) /* the port does not keep a ref on the buffer */
#define SPA_PORT_INFO_FLAG_LIVE (1<<6) /* output buffers from this port are timestamped against
* a live clock. */
uint32_t flags;
uint32_t rate;
uint32_t n_params;
SpaAllocParam **params;
@ -120,18 +90,53 @@ typedef struct {
SpaDict *extra;
} SpaPortInfo;
/**
* SpaEventNodeCallback:
* @node: a #SpaNode emiting the event
* @event: the event that was emited
* @user_data: user data provided when registering the callback
*
* This will be called when an out-of-bound event is notified
* on @node.
*/
typedef void (*SpaEventNodeCallback) (SpaNode *node,
SpaEvent *event,
void *user_data);
typedef struct {
/**
* SpaNodeCallbacks::event:
* @node: a #SpaNode
* @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.
*/
void (*event) (SpaNode *node,
SpaEvent *event,
void *user_data);
/**
* SpaNodeCallbacks::need_input:
* @node: a #SpaNode
* @user_data: user data provided when registering the callbacks
*
* The node needs more input
*/
void (*need_input) (SpaNode *node,
void *user_data);
/**
* SpaNodeCallbacks::have_output:
* @node: a #SpaNode
* @user_data: user data provided when registering the callbacks
*
* The node has output input
*/
void (*have_output) (SpaNode *node,
void *user_data);
/**
* SpaNodeCallbacks::reuse_buffer:
* @node: a #SpaNode
* @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.
*/
void (*reuse_buffer) (SpaNode *node,
uint32_t port_id,
uint32_t buffer_id,
void *user_data);
} SpaNodeCallbacks;
/**
* SpaNode:
@ -219,8 +224,9 @@ struct _SpaNode {
/**
* SpaNode::set_event_callback:
* @node: a #SpaNode
* @callback: a callback
* @user_data: user data passed in the callback
* @callbacks: callbacks to set
* @callbacks_size: size of the callbacks structure
* @user_data: user data passed to the callback functions
*
* Set a callback to receive events from @node. if @callback is %NULL, the
* current callback is removed.
@ -233,9 +239,10 @@ struct _SpaNode {
* Returns: #SPA_RESULT_OK on success
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
*/
SpaResult (*set_event_callback) (SpaNode *node,
SpaEventNodeCallback callback,
void *user_data);
SpaResult (*set_callbacks) (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data);
/**
* SpaNode::get_n_ports:
* @node: a #SpaNode
@ -367,11 +374,15 @@ struct _SpaNode {
* is not correct.
* #SPA_RESULT_ASYNC the function is executed asynchronously
*/
SpaResult (*port_set_format) (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format);
#define SPA_PORT_FORMAT_FLAG_TEST_ONLY (1 << 0) /* just check if the format is accepted */
#define SPA_PORT_FORMAT_FLAG_FIXATE (1 << 1) /* fixate the non-optional unset fields */
#define SPA_PORT_FORMAT_FLAG_NEAREST (1 << 2) /* allow set fields to be rounded to the
* nearest allowed field value. */
SpaResult (*port_set_format) (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format);
/**
* SpaNode::port_get_format:
* @node: a #SpaNode
@ -591,7 +602,7 @@ struct _SpaNode {
#define spa_node_get_props(n,...) (n)->get_props((n),__VA_ARGS__)
#define spa_node_set_props(n,...) (n)->set_props((n),__VA_ARGS__)
#define spa_node_send_command(n,...) (n)->send_command((n),__VA_ARGS__)
#define spa_node_set_event_callback(n,...) (n)->set_event_callback((n),__VA_ARGS__)
#define spa_node_set_callbacks(n,...) (n)->set_callbacks((n),__VA_ARGS__)
#define spa_node_get_n_ports(n,...) (n)->get_n_ports((n),__VA_ARGS__)
#define spa_node_get_port_ids(n,...) (n)->get_port_ids((n),__VA_ARGS__)
#define spa_node_add_port(n,...) (n)->add_port((n),__VA_ARGS__)

View file

@ -99,7 +99,7 @@ do_send_event (SpaLoop *loop,
{
SpaALSASink *this = user_data;
this->event_cb (&this->node, data, this->user_data);
this->callbacks.event (&this->node, data, this->user_data);
return SPA_RESULT_OK;
}
@ -171,9 +171,10 @@ spa_alsa_sink_node_send_command (SpaNode *node,
}
static SpaResult
spa_alsa_sink_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_alsa_sink_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaALSASink *this;
@ -181,7 +182,7 @@ spa_alsa_sink_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -271,11 +272,11 @@ spa_alsa_clear_buffers (SpaALSASink *this)
}
static SpaResult
spa_alsa_sink_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_alsa_sink_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaALSASink *this;
SpaPODBuilder b = { NULL };
@ -590,7 +591,7 @@ static const SpaNode alsasink_node = {
spa_alsa_sink_node_get_props,
spa_alsa_sink_node_set_props,
spa_alsa_sink_node_send_command,
spa_alsa_sink_node_set_event_callback,
spa_alsa_sink_node_set_callbacks,
spa_alsa_sink_node_get_n_ports,
spa_alsa_sink_node_get_port_ids,
spa_alsa_sink_node_add_port,

View file

@ -101,7 +101,7 @@ do_send_event (SpaLoop *loop,
{
SpaALSASource *this = user_data;
this->event_cb (&this->node, data, this->user_data);
this->callbacks.event (&this->node, data, this->user_data);
return SPA_RESULT_OK;
}
@ -204,9 +204,10 @@ spa_alsa_source_node_send_command (SpaNode *node,
}
static SpaResult
spa_alsa_source_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_alsa_source_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaALSASource *this;
@ -214,7 +215,7 @@ spa_alsa_source_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -319,11 +320,11 @@ spa_alsa_clear_buffers (SpaALSASource *this)
}
static SpaResult
spa_alsa_source_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_alsa_source_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaALSASource *this;
SpaPODBuilder b = { NULL };
@ -631,7 +632,7 @@ static const SpaNode alsasource_node = {
spa_alsa_source_node_get_props,
spa_alsa_source_node_set_props,
spa_alsa_source_node_send_command,
spa_alsa_source_node_set_event_callback,
spa_alsa_source_node_set_callbacks,
spa_alsa_source_node_get_n_ports,
spa_alsa_source_node_get_port_ids,
spa_alsa_source_node_add_port,

View file

@ -213,7 +213,7 @@ spa_alsa_enum_format (SpaALSAState *state,
}
int
spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, SpaPortFormatFlags flags)
spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, uint32_t flags)
{
unsigned int rrate, rchannels;
snd_pcm_uframes_t period_size;
@ -336,13 +336,11 @@ pull_frames (SpaALSAState *state,
SpaPortIO *io = state->io;
if (spa_list_is_empty (&state->ready) && do_pull) {
SpaEvent event = SPA_EVENT_INIT (state->type.event_node.NeedInput);
io->status = SPA_RESULT_NEED_BUFFER;
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->event_cb (&state->node, &event, state->user_data);
state->callbacks.need_input (&state->node, state->user_data);
}
while (!spa_list_is_empty (&state->ready) && to_write > 0) {
uint8_t *src, *dst;
@ -389,14 +387,11 @@ pull_frames (SpaALSAState *state,
reuse = (state->ready_offset >= size);
}
if (reuse) {
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->type.event_node.ReuseBuffer,
0, b->outbuf->id);
spa_list_remove (&b->link);
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->event_cb (&state->node, (SpaEvent *)&rb, state->user_data);
state->callbacks.reuse_buffer (&state->node, 0, b->outbuf->id, state->user_data);
state->ready_offset = 0;
}
total_frames += n_frames;
@ -450,13 +445,10 @@ push_frames (SpaALSAState *state,
d[0].chunk->stride = 0;
{
SpaEvent event = SPA_EVENT_INIT (state->type.event_node.HaveOutput);
b->outstanding = true;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_HAVE_BUFFER;
state->event_cb (&state->node, &event, state->user_data);
state->callbacks.have_output (&state->node, state->user_data);
}
}
return total_frames;

View file

@ -121,7 +121,7 @@ struct _SpaALSAState {
snd_pcm_stream_t stream;
snd_output_t *output;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
uint8_t props_buffer[1024];
@ -185,7 +185,7 @@ spa_alsa_enum_format (SpaALSAState *state,
int spa_alsa_set_format (SpaALSAState *state,
SpaAudioInfo *info,
SpaPortFormatFlags flags);
uint32_t flags);
SpaResult spa_alsa_start (SpaALSAState *state, bool xrun_recover);
SpaResult spa_alsa_pause (SpaALSAState *state, bool xrun_recover);

View file

@ -88,7 +88,7 @@ struct _SpaAudioMixer {
SpaTypeMap *map;
SpaLog *log;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
int port_count;
@ -161,9 +161,10 @@ spa_audiomixer_node_send_command (SpaNode *node,
}
static SpaResult
spa_audiomixer_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_audiomixer_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaAudioMixer *this;
@ -171,7 +172,7 @@ spa_audiomixer_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -335,11 +336,11 @@ clear_buffers (SpaAudioMixer *this, SpaAudioMixerPort *port)
}
static SpaResult
spa_audiomixer_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_audiomixer_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaAudioMixer *this;
SpaAudioMixerPort *port;
@ -789,7 +790,7 @@ static const SpaNode audiomixer_node = {
spa_audiomixer_node_get_props,
spa_audiomixer_node_set_props,
spa_audiomixer_node_send_command,
spa_audiomixer_node_set_event_callback,
spa_audiomixer_node_set_callbacks,
spa_audiomixer_node_get_n_ports,
spa_audiomixer_node_get_port_ids,
spa_audiomixer_node_add_port,

View file

@ -122,7 +122,7 @@ struct _SpaAudioTestSrc {
uint8_t props_buffer[512];
SpaAudioTestSrcProps props;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
SpaSource timer_source;
@ -238,13 +238,11 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
static inline SpaResult
send_have_output (SpaAudioTestSrc *this)
{
if (this->event_cb) {
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
this->event_cb (&this->node, &event, this->user_data);
}
if (this->callbacks.have_output)
this->callbacks.have_output (&this->node, this->user_data);
return SPA_RESULT_OK;
}
@ -419,9 +417,10 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
}
static SpaResult
spa_audiotestsrc_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event_cb,
void *user_data)
spa_audiotestsrc_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaAudioTestSrc *this;
@ -429,7 +428,7 @@ spa_audiotestsrc_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
this->event_cb = event_cb;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -556,11 +555,11 @@ clear_buffers (SpaAudioTestSrc *this)
}
static SpaResult
spa_audiotestsrc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_audiotestsrc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaAudioTestSrc *this;
@ -870,7 +869,7 @@ static const SpaNode audiotestsrc_node = {
spa_audiotestsrc_node_get_props,
spa_audiotestsrc_node_set_props,
spa_audiotestsrc_node_send_command,
spa_audiotestsrc_node_set_event_callback,
spa_audiotestsrc_node_set_callbacks,
spa_audiotestsrc_node_get_n_ports,
spa_audiotestsrc_node_get_port_ids,
spa_audiotestsrc_node_add_port,

View file

@ -76,7 +76,7 @@ struct _SpaFFMpegDec {
SpaTypeMap *map;
SpaLog *log;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
SpaFFMpegPort in_ports[1];
@ -127,9 +127,10 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
}
static SpaResult
spa_ffmpeg_dec_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_ffmpeg_dec_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaFFMpegDec *this;
@ -138,7 +139,7 @@ spa_ffmpeg_dec_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -231,11 +232,11 @@ spa_ffmpeg_dec_node_port_enum_formats (SpaNode *node,
}
static SpaResult
spa_ffmpeg_dec_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_ffmpeg_dec_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaFFMpegDec *this;
SpaFFMpegPort *port;
@ -453,7 +454,7 @@ static const SpaNode ffmpeg_dec_node = {
spa_ffmpeg_dec_node_get_props,
spa_ffmpeg_dec_node_set_props,
spa_ffmpeg_dec_node_send_command,
spa_ffmpeg_dec_node_set_event_callback,
spa_ffmpeg_dec_node_set_callbacks,
spa_ffmpeg_dec_node_get_n_ports,
spa_ffmpeg_dec_node_get_port_ids,
spa_ffmpeg_dec_node_add_port,
@ -520,8 +521,8 @@ spa_ffmpeg_dec_init (SpaHandle *handle,
this->node = ffmpeg_dec_node;
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
this->in_ports[0].info.flags = 0;
this->out_ports[0].info.flags = 0;
return SPA_RESULT_OK;
}

View file

@ -81,7 +81,7 @@ struct _SpaFFMpegEnc {
SpaTypeMap *map;
SpaLog *log;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
SpaFFMpegPort in_ports[1];
@ -128,9 +128,10 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
}
static SpaResult
spa_ffmpeg_enc_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_ffmpeg_enc_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaFFMpegEnc *this;
@ -139,7 +140,7 @@ spa_ffmpeg_enc_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -235,11 +236,11 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaNode *node,
}
static SpaResult
spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaFFMpegEnc *this;
SpaFFMpegPort *port;
@ -456,7 +457,7 @@ static const SpaNode ffmpeg_enc_node = {
spa_ffmpeg_enc_node_get_props,
spa_ffmpeg_enc_node_set_props,
spa_ffmpeg_enc_node_send_command,
spa_ffmpeg_enc_node_set_event_callback,
spa_ffmpeg_enc_node_set_callbacks,
spa_ffmpeg_enc_node_get_n_ports,
spa_ffmpeg_enc_node_get_port_ids,
spa_ffmpeg_enc_node_add_port,
@ -522,8 +523,8 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
this->node = ffmpeg_enc_node;
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
this->in_ports[0].info.flags = 0;
this->out_ports[0].info.flags = 0;
return SPA_RESULT_OK;
}

View file

@ -161,7 +161,7 @@ struct _SpaV4l2Source {
uint8_t props_buffer[512];
SpaV4l2SourceProps props;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
SpaV4l2State state[1];
@ -244,7 +244,7 @@ do_pause_done (SpaLoop *loop,
if (SPA_RESULT_IS_OK (ac->body.res.value))
ac->body.res.value = spa_v4l2_stream_off (this);
this->event_cb (&this->node, (SpaEvent *)ac, this->user_data);
this->callbacks.event (&this->node, (SpaEvent *)ac, this->user_data);
return SPA_RESULT_OK;
}
@ -290,7 +290,7 @@ do_start_done (SpaLoop *loop,
SpaV4l2Source *this = user_data;
SpaEventNodeAsyncComplete *ac = data;
this->event_cb (&this->node, (SpaEvent *)ac, this->user_data);
this->callbacks.event (&this->node, (SpaEvent *)ac, this->user_data);
return SPA_RESULT_OK;
}
@ -381,9 +381,10 @@ spa_v4l2_source_node_send_command (SpaNode *node,
}
static SpaResult
spa_v4l2_source_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_v4l2_source_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaV4l2Source *this;
@ -391,7 +392,7 @@ spa_v4l2_source_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -474,11 +475,11 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node,
}
static SpaResult
spa_v4l2_source_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_v4l2_source_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaV4l2Source *this;
SpaV4l2State *state;
@ -823,7 +824,7 @@ static const SpaNode v4l2source_node = {
spa_v4l2_source_node_get_props,
spa_v4l2_source_node_set_props,
spa_v4l2_source_node_send_command,
spa_v4l2_source_node_set_event_callback,
spa_v4l2_source_node_set_callbacks,
spa_v4l2_source_node_get_n_ports,
spa_v4l2_source_node_get_port_ids,
spa_v4l2_source_node_add_port,

View file

@ -972,15 +972,11 @@ mmap_read (SpaV4l2Source *this)
d[0].chunk->size = buf.bytesused;
d[0].chunk->stride = state->fmt.fmt.pix.bytesperline;
{
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
b->outstanding = true;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_HAVE_BUFFER;
this->callbacks.have_output (&this->node, this->user_data);
b->outstanding = true;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_HAVE_BUFFER;
this->event_cb (&this->node, &event, this->user_data);
}
return SPA_RESULT_OK;
}

View file

@ -114,7 +114,7 @@ struct _SpaVideoTestSrc {
uint8_t props_buffer[512];
SpaVideoTestSrcProps props;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
SpaSource timer_source;
@ -221,13 +221,11 @@ spa_videotestsrc_node_set_props (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
static inline SpaResult
send_have_output (SpaVideoTestSrc *this)
{
if (this->event_cb) {
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
this->event_cb (&this->node, &event, this->user_data);
}
if (this->callbacks.have_output)
this->callbacks.have_output (&this->node, this->user_data);
return SPA_RESULT_OK;
}
@ -381,9 +379,10 @@ spa_videotestsrc_node_send_command (SpaNode *node,
}
static SpaResult
spa_videotestsrc_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event_cb,
void *user_data)
spa_videotestsrc_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaVideoTestSrc *this;
@ -391,7 +390,7 @@ spa_videotestsrc_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this->event_cb = event_cb;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -523,11 +522,11 @@ clear_buffers (SpaVideoTestSrc *this)
}
static SpaResult
spa_videotestsrc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_videotestsrc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaVideoTestSrc *this;
@ -831,7 +830,7 @@ static const SpaNode videotestsrc_node = {
spa_videotestsrc_node_get_props,
spa_videotestsrc_node_set_props,
spa_videotestsrc_node_send_command,
spa_videotestsrc_node_set_event_callback,
spa_videotestsrc_node_set_callbacks,
spa_videotestsrc_node_get_n_ports,
spa_videotestsrc_node_get_port_ids,
spa_videotestsrc_node_add_port,

View file

@ -109,7 +109,7 @@ struct _SpaVolume {
uint8_t props_buffer[512];
SpaVolumeProps props;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
uint8_t format_buffer[1024];
@ -215,9 +215,10 @@ spa_volume_node_send_command (SpaNode *node,
}
static SpaResult
spa_volume_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_volume_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaVolume *this;
@ -225,7 +226,7 @@ spa_volume_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaVolume, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -352,11 +353,11 @@ clear_buffers (SpaVolume *this, SpaVolumePort *port)
}
static SpaResult
spa_volume_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_volume_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaVolume *this;
SpaVolumePort *port;
@ -623,12 +624,10 @@ find_free_buffer (SpaVolume *this, SpaVolumePort *port)
return b->outbuf;
}
static void
static inline void
release_buffer (SpaVolume *this, SpaBuffer *buffer)
{
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (this->type.event_node.ReuseBuffer,
0, buffer->id);
this->event_cb (&this->node, (SpaEvent *)&rb, this->user_data);
this->callbacks.reuse_buffer (&this->node, 0, buffer->id, this->user_data);
}
static void
@ -740,7 +739,7 @@ static const SpaNode volume_node = {
spa_volume_node_get_props,
spa_volume_node_set_props,
spa_volume_node_send_command,
spa_volume_node_set_event_callback,
spa_volume_node_set_callbacks,
spa_volume_node_get_n_ports,
spa_volume_node_get_port_ids,
spa_volume_node_add_port,

View file

@ -106,7 +106,7 @@ struct _SpaXvSink {
uint8_t props_buffer[512];
SpaXvSinkProps props;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
bool have_format;
@ -196,9 +196,10 @@ spa_xv_sink_node_send_command (SpaNode *node,
}
static SpaResult
spa_xv_sink_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_xv_sink_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaXvSink *this;
@ -207,7 +208,7 @@ spa_xv_sink_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -298,11 +299,11 @@ spa_xv_sink_node_port_enum_formats (SpaNode *node,
}
static SpaResult
spa_xv_sink_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_xv_sink_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaXvSink *this;
@ -482,7 +483,7 @@ static const SpaNode xvsink_node = {
spa_xv_sink_node_get_props,
spa_xv_sink_node_set_props,
spa_xv_sink_node_send_command,
spa_xv_sink_node_set_event_callback,
spa_xv_sink_node_set_callbacks,
spa_xv_sink_node_get_n_ports,
spa_xv_sink_node_get_port_ids,
spa_xv_sink_node_add_port,
@ -561,7 +562,7 @@ xv_sink_init (const SpaHandleFactory *factory,
this->node = xvsink_node;
reset_xv_sink_props (&this->props);
this->info.flags = SPA_PORT_INFO_FLAG_NONE;
this->info.flags = 0;
return SPA_RESULT_OK;
}

View file

@ -217,52 +217,61 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name, boo
static void
on_sink_event (SpaNode *node, SpaEvent *event, void *user_data)
{
printf ("got event %d\n", SPA_EVENT_TYPE (event));
}
static void
on_sink_need_input (SpaNode *node, void *user_data)
{
AppData *data = user_data;
SpaResult res;
if (SPA_EVENT_TYPE (event) == data->type.event_node.NeedInput) {
res = spa_node_process_output (data->mix);
if (res == SPA_RESULT_NEED_BUFFER) {
if (data->source1_mix_io[0].status == SPA_RESULT_NEED_BUFFER) {
res = spa_node_process_output (data->source1);
if (res != SPA_RESULT_HAVE_BUFFER)
printf ("got process_output error from source1 %d\n", res);
}
if (data->source2_mix_io[0].status == SPA_RESULT_NEED_BUFFER) {
res = spa_node_process_output (data->source2);
if (res != SPA_RESULT_HAVE_BUFFER)
printf ("got process_output error from source2 %d\n", res);
}
res = spa_node_process_input (data->mix);
if (res == SPA_RESULT_HAVE_BUFFER)
goto push;
else
printf ("got process_input error from mixer %d\n", res);
} else if (res == SPA_RESULT_HAVE_BUFFER) {
push:
if ((res = spa_node_process_input (data->sink)) < 0)
printf ("got process_input error from sink %d\n", res);
} else {
printf ("got process_output error from mixer %d\n", res);
res = spa_node_process_output (data->mix);
if (res == SPA_RESULT_NEED_BUFFER) {
if (data->source1_mix_io[0].status == SPA_RESULT_NEED_BUFFER) {
res = spa_node_process_output (data->source1);
if (res != SPA_RESULT_HAVE_BUFFER)
printf ("got process_output error from source1 %d\n", res);
}
}
else if (SPA_EVENT_TYPE (event) == data->type.event_node.ReuseBuffer) {
SpaEventNodeReuseBuffer *rb = (SpaEventNodeReuseBuffer *) event;
data->mix_sink_io[0].buffer_id = rb->body.buffer_id.value;
}
else {
printf ("got event %d\n", SPA_EVENT_TYPE (event));
if (data->source2_mix_io[0].status == SPA_RESULT_NEED_BUFFER) {
res = spa_node_process_output (data->source2);
if (res != SPA_RESULT_HAVE_BUFFER)
printf ("got process_output error from source2 %d\n", res);
}
res = spa_node_process_input (data->mix);
if (res == SPA_RESULT_HAVE_BUFFER)
goto push;
else
printf ("got process_input error from mixer %d\n", res);
} else if (res == SPA_RESULT_HAVE_BUFFER) {
push:
if ((res = spa_node_process_input (data->sink)) < 0)
printf ("got process_input error from sink %d\n", res);
} else {
printf ("got process_output error from mixer %d\n", res);
}
}
static void
on_sink_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
{
AppData *data = user_data;
data->mix_sink_io[0].buffer_id = buffer_id;
}
static const SpaNodeCallbacks sink_callbacks =
{
&on_sink_event,
&on_sink_need_input,
NULL,
&on_sink_reuse_buffer
};
static SpaResult
do_add_source (SpaLoop *loop,
SpaSource *source)
@ -313,7 +322,7 @@ make_nodes (AppData *data, const char *device)
printf ("can't create alsa-sink: %d\n", res);
return res;
}
spa_node_set_event_callback (data->sink, on_sink_event, data);
spa_node_set_callbacks (data->sink, &sink_callbacks, sizeof (sink_callbacks), data);
spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_props (&b, &f[0], data->type.props,

View file

@ -209,28 +209,38 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name, boo
static void
on_sink_event (SpaNode *node, SpaEvent *event, void *user_data)
{
printf ("got event %d\n", SPA_EVENT_TYPE (event));
}
static void
on_sink_need_input (SpaNode *node, void *user_data)
{
AppData *data = user_data;
SpaResult res;
if (SPA_EVENT_TYPE (event) == data->type.event_node.NeedInput) {
res = spa_node_process_output (data->source);
if (res != SPA_RESULT_HAVE_BUFFER)
printf ("got process_output error from source %d\n", res);
res = spa_node_process_output (data->source);
if (res != SPA_RESULT_HAVE_BUFFER)
printf ("got process_output error from source %d\n", res);
if ((res = spa_node_process_input (data->sink)) < 0)
printf ("got process_input error from sink %d\n", res);
}
else if (SPA_EVENT_TYPE (event) == data->type.event_node.ReuseBuffer) {
SpaEventNodeReuseBuffer *rb = (SpaEventNodeReuseBuffer *) event;
data->source_sink_io[0].buffer_id = rb->body.buffer_id.value;
}
else {
printf ("got event %d\n", SPA_EVENT_TYPE (event));
}
if ((res = spa_node_process_input (data->sink)) < 0)
printf ("got process_input error from sink %d\n", res);
}
static void
on_sink_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
{
AppData *data = user_data;
data->source_sink_io[0].buffer_id = buffer_id;
}
static const SpaNodeCallbacks sink_callbacks = {
&on_sink_event,
&on_sink_need_input,
NULL,
&on_sink_reuse_buffer
};
static SpaResult
do_add_source (SpaLoop *loop,
SpaSource *source)
@ -281,7 +291,7 @@ make_nodes (AppData *data)
printf ("can't create alsa-sink: %d\n", res);
return res;
}
spa_node_set_event_callback (data->sink, on_sink_event, data);
spa_node_set_callbacks (data->sink, &sink_callbacks, sizeof (sink_callbacks), data);
spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_props (&b, &f[0], data->type.props,

View file

@ -183,76 +183,87 @@ on_source_event (SpaNode *node, SpaEvent *event, void *user_data)
handle_events (data);
if (SPA_EVENT_TYPE (event) == data->type.event_node.HaveOutput) {
SpaResult res;
SpaBuffer *b;
void *sdata, *ddata;
int sstride, dstride;
int i;
uint8_t *src, *dst;
SpaMeta *metas;
SpaData *datas;
SpaPortIO *io = &data->source_output[0];
b = data->bp[io->buffer_id];
metas = b->metas;
datas = b->datas;
if (metas[1].type == data->type.meta.Pointer &&
((SpaMetaPointer *)metas[1].data)->type == data->type.SDL_Texture) {
SDL_Texture *texture;
texture = ((SpaMetaPointer *)metas[1].data)->ptr;
SDL_UnlockTexture(texture);
SDL_RenderClear (data->renderer);
SDL_RenderCopy (data->renderer, texture, NULL, NULL);
SDL_RenderPresent (data->renderer);
if (SDL_LockTexture (texture, NULL, &sdata, &sstride) < 0) {
fprintf (stderr, "Couldn't lock texture: %s\n", SDL_GetError());
return;
}
datas[0].type = data->type.data.MemPtr;
datas[0].flags = 0;
datas[0].fd = -1;
datas[0].mapoffset = 0;
datas[0].maxsize = sstride * 240;
datas[0].data = sdata;
datas[0].chunk->offset = 0;
datas[0].chunk->size = sstride * 240;
datas[0].chunk->stride = sstride;
} else {
if (SDL_LockTexture (data->texture, NULL, &ddata, &dstride) < 0) {
fprintf (stderr, "Couldn't lock texture: %s\n", SDL_GetError());
return;
}
sdata = datas[0].data;
sstride = datas[0].chunk->stride;
for (i = 0; i < 240; i++) {
src = ((uint8_t*)sdata + i * sstride);
dst = ((uint8_t*)ddata + i * dstride);
memcpy (dst, src, SPA_MIN (sstride, dstride));
}
SDL_UnlockTexture(data->texture);
SDL_RenderClear (data->renderer);
SDL_RenderCopy (data->renderer, data->texture, NULL, NULL);
SDL_RenderPresent (data->renderer);
}
io->status = SPA_RESULT_NEED_BUFFER;
if ((res = spa_node_process_output (data->source)) < 0)
printf ("got pull error %d\n", res);
}
else {
printf ("got event %d\n", SPA_EVENT_TYPE (event));
}
printf ("got event %d\n", SPA_EVENT_TYPE (event));
}
static void
on_source_have_output (SpaNode *node, void *user_data)
{
AppData *data = user_data;
SpaResult res;
SpaBuffer *b;
void *sdata, *ddata;
int sstride, dstride;
int i;
uint8_t *src, *dst;
SpaMeta *metas;
SpaData *datas;
SpaPortIO *io = &data->source_output[0];
handle_events (data);
b = data->bp[io->buffer_id];
metas = b->metas;
datas = b->datas;
if (metas[1].type == data->type.meta.Pointer &&
((SpaMetaPointer *)metas[1].data)->type == data->type.SDL_Texture) {
SDL_Texture *texture;
texture = ((SpaMetaPointer *)metas[1].data)->ptr;
SDL_UnlockTexture(texture);
SDL_RenderClear (data->renderer);
SDL_RenderCopy (data->renderer, texture, NULL, NULL);
SDL_RenderPresent (data->renderer);
if (SDL_LockTexture (texture, NULL, &sdata, &sstride) < 0) {
fprintf (stderr, "Couldn't lock texture: %s\n", SDL_GetError());
return;
}
datas[0].type = data->type.data.MemPtr;
datas[0].flags = 0;
datas[0].fd = -1;
datas[0].mapoffset = 0;
datas[0].maxsize = sstride * 240;
datas[0].data = sdata;
datas[0].chunk->offset = 0;
datas[0].chunk->size = sstride * 240;
datas[0].chunk->stride = sstride;
} else {
if (SDL_LockTexture (data->texture, NULL, &ddata, &dstride) < 0) {
fprintf (stderr, "Couldn't lock texture: %s\n", SDL_GetError());
return;
}
sdata = datas[0].data;
sstride = datas[0].chunk->stride;
for (i = 0; i < 240; i++) {
src = ((uint8_t*)sdata + i * sstride);
dst = ((uint8_t*)ddata + i * dstride);
memcpy (dst, src, SPA_MIN (sstride, dstride));
}
SDL_UnlockTexture(data->texture);
SDL_RenderClear (data->renderer);
SDL_RenderCopy (data->renderer, data->texture, NULL, NULL);
SDL_RenderPresent (data->renderer);
}
io->status = SPA_RESULT_NEED_BUFFER;
if ((res = spa_node_process_output (data->source)) < 0)
printf ("got pull error %d\n", res);
}
static const SpaNodeCallbacks source_callbacks = {
&on_source_event,
NULL,
&on_source_have_output,
NULL
};
static SpaResult
do_add_source (SpaLoop *loop,
SpaSource *source)
@ -301,7 +312,7 @@ make_nodes (AppData *data, const char *device)
printf ("can't create v4l2-source: %d\n", res);
return res;
}
spa_node_set_event_callback (data->source, on_source_event, data);
spa_node_set_callbacks (data->source, &source_callbacks, sizeof (source_callbacks), data);
spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_props (&b, &f[0], data->type.props,