mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
node: improve callbacks
Make separate callbacks for events and RT notifications.
This commit is contained in:
parent
fb0919b8b7
commit
3b33e3d362
32 changed files with 557 additions and 481 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* Simple Plugin API
|
||||
/* Pinos
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Simple Plugin API
|
||||
/* Pinos
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Simple Plugin API
|
||||
/* Pinos
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
@ -233,7 +233,7 @@ typedef struct {
|
|||
uint32_t seq,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
uint32_t flags,
|
||||
const SpaFormat *format);
|
||||
void (*set_property) (void *object,
|
||||
uint32_t seq,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Simple Plugin API
|
||||
/* Pinos
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Simple Plugin API
|
||||
/* Pinos
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ static inline void
|
|||
send_have_output (PinosStream *stream)
|
||||
{
|
||||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||
SpaEvent ho = SPA_EVENT_INIT (stream->context->type.event_node.HaveOutput);
|
||||
SpaEvent ho = SPA_EVENT_INIT (stream->context->type.event_transport.HaveOutput);
|
||||
uint64_t cmd = 1;
|
||||
|
||||
pinos_transport_add_event (impl->trans, &ho);
|
||||
|
|
@ -483,7 +483,7 @@ handle_rtnode_event (PinosStream *stream,
|
|||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||
PinosContext *context = impl->this.context;
|
||||
|
||||
if (SPA_EVENT_TYPE (event) == context->type.event_node.HaveOutput) {
|
||||
if (SPA_EVENT_TYPE (event) == context->type.event_transport.HaveOutput) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < impl->trans->area->n_inputs; i++) {
|
||||
|
|
@ -498,7 +498,7 @@ handle_rtnode_event (PinosStream *stream,
|
|||
}
|
||||
send_need_input (stream);
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == context->type.event_node.NeedInput) {
|
||||
else if (SPA_EVENT_TYPE (event) == context->type.event_transport.NeedInput) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < impl->trans->area->n_outputs; i++) {
|
||||
|
|
@ -516,8 +516,8 @@ handle_rtnode_event (PinosStream *stream,
|
|||
pinos_signal_emit (&stream->need_buffer, stream);
|
||||
impl->in_need_buffer = false;
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == context->type.event_node.ReuseBuffer) {
|
||||
SpaEventNodeReuseBuffer *p = (SpaEventNodeReuseBuffer *) event;
|
||||
else if (SPA_EVENT_TYPE (event) == context->type.event_transport.ReuseBuffer) {
|
||||
PinosEventTransportReuseBuffer *p = (PinosEventTransportReuseBuffer *) event;
|
||||
|
||||
if (p->body.port_id.value != impl->port_id)
|
||||
return;
|
||||
|
|
@ -699,12 +699,12 @@ client_node_remove_port (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_set_format (void *object,
|
||||
uint32_t seq,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
client_node_set_format (void *object,
|
||||
uint32_t seq,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
uint32_t flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
PinosProxy *proxy = object;
|
||||
PinosStream *stream = proxy->user_data;
|
||||
|
|
@ -1138,8 +1138,8 @@ pinos_stream_recycle_buffer (PinosStream *stream,
|
|||
uint32_t id)
|
||||
{
|
||||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (stream->context->type.event_node.ReuseBuffer,
|
||||
impl->port_id, id);
|
||||
PinosEventTransportReuseBuffer rb = PINOS_EVENT_TRANSPORT_REUSE_BUFFER_INIT
|
||||
(stream->context->type.event_transport.ReuseBuffer, impl->port_id, id);
|
||||
BufferId *bid;
|
||||
uint64_t cmd = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Simple Plugin API
|
||||
/* Pinos
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
@ -83,6 +83,46 @@ SpaResult pinos_transport_next_event (PinosTransport *trans,
|
|||
SpaResult pinos_transport_parse_event (PinosTransport *trans,
|
||||
void *event);
|
||||
|
||||
#define PINOS_TYPE_EVENT__Transport SPA_TYPE_EVENT_BASE "Transport"
|
||||
#define PINOS_TYPE_EVENT_TRANSPORT_BASE PINOS_TYPE_EVENT__Transport ":"
|
||||
|
||||
#define PINOS_TYPE_EVENT_TRANSPORT__HaveOutput PINOS_TYPE_EVENT_TRANSPORT_BASE "HaveOutput"
|
||||
#define PINOS_TYPE_EVENT_TRANSPORT__NeedInput PINOS_TYPE_EVENT_TRANSPORT_BASE "NeedInput"
|
||||
#define PINOS_TYPE_EVENT_TRANSPORT__ReuseBuffer PINOS_TYPE_EVENT_TRANSPORT_BASE "ReuseBuffer"
|
||||
|
||||
typedef struct {
|
||||
uint32_t HaveOutput;
|
||||
uint32_t NeedInput;
|
||||
uint32_t ReuseBuffer;
|
||||
} PinosTypeEventTransport;
|
||||
|
||||
static inline void
|
||||
pinos_type_event_transport_map (SpaTypeMap *map, PinosTypeEventTransport *type)
|
||||
{
|
||||
if (type->HaveOutput == 0) {
|
||||
type->HaveOutput = spa_type_map_get_id (map, PINOS_TYPE_EVENT_TRANSPORT__HaveOutput);
|
||||
type->NeedInput = spa_type_map_get_id (map, PINOS_TYPE_EVENT_TRANSPORT__NeedInput);
|
||||
type->ReuseBuffer = spa_type_map_get_id (map, PINOS_TYPE_EVENT_TRANSPORT__ReuseBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
SpaPODObjectBody body;
|
||||
SpaPODInt port_id;
|
||||
SpaPODInt buffer_id;
|
||||
} PinosEventTransportReuseBufferBody;
|
||||
|
||||
typedef struct {
|
||||
SpaPOD pod;
|
||||
PinosEventTransportReuseBufferBody body;
|
||||
} PinosEventTransportReuseBuffer;
|
||||
|
||||
#define PINOS_EVENT_TRANSPORT_REUSE_BUFFER_INIT(type,port_id,buffer_id) \
|
||||
SPA_EVENT_INIT_COMPLEX (sizeof (PinosEventTransportReuseBufferBody), type, \
|
||||
SPA_POD_INT_INIT (port_id), \
|
||||
SPA_POD_INT_INIT (buffer_id))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ pinos_type_init (PinosType *type)
|
|||
spa_type_alloc_param_buffers_map (type->map, &type->alloc_param_buffers);
|
||||
spa_type_alloc_param_meta_enable_map (type->map, &type->alloc_param_meta_enable);
|
||||
spa_type_alloc_param_video_padding_map (type->map, &type->alloc_param_video_padding);
|
||||
|
||||
pinos_type_event_transport_map (type->map, &type->event_transport);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -24,13 +24,15 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pinos/client/map.h>
|
||||
#include <spa/include/spa/type-map.h>
|
||||
#include <spa/include/spa/event-node.h>
|
||||
#include <spa/include/spa/command-node.h>
|
||||
#include <spa/include/spa/monitor.h>
|
||||
#include <spa/include/spa/alloc-param.h>
|
||||
|
||||
#include <pinos/client/map.h>
|
||||
#include <pinos/client/transport.h>
|
||||
|
||||
typedef struct _PinosType PinosType;
|
||||
|
||||
/**
|
||||
|
|
@ -64,6 +66,7 @@ struct _PinosType {
|
|||
SpaTypeAllocParamBuffers alloc_param_buffers;
|
||||
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
|
||||
SpaTypeAllocParamVideoPadding alloc_param_video_padding;
|
||||
PinosTypeEventTransport event_transport;
|
||||
};
|
||||
|
||||
void pinos_type_init (PinosType *type);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Simple Plugin API
|
||||
/* Pinos
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ struct _SpaProxy
|
|||
SpaLoop *main_loop;
|
||||
SpaLoop *data_loop;
|
||||
|
||||
SpaEventNodeCallback event_cb;
|
||||
SpaNodeCallbacks callbacks;
|
||||
void *user_data;
|
||||
|
||||
PinosResource *resource;
|
||||
|
|
@ -172,7 +172,7 @@ static inline void
|
|||
send_need_input (SpaProxy *this)
|
||||
{
|
||||
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, proxy);
|
||||
SpaEvent event = SPA_EVENT_INIT (impl->core->type.event_node.NeedInput);
|
||||
SpaEvent event = SPA_EVENT_INIT (impl->core->type.event_transport.NeedInput);
|
||||
|
||||
pinos_transport_add_event (impl->transport, &event);
|
||||
do_flush (this);
|
||||
|
|
@ -182,7 +182,7 @@ static inline void
|
|||
send_have_output (SpaProxy *this)
|
||||
{
|
||||
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, proxy);
|
||||
SpaEvent event = SPA_EVENT_INIT (impl->core->type.event_node.HaveOutput);
|
||||
SpaEvent event = SPA_EVENT_INIT (impl->core->type.event_transport.HaveOutput);
|
||||
|
||||
pinos_transport_add_event (impl->transport, &event);
|
||||
do_flush (this);
|
||||
|
|
@ -225,9 +225,10 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_proxy_node_set_event_callback (SpaNode *node,
|
||||
SpaEventNodeCallback event,
|
||||
void *user_data)
|
||||
spa_proxy_node_set_callbacks (SpaNode *node,
|
||||
const SpaNodeCallbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
{
|
||||
SpaProxy *this;
|
||||
|
||||
|
|
@ -235,7 +236,7 @@ spa_proxy_node_set_event_callback (SpaNode *node,
|
|||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaProxy, node);
|
||||
this->event_cb = event;
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -484,11 +485,11 @@ next:
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_proxy_node_port_set_format (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
spa_proxy_node_port_set_format (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
uint32_t flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaProxy *this;
|
||||
|
||||
|
|
@ -768,8 +769,8 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
|
|||
|
||||
spa_log_trace (this->log, "reuse buffer %d", buffer_id);
|
||||
{
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (impl->core->type.event_node.ReuseBuffer,
|
||||
port_id, buffer_id);
|
||||
PinosEventTransportReuseBuffer rb = PINOS_EVENT_TRANSPORT_REUSE_BUFFER_INIT
|
||||
(impl->core->type.event_transport.ReuseBuffer, port_id, buffer_id);
|
||||
pinos_transport_add_event (impl->transport, (SpaEvent *)&rb);
|
||||
}
|
||||
|
||||
|
|
@ -840,8 +841,8 @@ spa_proxy_node_process_output (SpaNode *node)
|
|||
continue;
|
||||
|
||||
if (io->buffer_id != SPA_ID_INVALID) {
|
||||
SpaEventNodeReuseBuffer rb =
|
||||
SPA_EVENT_NODE_REUSE_BUFFER_INIT (impl->core->type.event_node.ReuseBuffer, i, io->buffer_id);
|
||||
PinosEventTransportReuseBuffer rb =
|
||||
PINOS_EVENT_TRANSPORT_REUSE_BUFFER_INIT (impl->core->type.event_transport.ReuseBuffer, i, io->buffer_id);
|
||||
|
||||
spa_log_trace (this->log, "reuse buffer %d", io->buffer_id);
|
||||
|
||||
|
|
@ -875,7 +876,7 @@ handle_node_event (SpaProxy *this,
|
|||
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, proxy);
|
||||
int i;
|
||||
|
||||
if (SPA_EVENT_TYPE (event) == impl->core->type.event_node.HaveOutput) {
|
||||
if (SPA_EVENT_TYPE (event) == impl->core->type.event_transport.HaveOutput) {
|
||||
for (i = 0; i < MAX_OUTPUTS; i++) {
|
||||
SpaPortIO *io = this->out_ports[i].io;
|
||||
|
||||
|
|
@ -885,8 +886,15 @@ handle_node_event (SpaProxy *this,
|
|||
*io = impl->transport->outputs[i];
|
||||
pinos_log_trace ("%d %d", io->status, io->buffer_id);
|
||||
}
|
||||
this->callbacks.have_output (&this->node, this->user_data);
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == impl->core->type.event_transport.NeedInput) {
|
||||
this->callbacks.need_input (&this->node, this->user_data);
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == impl->core->type.event_transport.ReuseBuffer) {
|
||||
PinosEventTransportReuseBuffer *p = (PinosEventTransportReuseBuffer *) event;
|
||||
this->callbacks.reuse_buffer (&this->node, p->body.port_id.value, p->body.buffer_id.value, this->user_data);
|
||||
}
|
||||
this->event_cb (&this->node, event, this->user_data);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -958,7 +966,7 @@ client_node_event (void *object,
|
|||
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (node, PinosClientNodeImpl, this);
|
||||
SpaProxy *this = &impl->proxy;
|
||||
|
||||
handle_node_event (this, event);
|
||||
this->callbacks.event (&this->node, event, this->user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -996,7 +1004,7 @@ proxy_on_data_fd_events (SpaSource *source)
|
|||
while (pinos_transport_next_event (impl->transport, &event) == SPA_RESULT_OK) {
|
||||
SpaEvent *ev = alloca (SPA_POD_SIZE (&event));
|
||||
pinos_transport_parse_event (impl->transport, ev);
|
||||
this->event_cb (&this->node, ev, this->user_data);
|
||||
handle_node_event (this, ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1007,7 +1015,7 @@ static const SpaNode proxy_node = {
|
|||
spa_proxy_node_get_props,
|
||||
spa_proxy_node_set_props,
|
||||
spa_proxy_node_send_command,
|
||||
spa_proxy_node_set_event_callback,
|
||||
spa_proxy_node_set_callbacks,
|
||||
spa_proxy_node_get_n_ports,
|
||||
spa_proxy_node_get_port_ids,
|
||||
spa_proxy_node_add_port,
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
|
|||
PinosLinkImpl *impl = SPA_CONTAINER_OF (this, PinosLinkImpl, this);
|
||||
SpaResult res;
|
||||
const SpaPortInfo *iinfo, *oinfo;
|
||||
SpaPortInfoFlags in_flags, out_flags;
|
||||
uint32_t in_flags, out_flags;
|
||||
char *error = NULL;
|
||||
|
||||
if (in_state != PINOS_PORT_STATE_READY && out_state != PINOS_PORT_STATE_READY)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,6 @@ typedef struct
|
|||
{
|
||||
PinosNode this;
|
||||
|
||||
#define STATE_IN 0
|
||||
#define STATE_OUT 1
|
||||
int state;
|
||||
PinosWorkQueue *work;
|
||||
|
||||
bool async_init;
|
||||
|
|
@ -295,15 +292,15 @@ do_pull (PinosNode *this)
|
|||
res = do_pull (outport->node);
|
||||
pinos_log_trace ("node %p: pull return %d", outport->node, res);
|
||||
}
|
||||
else if (res < 0 && res != SPA_RESULT_HAVE_BUFFER) {
|
||||
pinos_log_warn ("node %p: got process output %d", outport->node, res);
|
||||
}
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER) {
|
||||
else if (res == SPA_RESULT_HAVE_BUFFER) {
|
||||
*pi = *po;
|
||||
pinos_log_trace ("node %p: have output %d %d", this, pi->status, pi->buffer_id);
|
||||
have_output = true;
|
||||
}
|
||||
else if (res < 0) {
|
||||
pinos_log_warn ("node %p: got process output %d", outport->node, res);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (have_output) {
|
||||
|
|
@ -326,69 +323,80 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
|
|||
pinos_work_queue_complete (impl->work, this, ac->body.seq.value, ac->body.res.value);
|
||||
pinos_signal_emit (&this->async_complete, this, ac->body.seq.value, ac->body.res.value);
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == this->core->type.event_node.NeedInput) {
|
||||
do_pull (this);
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == this->core->type.event_node.HaveOutput) {
|
||||
SpaResult res;
|
||||
PinosPort *outport;
|
||||
|
||||
spa_list_for_each (outport, &this->output_ports, link) {
|
||||
PinosLink *link;
|
||||
SpaPortIO *po;
|
||||
|
||||
po = &outport->io;
|
||||
if (po->buffer_id == SPA_ID_INVALID)
|
||||
continue;
|
||||
|
||||
pinos_log_trace ("node %p: have output %d", this, po->buffer_id);
|
||||
|
||||
spa_list_for_each (link, &outport->rt.links, rt.output_link) {
|
||||
PinosPort *inport;
|
||||
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
inport = link->rt.input;
|
||||
inport->io = *po;
|
||||
|
||||
pinos_log_trace ("node %p: do process input %d", this, po->buffer_id);
|
||||
|
||||
if ((res = spa_node_process_input (inport->node->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process input %d", inport->node, res);
|
||||
|
||||
}
|
||||
po->status = SPA_RESULT_NEED_BUFFER;
|
||||
}
|
||||
res = spa_node_process_output (this->node);
|
||||
if (res < 0 && res != SPA_RESULT_HAVE_BUFFER)
|
||||
pinos_log_warn ("node %p: got process output %d", this, res);
|
||||
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == this->core->type.event_node.ReuseBuffer) {
|
||||
SpaEventNodeReuseBuffer *rb = (SpaEventNodeReuseBuffer *) event;
|
||||
PinosPort *inport;
|
||||
|
||||
pinos_log_trace ("node %p: reuse buffer %u", this, rb->body.buffer_id.value);
|
||||
|
||||
spa_list_for_each (inport, &this->input_ports, link) {
|
||||
PinosLink *link;
|
||||
PinosPort *outport;
|
||||
|
||||
spa_list_for_each (link, &inport->rt.links, rt.input_link) {
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
outport = link->rt.output;
|
||||
outport->io.buffer_id = rb->body.buffer_id.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (SPA_EVENT_TYPE (event) == this->core->type.event_node.RequestClockUpdate) {
|
||||
send_clock_update (this);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_node_need_input (SpaNode *node, void *user_data)
|
||||
{
|
||||
PinosNode *this = user_data;
|
||||
|
||||
do_pull (this);
|
||||
}
|
||||
|
||||
static void
|
||||
on_node_have_output (SpaNode *node, void *user_data)
|
||||
{
|
||||
PinosNode *this = user_data;
|
||||
SpaResult res;
|
||||
PinosPort *outport;
|
||||
|
||||
spa_list_for_each (outport, &this->output_ports, link) {
|
||||
PinosLink *link;
|
||||
SpaPortIO *po;
|
||||
|
||||
po = &outport->io;
|
||||
if (po->buffer_id == SPA_ID_INVALID)
|
||||
continue;
|
||||
|
||||
pinos_log_trace ("node %p: have output %d", this, po->buffer_id);
|
||||
|
||||
spa_list_for_each (link, &outport->rt.links, rt.output_link) {
|
||||
PinosPort *inport;
|
||||
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
inport = link->rt.input;
|
||||
inport->io = *po;
|
||||
|
||||
pinos_log_trace ("node %p: do process input %d", this, po->buffer_id);
|
||||
|
||||
if ((res = spa_node_process_input (inport->node->node)) < 0)
|
||||
pinos_log_warn ("node %p: got process input %d", inport->node, res);
|
||||
|
||||
}
|
||||
po->status = SPA_RESULT_NEED_BUFFER;
|
||||
}
|
||||
res = spa_node_process_output (this->node);
|
||||
if (res != SPA_RESULT_OK)
|
||||
pinos_log_warn ("node %p: got process output %d", this, res);
|
||||
}
|
||||
|
||||
static void
|
||||
on_node_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data)
|
||||
{
|
||||
PinosNode *this = user_data;
|
||||
PinosPort *inport;
|
||||
|
||||
pinos_log_trace ("node %p: reuse buffer %u", this, buffer_id);
|
||||
|
||||
spa_list_for_each (inport, &this->input_ports, link) {
|
||||
PinosLink *link;
|
||||
PinosPort *outport;
|
||||
|
||||
spa_list_for_each (link, &inport->rt.links, rt.input_link) {
|
||||
if (link->rt.input == NULL || link->rt.output == NULL)
|
||||
continue;
|
||||
|
||||
outport = link->rt.output;
|
||||
outport->io.buffer_id = buffer_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
node_unbind_func (void *data)
|
||||
{
|
||||
|
|
@ -514,6 +522,13 @@ pinos_node_set_data_loop (PinosNode *node,
|
|||
pinos_signal_emit (&node->loop_changed, node);
|
||||
}
|
||||
|
||||
static const SpaNodeCallbacks node_callbacks = {
|
||||
&on_node_event,
|
||||
&on_node_need_input,
|
||||
&on_node_have_output,
|
||||
&on_node_reuse_buffer,
|
||||
};
|
||||
|
||||
PinosNode *
|
||||
pinos_node_new (PinosCore *core,
|
||||
PinosClient *owner,
|
||||
|
|
@ -546,7 +561,7 @@ pinos_node_new (PinosCore *core,
|
|||
|
||||
spa_list_init (&this->resource_list);
|
||||
|
||||
if (spa_node_set_event_callback (this->node, on_node_event, this) < 0)
|
||||
if (spa_node_set_callbacks (this->node, &node_callbacks, sizeof (node_callbacks), this) < 0)
|
||||
pinos_log_warn ("node %p: error setting callback", this);
|
||||
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
|
|
|
|||
|
|
@ -607,12 +607,12 @@ client_node_marshal_remove_port (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_marshal_set_format (void *object,
|
||||
uint32_t seq,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaPortFormatFlags flags,
|
||||
const SpaFormat *format)
|
||||
client_node_marshal_set_format (void *object,
|
||||
uint32_t seq,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
uint32_t flags,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
PinosResource *resource = object;
|
||||
PinosConnection *connection = resource->client->protocol_private;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue