mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Optimize transport some more
We can optimize the transport some more if we allow the host to configure the area used for transfering buffers. We can then also place the current status in the area and avoid calling get_status(). We can also allocate this area in shared memory, avoiding a memcpy in the client-node.
This commit is contained in:
parent
b774b99db5
commit
e88a376d7c
21 changed files with 903 additions and 989 deletions
|
|
@ -72,17 +72,24 @@ typedef enum {
|
|||
SPA_PORT_FORMAT_FLAG_NEAREST = (1 << 2),
|
||||
} SpaPortFormatFlags;
|
||||
|
||||
typedef enum {
|
||||
SPA_PORT_STATE_FLAG_NONE = 0,
|
||||
SPA_PORT_STATE_FLAG_HAVE_FORMAT = 1 << 0,
|
||||
SPA_PORT_STATE_FLAG_HAVE_BUFFERS = 1 << 1,
|
||||
} SpaPortStateFlags;
|
||||
|
||||
/**
|
||||
* SpaPortInputFlags:
|
||||
* @SPA_INPUT_FLAG_NONE: no flag
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_PORT_INPUT_FLAG_NONE = 0,
|
||||
SPA_PORT_INPUT_FLAG_NONE = 0,
|
||||
SPA_PORT_INPUT_FLAG_NEED_INPUT = 1 << 0,
|
||||
} SpaPortInputFlags;
|
||||
|
||||
/**
|
||||
* SpaPortInputInfo:
|
||||
* @port_id: the port id
|
||||
* SpaPortInput:
|
||||
* @state: the port state
|
||||
* @flags: extra flags
|
||||
* @buffer_id: a buffer id
|
||||
* @status: status
|
||||
|
|
@ -90,44 +97,44 @@ typedef enum {
|
|||
* Input information for a node.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
SpaPortStateFlags state;
|
||||
SpaPortInputFlags flags;
|
||||
uint32_t buffer_id;
|
||||
SpaResult status;
|
||||
} SpaPortInputInfo;
|
||||
} SpaPortInput;
|
||||
|
||||
/**
|
||||
* SpaPortOutputFlags:
|
||||
* @SPA_PORT_OUTPUT_FLAG_NONE: no flag
|
||||
* @SPA_PORT_OUTPUT_FLAG_PULL: force a #SPA_NODE_EVENT_NEED_INPUT event on the
|
||||
* peer input ports when no data is available.
|
||||
* @SPA_PORT_OUTPUT_FLAG_DISCARD: discard the buffer data
|
||||
* @SPA_PORT_OUTPUT_FLAG_NO_BUFFER: no buffer was produced on the port
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_PORT_OUTPUT_FLAG_NONE = 0,
|
||||
SPA_PORT_OUTPUT_FLAG_PULL = (1 << 0),
|
||||
SPA_PORT_OUTPUT_FLAG_DISCARD = (1 << 1),
|
||||
SPA_PORT_OUTPUT_FLAG_NO_BUFFER = (1 << 2),
|
||||
SPA_PORT_OUTPUT_FLAG_HAVE_OUTPUT = (1 << 0),
|
||||
SPA_PORT_OUTPUT_FLAG_PULL = (1 << 1),
|
||||
} SpaPortOutputFlags;
|
||||
|
||||
/**
|
||||
* SpaPortOutputInfo:
|
||||
* @port_id: the port id
|
||||
* SpaPortOutput:
|
||||
* @state: the port state
|
||||
* @flags: extra flags
|
||||
* @buffer_id: a buffer id will be set
|
||||
* @event: output event
|
||||
* @status: a status
|
||||
* @status: the status
|
||||
*
|
||||
* Output information for a node.
|
||||
* Output information for a port on a node. This is allocated
|
||||
* by the host and configured on all output ports for which output is
|
||||
* requested.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
SpaPortStateFlags state;
|
||||
uint64_t latency;
|
||||
SpaPortOutputFlags flags;
|
||||
uint32_t buffer_id;
|
||||
SpaNodeEvent *event;
|
||||
SpaResult status;
|
||||
} SpaPortOutputInfo;
|
||||
} SpaPortOutput;
|
||||
|
||||
/**
|
||||
* SpaNodeEventCallback:
|
||||
|
|
@ -496,57 +503,40 @@ struct _SpaNode {
|
|||
SpaBuffer **buffers,
|
||||
unsigned int *n_buffers);
|
||||
|
||||
SpaResult (*port_get_status) (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status);
|
||||
/**
|
||||
* SpaNode::port_set_input:
|
||||
* @port_id: an input port id
|
||||
* @input: a #SpaPortInput
|
||||
*
|
||||
* Configure the given input structure on the input @port_id. This
|
||||
* structure is allocated by the host and is used to query the state
|
||||
* of the port and transfer buffers into the port.
|
||||
*
|
||||
* Setting an @input of %NULL will disable the port.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
*/
|
||||
SpaResult (*port_set_input) (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input);
|
||||
|
||||
/**
|
||||
* SpaNode::port_push_input:
|
||||
* @node: a #SpaNode
|
||||
* @n_info: number of #SpaPortInputInfo in @info
|
||||
* @info: array of #SpaPortInputInfo
|
||||
* SpaNode::port_set_output:
|
||||
* @port_id: an output port id
|
||||
* @output: a #SpaPortOutput
|
||||
*
|
||||
* Push a buffer id into one or more input ports of @node.
|
||||
* Configure the given output structure on the output @port_id. This
|
||||
* structure is allocated by the host and is used to query the state
|
||||
* of the port and transfer buffers and events into the port.
|
||||
*
|
||||
* This function must be called from the data thread.
|
||||
* Setting an @output of %NULL will disable the port.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node or info is %NULL
|
||||
* #SPA_RESULT_ERROR when one or more of the @info has an
|
||||
* error result. Check the status of all the
|
||||
* @info.
|
||||
* #SPA_RESULT_HAVE_ENOUGH_INPUT when output can be produced.
|
||||
*/
|
||||
SpaResult (*port_push_input) (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info);
|
||||
/**
|
||||
* SpaNode::port_pull_output:
|
||||
* @node: a #SpaNode
|
||||
* @n_info: number of #SpaPortOutputInfo in @info
|
||||
* @info: array of #SpaPortOutputInfo
|
||||
*
|
||||
* Pull a buffer id from one or more output ports of @node.
|
||||
*
|
||||
* This function must be called from the data thread.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node or info is %NULL
|
||||
* #SPA_RESULT_PORTS_CHANGED the number of ports has changed. None
|
||||
* of the @info fields are modified
|
||||
* #SPA_RESULT_FORMAT_CHANGED a format changed on some port.
|
||||
* the ports that changed are marked in the status.
|
||||
* #SPA_RESULT_PROPERTIES_CHANGED port properties changed. The
|
||||
* changed ports are marked in the status.
|
||||
* #SPA_RESULT_ERROR when one or more of the @info has an
|
||||
* error result. Check the status of all the @info.
|
||||
* #SPA_RESULT_NEED_MORE_INPUT when no output can be produced
|
||||
* because more input is needed.
|
||||
*/
|
||||
SpaResult (*port_pull_output) (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info);
|
||||
SpaResult (*port_set_output) (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output);
|
||||
|
||||
/**
|
||||
* SpaNode::port_reuse_buffer:
|
||||
* @node: a #SpaNode
|
||||
|
|
@ -568,6 +558,18 @@ struct _SpaNode {
|
|||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command);
|
||||
/**
|
||||
* SpaNode::process:
|
||||
* @node: a #SpaNode
|
||||
* @flags: process flags
|
||||
*
|
||||
* Process the node.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_HAVE_ENOUGH_INPUT when output can be produced.
|
||||
*/
|
||||
SpaResult (*process_input) (SpaNode *node);
|
||||
SpaResult (*process_output) (SpaNode *node);
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -587,11 +589,12 @@ struct _SpaNode {
|
|||
#define spa_node_port_set_props(n,...) (n)->port_set_props((n),__VA_ARGS__)
|
||||
#define spa_node_port_use_buffers(n,...) (n)->port_use_buffers((n),__VA_ARGS__)
|
||||
#define spa_node_port_alloc_buffers(n,...) (n)->port_alloc_buffers((n),__VA_ARGS__)
|
||||
#define spa_node_port_get_status(n,...) (n)->port_get_status((n),__VA_ARGS__)
|
||||
#define spa_node_port_push_input(n,...) (n)->port_push_input((n),__VA_ARGS__)
|
||||
#define spa_node_port_pull_output(n,...) (n)->port_pull_output((n),__VA_ARGS__)
|
||||
#define spa_node_port_set_input(n,...) (n)->port_set_input((n),__VA_ARGS__)
|
||||
#define spa_node_port_set_output(n,...) (n)->port_set_output((n),__VA_ARGS__)
|
||||
#define spa_node_port_reuse_buffer(n,...) (n)->port_reuse_buffer((n),__VA_ARGS__)
|
||||
#define spa_node_port_send_command(n,...) (n)->port_send_command((n),__VA_ARGS__)
|
||||
#define spa_node_process_input(n) (n)->process_input((n))
|
||||
#define spa_node_process_output(n) (n)->process_output((n))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
typedef struct _SpaALSAState SpaALSASink;
|
||||
|
||||
static const char default_device[] = "default";
|
||||
static const uint32_t default_buffer_time = 10000;
|
||||
static const uint32_t default_buffer_time = 4000;
|
||||
static const uint32_t default_period_time = 1000;
|
||||
static const bool default_period_event = 0;
|
||||
|
||||
|
|
@ -590,88 +590,31 @@ spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_alsa_sink_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*status = &this->status;
|
||||
this->io = input;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
spa_alsa_sink_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
SpaALSABuffer *b;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
if (!this->have_format) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (info[i].buffer_id >= this->n_buffers) {
|
||||
info[i].status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
b = &this->buffers[info[i].buffer_id];
|
||||
if (!b->outstanding) {
|
||||
info[i].status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
if (this->ringbuffer) {
|
||||
this->ringbuffer->outstanding = true;
|
||||
this->ringbuffer = b;
|
||||
} else {
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->ready, SpaALSABuffer, next, b);
|
||||
}
|
||||
b->outstanding = false;
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -721,6 +664,55 @@ spa_alsa_sink_node_port_send_command (SpaNode *node,
|
|||
return res;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_process_input (SpaNode *node)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
SpaPortInput *input;
|
||||
SpaALSABuffer *b;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
|
||||
if ((input = this->io) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if (!this->have_format) {
|
||||
input->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
if (input->buffer_id >= this->n_buffers) {
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
b = &this->buffers[input->buffer_id];
|
||||
if (!b->outstanding) {
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
if (this->ringbuffer) {
|
||||
this->ringbuffer->outstanding = true;
|
||||
this->ringbuffer = b;
|
||||
} else {
|
||||
b->next = NULL;
|
||||
SPA_QUEUE_PUSH_TAIL (&this->ready, SpaALSABuffer, next, b);
|
||||
}
|
||||
b->outstanding = false;
|
||||
input->status = SPA_RESULT_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_process_output (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
|
||||
static const SpaNode alsasink_node = {
|
||||
sizeof (SpaNode),
|
||||
|
|
@ -742,11 +734,12 @@ static const SpaNode alsasink_node = {
|
|||
spa_alsa_sink_node_port_set_props,
|
||||
spa_alsa_sink_node_port_use_buffers,
|
||||
spa_alsa_sink_node_port_alloc_buffers,
|
||||
spa_alsa_sink_node_port_get_status,
|
||||
spa_alsa_sink_node_port_push_input,
|
||||
spa_alsa_sink_node_port_pull_output,
|
||||
spa_alsa_sink_node_port_set_input,
|
||||
spa_alsa_sink_node_port_set_output,
|
||||
spa_alsa_sink_node_port_reuse_buffer,
|
||||
spa_alsa_sink_node_port_send_command,
|
||||
spa_alsa_sink_node_process_input,
|
||||
spa_alsa_sink_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -815,8 +808,6 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
reset_alsa_sink_props (&this->props[1]);
|
||||
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
for (i = 0; info && i < info->n_items; i++) {
|
||||
if (!strcmp (info->items[i].key, "alsa.card")) {
|
||||
snprintf (this->props[1].device, 63, "hw:%s", info->items[i].value);
|
||||
|
|
|
|||
|
|
@ -631,80 +631,31 @@ spa_alsa_source_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_source_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*status = &this->status;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_source_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
spa_alsa_source_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_source_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
spa_alsa_source_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
SpaALSABuffer *b;
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this->have_format) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, SpaALSABuffer, next, b);
|
||||
if (b == NULL) {
|
||||
info[i].status = SPA_RESULT_UNEXPECTED;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
info[i].buffer_id = b->outbuf->id;
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
spa_log_trace (this->log, "pull buffer %u", b->outbuf->id);
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
this->io = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -773,6 +724,46 @@ spa_alsa_source_node_port_send_command (SpaNode *node,
|
|||
return res;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_source_node_process_input (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_source_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
SpaPortOutput *output;
|
||||
SpaALSABuffer *b;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
||||
output = this->io;
|
||||
|
||||
if (!this->have_format) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, SpaALSABuffer, next, b);
|
||||
if (b == NULL) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
spa_log_trace (this->log, "pull buffer %u", b->outbuf->id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode alsasource_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -793,11 +784,12 @@ static const SpaNode alsasource_node = {
|
|||
spa_alsa_source_node_port_set_props,
|
||||
spa_alsa_source_node_port_use_buffers,
|
||||
spa_alsa_source_node_port_alloc_buffers,
|
||||
spa_alsa_source_node_port_get_status,
|
||||
spa_alsa_source_node_port_push_input,
|
||||
spa_alsa_source_node_port_pull_output,
|
||||
spa_alsa_source_node_port_set_input,
|
||||
spa_alsa_source_node_port_set_output,
|
||||
spa_alsa_source_node_port_reuse_buffer,
|
||||
spa_alsa_source_node_port_send_command,
|
||||
spa_alsa_source_node_process_input,
|
||||
spa_alsa_source_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -916,8 +908,6 @@ alsa_source_init (const SpaHandleFactory *factory,
|
|||
this->stream = SND_PCM_STREAM_CAPTURE;
|
||||
reset_alsa_props (&this->props[1]);
|
||||
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
|
||||
for (i = 0; info && i < info->n_items; i++) {
|
||||
if (!strcmp (info->items[i].key, "alsa.card")) {
|
||||
snprintf (this->props[1].device, 63, "hw:%s", info->items[i].value);
|
||||
|
|
|
|||
|
|
@ -371,10 +371,11 @@ mmap_write (SpaALSAState *state)
|
|||
snd_pcm_sframes_t avail;
|
||||
snd_pcm_uframes_t offset, frames, size;
|
||||
const snd_pcm_channel_area_t *my_areas;
|
||||
snd_pcm_status_t *status;
|
||||
SpaNodeEventNeedInput ni;
|
||||
|
||||
#if 0
|
||||
snd_pcm_status_t *status;
|
||||
|
||||
snd_pcm_status_alloca (&status);
|
||||
|
||||
if ((err = snd_pcm_status (hndl, status)) < 0) {
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ struct _SpaALSAState {
|
|||
SpaAllocParamBuffers param_buffers;
|
||||
SpaAllocParamMetaEnable param_meta;
|
||||
SpaAllocParamMetaEnableRingbuffer param_meta_rb;
|
||||
SpaPortStatus status;
|
||||
void *io;
|
||||
|
||||
SpaALSABuffer buffers[MAX_BUFFERS];
|
||||
unsigned int n_buffers;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ typedef struct {
|
|||
SpaFormatAudio format[2];
|
||||
SpaAudioMixerPortProps props[2];
|
||||
SpaPortInfo info;
|
||||
SpaPortStatus status;
|
||||
size_t buffer_index;
|
||||
size_t buffer_offset;
|
||||
size_t buffer_queued;
|
||||
|
|
@ -63,6 +62,7 @@ typedef struct {
|
|||
SpaBuffer **buffers;
|
||||
unsigned int n_buffers;
|
||||
SpaBuffer *buffer;
|
||||
void *io;
|
||||
} SpaAudioMixerPort;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -274,10 +274,6 @@ spa_audiomixer_node_add_port (SpaNode *node,
|
|||
SPA_PORT_INFO_FLAG_REMOVABLE |
|
||||
SPA_PORT_INFO_FLAG_OPTIONAL |
|
||||
SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
this->in_ports[port_id].status.flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
|
||||
this->out_ports[0].status.flags &= ~SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -287,23 +283,25 @@ spa_audiomixer_node_remove_port (SpaNode *node,
|
|||
uint32_t port_id)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
SpaPortInput *input;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
if (!CHECK_IN_PORT (this, direction, port_id))
|
||||
if (!CHECK_IN_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
this->in_ports[port_id].valid = false;
|
||||
this->port_count--;
|
||||
if (this->in_ports[port_id].buffer) {
|
||||
this->in_ports[port_id].buffer = NULL;
|
||||
|
||||
input = this->in_ports[port_id].io;
|
||||
if (input && input->buffer_id) {
|
||||
this->port_queued--;
|
||||
}
|
||||
if (this->port_count == this->port_queued)
|
||||
this->out_ports[0].status.flags |= SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
((SpaPortOutput*)this->out_ports[0].io)->flags |= SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -473,90 +471,102 @@ spa_audiomixer_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_audiomixer_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
SpaAudioMixerPort *port;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[0];
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*status = &port->status;
|
||||
this->in_ports[port_id].io = input;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
spa_audiomixer_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
if (this->out_ports[0].status.flags & SPA_PORT_STATUS_FLAG_HAVE_OUTPUT)
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
this->out_ports[port_id].io = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_reuse_buffer (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_process_input (SpaNode *node)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
SpaPortOutput *output;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
if ((output = this->out_ports[0].io) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if (output->flags & SPA_PORT_STATUS_FLAG_HAVE_OUTPUT)
|
||||
return SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
SpaBuffer *buffer;
|
||||
SpaAudioMixerPort *port;
|
||||
int idx = info[i].port_id;
|
||||
this->port_queued = 0;
|
||||
|
||||
if (!CHECK_IN_PORT (this, SPA_DIRECTION_INPUT, idx)) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
for (i = 0; i < MAX_PORTS; i++) {
|
||||
SpaAudioMixerPort *port = &this->in_ports[i];
|
||||
SpaPortInput *input;
|
||||
|
||||
if ((input = port->io) == NULL)
|
||||
continue;
|
||||
|
||||
if (input->buffer_id >= port->n_buffers) {
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
port = &this->in_ports[idx];
|
||||
buffer = port->buffers[info[i].buffer_id];
|
||||
|
||||
if (buffer == NULL) {
|
||||
info[i].status = SPA_RESULT_INVALID_ARGUMENTS;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
if (!port->have_format) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (port->buffer != NULL) {
|
||||
info[i].status = SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
port->buffer = buffer;
|
||||
port->buffer_queued = 0;
|
||||
port->buffer_index = 0;
|
||||
port->buffer_offset = 0;
|
||||
this->port_queued++;
|
||||
|
||||
if (this->port_queued == this->port_count)
|
||||
this->out_ports[0].status.flags |= SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
port->buffer = port->buffers[port->n_buffers];
|
||||
input->status = SPA_RESULT_OK;
|
||||
this->port_queued++;
|
||||
}
|
||||
if (this->port_queued == this->port_count)
|
||||
output->flags |= SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
|
|
@ -565,7 +575,7 @@ spa_audiomixer_node_port_push_input (SpaNode *node,
|
|||
|
||||
|
||||
static void
|
||||
pull_port (SpaAudioMixer *this, uint32_t port_id, SpaPortOutputInfo *info, size_t pull_size)
|
||||
pull_port (SpaAudioMixer *this, uint32_t port_id, SpaPortOutput *output, size_t pull_size)
|
||||
{
|
||||
SpaNodeEventNeedInput ni;
|
||||
|
||||
|
|
@ -606,8 +616,8 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port)
|
|||
if ((is -= chunk) == 0) {
|
||||
if (++port->buffer_index == port->buffer->n_datas) {
|
||||
port->buffer = NULL;
|
||||
port->status.flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
this->out_ports[0].status.flags &= ~SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
((SpaPortInput*)port->io)->flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
((SpaPortOutput*)this->out_ports[0].io)->flags = SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
break;
|
||||
}
|
||||
port->buffer_offset = 0;
|
||||
|
|
@ -626,14 +636,11 @@ add_port_data (SpaAudioMixer *this, SpaBuffer *out, SpaAudioMixerPort *port)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
mix_data (SpaAudioMixer *this, SpaPortOutputInfo *info)
|
||||
mix_data (SpaAudioMixer *this, SpaPortOutput *output)
|
||||
{
|
||||
int i, min_size, min_port, pull_size;
|
||||
SpaBuffer *buf;
|
||||
|
||||
if (info->port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
pull_size = 0;
|
||||
|
||||
min_size = 0;
|
||||
|
|
@ -643,8 +650,8 @@ mix_data (SpaAudioMixer *this, SpaPortOutputInfo *info)
|
|||
continue;
|
||||
|
||||
if (this->in_ports[i].buffer == NULL) {
|
||||
if (pull_size && info->flags & SPA_PORT_OUTPUT_FLAG_PULL) {
|
||||
pull_port (this, i, info, pull_size);
|
||||
if (pull_size && output->flags & SPA_PORT_OUTPUT_FLAG_PULL) {
|
||||
pull_port (this, i, output, pull_size);
|
||||
}
|
||||
if (this->in_ports[i].buffer == NULL)
|
||||
return SPA_RESULT_NEED_MORE_INPUT;
|
||||
|
|
@ -659,10 +666,11 @@ mix_data (SpaAudioMixer *this, SpaPortOutputInfo *info)
|
|||
return SPA_RESULT_NEED_MORE_INPUT;
|
||||
|
||||
buf = this->in_ports[min_port].buffer;
|
||||
info->buffer_id = buf->id;
|
||||
output->buffer_id = buf->id;
|
||||
this->in_ports[min_port].buffer = NULL;
|
||||
this->in_ports[min_port].status.flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
this->out_ports[0].status.flags &= ~SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
((SpaPortInput*)this->in_ports[min_port].io)->flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
((SpaPortOutput*)this->out_ports[0].io)->flags &= ~SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
for (i = 0; i < MAX_PORTS; i++) {
|
||||
if (!this->in_ports[i].valid || this->in_ports[i].buffer == NULL)
|
||||
|
|
@ -674,61 +682,33 @@ mix_data (SpaAudioMixer *this, SpaPortOutputInfo *info)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
spa_audiomixer_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
SpaAudioMixerPort *port;
|
||||
int i;
|
||||
bool have_error = false;
|
||||
SpaPortOutput *output;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, info->port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = &this->out_ports[info->port_id];
|
||||
port = &this->out_ports[0];
|
||||
if ((output = port->io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
// if (!(this->ports[0].status.flags & SPA_PORT_STATUS_FLAG_HAVE_OUTPUT))
|
||||
// if (!(output->flags & SPA_PORT_STATUS_FLAG_HAVE_OUTPUT))
|
||||
// return SPA_RESULT_NEED_MORE_INPUT;
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if ((info[i].status = mix_data (this, &info[i])) < 0) {
|
||||
spa_log_error (this->log, "error mixing: %d", info[i].status);
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (have_error)
|
||||
if ((output->status = mix_data (this, output)) < 0)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_reuse_buffer (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static const SpaNode audiomixer_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -749,11 +729,12 @@ static const SpaNode audiomixer_node = {
|
|||
spa_audiomixer_node_port_set_props,
|
||||
spa_audiomixer_node_port_use_buffers,
|
||||
spa_audiomixer_node_port_alloc_buffers,
|
||||
spa_audiomixer_node_port_get_status,
|
||||
spa_audiomixer_node_port_push_input,
|
||||
spa_audiomixer_node_port_pull_output,
|
||||
spa_audiomixer_node_port_set_input,
|
||||
spa_audiomixer_node_port_set_output,
|
||||
spa_audiomixer_node_port_reuse_buffer,
|
||||
spa_audiomixer_node_port_send_command,
|
||||
spa_audiomixer_node_process_input,
|
||||
spa_audiomixer_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ struct _SpaAudioTestSrc {
|
|||
SpaAllocParam *params[2];
|
||||
SpaAllocParamBuffers param_buffers;
|
||||
SpaAllocParamMetaEnable param_meta;
|
||||
SpaPortStatus status;
|
||||
|
||||
bool have_format;
|
||||
SpaFormatAudio query_format;
|
||||
|
|
@ -96,6 +95,8 @@ struct _SpaAudioTestSrc {
|
|||
ATSBuffer buffers[MAX_BUFFERS];
|
||||
unsigned int n_buffers;
|
||||
|
||||
SpaPortOutput *output;
|
||||
|
||||
bool started;
|
||||
uint64_t start_time;
|
||||
uint64_t elapsed_time;
|
||||
|
|
@ -743,84 +744,34 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_audiotestsrc_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL || output == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*status = &this->status;
|
||||
this->output = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
ATSBuffer *b;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this->have_format) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, ATSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
info[i].status = SPA_RESULT_UNEXPECTED;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
info[i].buffer_id = b->outbuf->id;
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
|
|
@ -866,6 +817,39 @@ spa_audiotestsrc_node_port_send_command (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_process_input (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
SpaPortOutput *output;
|
||||
ATSBuffer *b;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
if ((output = this->output) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, ATSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode audiotestsrc_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -886,11 +870,12 @@ static const SpaNode audiotestsrc_node = {
|
|||
spa_audiotestsrc_node_port_set_props,
|
||||
spa_audiotestsrc_node_port_use_buffers,
|
||||
spa_audiotestsrc_node_port_alloc_buffers,
|
||||
spa_audiotestsrc_node_port_get_status,
|
||||
spa_audiotestsrc_node_port_push_input,
|
||||
spa_audiotestsrc_node_port_pull_output,
|
||||
spa_audiotestsrc_node_port_set_input,
|
||||
spa_audiotestsrc_node_port_set_output,
|
||||
spa_audiotestsrc_node_port_reuse_buffer,
|
||||
spa_audiotestsrc_node_port_send_command,
|
||||
spa_audiotestsrc_node_process_input,
|
||||
spa_audiotestsrc_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -1045,8 +1030,6 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
if (this->props[1].live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->node.state = SPA_NODE_STATE_CONFIGURE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ typedef struct {
|
|||
SpaPortInfo info;
|
||||
SpaAllocParam *params[1];
|
||||
SpaAllocParamBuffers param_buffers;
|
||||
SpaPortStatus status;
|
||||
void *io;
|
||||
} SpaFFMpegPort;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -418,69 +418,74 @@ spa_ffmpeg_dec_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_ffmpeg_dec_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
SpaFFMpegPort *port;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
|
||||
if (!IS_VALID_PORT (this, direction, port_id))
|
||||
if (!IS_VALID_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*status = &port->status;
|
||||
this->in_ports[port_id].io = input;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
spa_ffmpeg_dec_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
|
||||
if (!IS_VALID_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
this->out_ports[port_id].io = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_process_input (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
spa_ffmpeg_dec_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
SpaFFMpegPort *port;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
SpaPortOutput *output;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
port = &this->out_ports[info[i].port_id];
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if (port->current_format == NULL) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
if ((output = port->io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
if (port->current_format == NULL) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -528,11 +533,12 @@ static const SpaNode ffmpeg_dec_node = {
|
|||
spa_ffmpeg_dec_node_port_set_props,
|
||||
spa_ffmpeg_dec_node_port_use_buffers,
|
||||
spa_ffmpeg_dec_node_port_alloc_buffers,
|
||||
spa_ffmpeg_dec_node_port_get_status,
|
||||
spa_ffmpeg_dec_node_port_push_input,
|
||||
spa_ffmpeg_dec_node_port_pull_output,
|
||||
spa_ffmpeg_dec_node_port_set_input,
|
||||
spa_ffmpeg_dec_node_port_set_output,
|
||||
spa_ffmpeg_dec_node_port_reuse_buffer,
|
||||
spa_ffmpeg_dec_node_port_send_command,
|
||||
spa_ffmpeg_dec_node_process_input,
|
||||
spa_ffmpeg_dec_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -586,10 +592,7 @@ spa_ffmpeg_dec_init (SpaHandle *handle,
|
|||
reset_ffmpeg_dec_props (&this->props[1]);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->in_ports[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->out_ports[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,10 +63,9 @@ typedef struct {
|
|||
SpaPortInfo info;
|
||||
SpaAllocParam *params[1];
|
||||
SpaAllocParamBuffers param_buffers;
|
||||
SpaPortStatus status;
|
||||
void *io;
|
||||
} SpaFFMpegPort;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
} URI;
|
||||
|
|
@ -84,8 +83,8 @@ struct _SpaFFMpegEnc {
|
|||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
SpaFFMpegPort in_ports[0];
|
||||
SpaFFMpegPort out_ports[0];
|
||||
SpaFFMpegPort in_ports[1];
|
||||
SpaFFMpegPort out_ports[1];
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -427,69 +426,41 @@ spa_ffmpeg_enc_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_ffmpeg_enc_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
SpaFFMpegPort *port;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
|
||||
|
||||
if (!IS_VALID_PORT (this, direction, port_id))
|
||||
if (!IS_VALID_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*status = &port->status;
|
||||
this->in_ports[port_id].io = input;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
spa_ffmpeg_enc_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
SpaFFMpegPort *port;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
|
||||
|
||||
if (!IS_VALID_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
port = &this->out_ports[info[i].port_id];
|
||||
|
||||
if (port->current_format == NULL) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
this->out_ports[port_id].io = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -517,6 +488,38 @@ spa_ffmpeg_enc_node_port_send_command (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_process_input (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
SpaFFMpegPort *port;
|
||||
SpaPortOutput *output;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
|
||||
|
||||
if ((output = this->out_ports[0].io) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if (port->current_format == NULL) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode ffmpeg_enc_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -537,11 +540,12 @@ static const SpaNode ffmpeg_enc_node = {
|
|||
spa_ffmpeg_enc_node_port_set_props,
|
||||
spa_ffmpeg_enc_node_port_use_buffers,
|
||||
spa_ffmpeg_enc_node_port_alloc_buffers,
|
||||
spa_ffmpeg_enc_node_port_get_status,
|
||||
spa_ffmpeg_enc_node_port_push_input,
|
||||
spa_ffmpeg_enc_node_port_pull_output,
|
||||
spa_ffmpeg_enc_node_port_set_input,
|
||||
spa_ffmpeg_enc_node_port_set_output,
|
||||
spa_ffmpeg_enc_node_port_reuse_buffer,
|
||||
spa_ffmpeg_enc_node_port_send_command,
|
||||
spa_ffmpeg_enc_node_process_input,
|
||||
spa_ffmpeg_enc_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -595,10 +599,7 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
|
|||
reset_ffmpeg_enc_props (&this->props[1]);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->in_ports[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->out_ports[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->node.state = SPA_NODE_STATE_CONFIGURE;
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ typedef struct {
|
|||
SpaAllocParam *params[2];
|
||||
SpaAllocParamBuffers param_buffers;
|
||||
SpaAllocParamMetaEnable param_meta;
|
||||
SpaPortStatus status;
|
||||
void *io;
|
||||
|
||||
int64_t last_ticks;
|
||||
int64_t last_monotonic;
|
||||
|
|
@ -741,81 +741,33 @@ spa_v4l2_source_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_v4l2_source_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*status = &this->state[port_id].status;
|
||||
this->state[port_id].io = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
SpaV4l2State *state;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
V4l2Buffer *b;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
state = &this->state[info[i].port_id];
|
||||
|
||||
if (state->current_format == NULL) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&state->ready, V4l2Buffer, next, b);
|
||||
if (b == NULL) {
|
||||
info[i].status = SPA_RESULT_UNEXPECTED;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
info[i].buffer_id = b->outbuf->id;
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_port_reuse_buffer (SpaNode *node,
|
||||
|
|
@ -873,6 +825,48 @@ spa_v4l2_source_node_port_send_command (SpaNode *node,
|
|||
return res;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_process_input (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
SpaV4l2State *state;
|
||||
SpaPortOutput *output;
|
||||
V4l2Buffer *b;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
|
||||
|
||||
state = &this->state[0];
|
||||
|
||||
if ((output = state->io) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if (state->current_format == NULL) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&state->ready, V4l2Buffer, next, b);
|
||||
if (b == NULL) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode v4l2source_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -893,11 +887,12 @@ static const SpaNode v4l2source_node = {
|
|||
spa_v4l2_source_node_port_set_props,
|
||||
spa_v4l2_source_node_port_use_buffers,
|
||||
spa_v4l2_source_node_port_alloc_buffers,
|
||||
spa_v4l2_source_node_port_get_status,
|
||||
spa_v4l2_source_node_port_push_input,
|
||||
spa_v4l2_source_node_port_pull_output,
|
||||
spa_v4l2_source_node_port_set_input,
|
||||
spa_v4l2_source_node_port_set_output,
|
||||
spa_v4l2_source_node_port_reuse_buffer,
|
||||
spa_v4l2_source_node_port_send_command,
|
||||
spa_v4l2_source_node_process_input,
|
||||
spa_v4l2_source_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -1030,7 +1025,6 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
|
||||
this->state[0].log = this->log;
|
||||
this->state[0].info.flags = SPA_PORT_INFO_FLAG_LIVE;
|
||||
this->state[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->state[0].export_buf = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ struct _SpaVideoTestSrc {
|
|||
SpaAllocParam *params[2];
|
||||
SpaAllocParamBuffers param_buffers;
|
||||
SpaAllocParamMetaEnable param_meta;
|
||||
SpaPortStatus status;
|
||||
SpaPortOutput *output;
|
||||
|
||||
bool have_format;
|
||||
SpaFormatVideo query_format;
|
||||
|
|
@ -692,79 +692,29 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_videotestsrc_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_videotestsrc_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_videotestsrc_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*status = &this->status;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static SpaResult
|
||||
spa_videotestsrc_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
static SpaResult
|
||||
spa_videotestsrc_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
VTSBuffer *b;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this->have_format) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, VTSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
info[i].status = SPA_RESULT_UNEXPECTED;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
info[i].buffer_id = b->outbuf->id;
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
this->output = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -814,6 +764,45 @@ spa_videotestsrc_node_port_send_command (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_videotestsrc_node_process_input (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_videotestsrc_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
VTSBuffer *b;
|
||||
SpaPortOutput *output;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||
|
||||
if ((output = this->output) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if (!this->have_format) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
SPA_QUEUE_POP_HEAD (&this->ready, VTSBuffer, next, b);
|
||||
if (b == NULL) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode videotestsrc_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -834,11 +823,12 @@ static const SpaNode videotestsrc_node = {
|
|||
spa_videotestsrc_node_port_set_props,
|
||||
spa_videotestsrc_node_port_use_buffers,
|
||||
spa_videotestsrc_node_port_alloc_buffers,
|
||||
spa_videotestsrc_node_port_get_status,
|
||||
spa_videotestsrc_node_port_push_input,
|
||||
spa_videotestsrc_node_port_pull_output,
|
||||
spa_videotestsrc_node_port_set_input,
|
||||
spa_videotestsrc_node_port_set_output,
|
||||
spa_videotestsrc_node_port_reuse_buffer,
|
||||
spa_videotestsrc_node_port_send_command,
|
||||
spa_videotestsrc_node_process_input,
|
||||
spa_videotestsrc_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -989,8 +979,6 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
if (this->props[1].live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->node.state = SPA_NODE_STATE_CONFIGURE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ typedef struct {
|
|||
typedef struct {
|
||||
bool have_format;
|
||||
SpaPortInfo info;
|
||||
SpaPortStatus status;
|
||||
SpaBuffer **buffers;
|
||||
unsigned int n_buffers;
|
||||
SpaBuffer *buffer;
|
||||
void *io;
|
||||
} SpaVolumePort;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -425,94 +425,99 @@ spa_volume_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_volume_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
SpaVolume *this;
|
||||
SpaVolumePort *port;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*status = &port->status;
|
||||
this->in_ports[port_id].io = input;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
spa_volume_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
SpaVolume *this;
|
||||
unsigned int i;
|
||||
bool have_error = false;
|
||||
bool have_enough = false;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
SpaVolumePort *port;
|
||||
SpaBuffer *buffer;
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
port = &this->in_ports[info[i].port_id];
|
||||
buffer = port->buffers[info[i].buffer_id];
|
||||
|
||||
if (buffer == NULL) {
|
||||
info[i].status = SPA_RESULT_INVALID_ARGUMENTS;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
if (!port->have_format) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (port->buffer != NULL) {
|
||||
info[i].status = SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
have_enough = true;
|
||||
continue;
|
||||
}
|
||||
port->buffer = buffer;
|
||||
|
||||
this->in_ports[0].status.flags &= ~SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
this->out_ports[0].status.flags |= SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
if (have_enough)
|
||||
return SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
this->in_ports[port_id].io = output;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_reuse_buffer (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_process_input (SpaNode *node)
|
||||
{
|
||||
SpaVolume *this;
|
||||
SpaPortInput *input;
|
||||
SpaPortOutput *output;
|
||||
SpaVolumePort *port;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
port = &this->in_ports[0];
|
||||
|
||||
if ((input = port->io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
if ((output = this->out_ports[0].io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
if (input->buffer_id >= port->n_buffers) {
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
if (!port->have_format) {
|
||||
input->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
port->buffer = port->buffers[input->buffer_id];
|
||||
|
||||
input->status = SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
input->flags &= ~SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
output->flags |= SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
return SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
}
|
||||
|
||||
static SpaBuffer *
|
||||
find_free_buffer (SpaVolume *this, SpaVolumePort *port)
|
||||
{
|
||||
|
|
@ -532,9 +537,7 @@ release_buffer (SpaVolume *this, SpaBuffer *buffer)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
spa_volume_node_process_output (SpaNode *node)
|
||||
{
|
||||
SpaVolume *this;
|
||||
SpaVolumePort *port;
|
||||
|
|
@ -543,16 +546,21 @@ spa_volume_node_port_pull_output (SpaNode *node,
|
|||
SpaData *sd, *dd;
|
||||
uint16_t *src, *dst;
|
||||
double volume;
|
||||
SpaPortInput *input;
|
||||
SpaPortInput *output;
|
||||
|
||||
if (node == NULL || n_info == 0 || info == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
if (info[0].port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if ((output = port->io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
if ((input = this->in_ports[0].io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
port = &this->out_ports[info[0].port_id];
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -595,36 +603,19 @@ spa_volume_node_port_pull_output (SpaNode *node,
|
|||
doff = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (sbuf != dbuf)
|
||||
release_buffer (this, sbuf);
|
||||
|
||||
this->in_ports[0].buffer = NULL;
|
||||
info->buffer_id = dbuf->id;
|
||||
output->buffer_id = dbuf->id;
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
this->in_ports[0].status.flags |= SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
this->out_ports[0].status.flags &= ~SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
input->flags |= SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
output->flags &= ~SPA_PORT_STATUS_FLAG_HAVE_OUTPUT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_reuse_buffer (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static const SpaNode volume_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -645,11 +636,12 @@ static const SpaNode volume_node = {
|
|||
spa_volume_node_port_set_props,
|
||||
spa_volume_node_port_use_buffers,
|
||||
spa_volume_node_port_alloc_buffers,
|
||||
spa_volume_node_port_get_status,
|
||||
spa_volume_node_port_push_input,
|
||||
spa_volume_node_port_pull_output,
|
||||
spa_volume_node_port_set_input,
|
||||
spa_volume_node_port_set_output,
|
||||
spa_volume_node_port_reuse_buffer,
|
||||
spa_volume_node_port_send_command,
|
||||
spa_volume_node_process_input,
|
||||
spa_volume_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -719,9 +711,6 @@ volume_init (const SpaHandleFactory *factory,
|
|||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
|
||||
this->in_ports[0].status.flags = SPA_PORT_STATUS_FLAG_NEED_INPUT;
|
||||
this->out_ports[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,11 +90,10 @@ struct _SpaXvSink {
|
|||
SpaFormatVideo format[2];
|
||||
SpaFormat *current_format;
|
||||
|
||||
SpaPortInfo info;
|
||||
SpaXvState state;
|
||||
|
||||
SpaPortInfo info;
|
||||
SpaPortStatus status;
|
||||
|
||||
SpaPortInput *input;
|
||||
};
|
||||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
|
|
@ -456,42 +455,33 @@ spa_xv_sink_node_port_alloc_buffers (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_port_get_status (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
spa_xv_sink_node_port_set_input (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortInput *input)
|
||||
{
|
||||
SpaXvSink *this;
|
||||
|
||||
if (node == NULL || status == NULL)
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
if (!CHECK_PORT (this, SPA_DIRECTION_INPUT, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*status = &this->status;
|
||||
this->input = input;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortInputInfo *info)
|
||||
spa_xv_sink_node_port_set_output (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaPortOutput *output)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_port_pull_output (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_port_reuse_buffer (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
|
|
@ -509,6 +499,18 @@ spa_xv_sink_node_port_send_command (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_process_input (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_process_output (SpaNode *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static const SpaNode xvsink_node = {
|
||||
sizeof (SpaNode),
|
||||
NULL,
|
||||
|
|
@ -529,11 +531,12 @@ static const SpaNode xvsink_node = {
|
|||
spa_xv_sink_node_port_set_props,
|
||||
spa_xv_sink_node_port_use_buffers,
|
||||
spa_xv_sink_node_port_alloc_buffers,
|
||||
spa_xv_sink_node_port_get_status,
|
||||
spa_xv_sink_node_port_push_input,
|
||||
spa_xv_sink_node_port_pull_output,
|
||||
spa_xv_sink_node_port_set_input,
|
||||
spa_xv_sink_node_port_set_output,
|
||||
spa_xv_sink_node_port_reuse_buffer,
|
||||
spa_xv_sink_node_port_send_command,
|
||||
spa_xv_sink_node_process_input,
|
||||
spa_xv_sink_node_process_output,
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -598,7 +601,6 @@ xv_sink_init (const SpaHandleFactory *factory,
|
|||
reset_xv_sink_props (&this->props[1]);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,27 +111,25 @@ on_mix_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
switch (event->type) {
|
||||
case SPA_NODE_EVENT_TYPE_NEED_INPUT:
|
||||
{
|
||||
SpaPortInputInfo iinfo;
|
||||
SpaPortOutputInfo oinfo;
|
||||
SpaPortInput pi = { 0, };
|
||||
SpaPortOutput po = { 0, };
|
||||
SpaResult res;
|
||||
SpaNodeEventNeedInput *ni = (SpaNodeEventNeedInput *) event;
|
||||
SpaNode *peer;
|
||||
|
||||
oinfo.port_id = 0;
|
||||
oinfo.flags = SPA_PORT_OUTPUT_FLAG_NONE;
|
||||
if (ni->port_id == data->mix_ports[0])
|
||||
peer = data->source1;
|
||||
else
|
||||
peer = data->source2;
|
||||
|
||||
if (ni->port_id == data->mix_ports[0]) {
|
||||
if ((res = spa_node_port_pull_output (data->source1, 1, &oinfo)) < 0)
|
||||
printf ("got error %d\n", res);
|
||||
} else {
|
||||
if ((res = spa_node_port_pull_output (data->source2, 1, &oinfo)) < 0)
|
||||
printf ("got error %d\n", res);
|
||||
}
|
||||
spa_node_port_set_output (peer, 0, &po);
|
||||
if ((res = spa_node_process_output (peer)) < 0)
|
||||
printf ("got error %d\n", res);
|
||||
|
||||
iinfo.port_id = ni->port_id;
|
||||
iinfo.flags = SPA_PORT_INPUT_FLAG_NONE;
|
||||
iinfo.buffer_id = oinfo.buffer_id;
|
||||
pi.buffer_id = po.buffer_id;
|
||||
|
||||
if ((res = spa_node_port_push_input (data->mix, 1, &iinfo)) < 0)
|
||||
spa_node_port_set_input (data->mix, ni->port_id, &pi);
|
||||
if ((res = spa_node_process_input (data->mix)) < 0)
|
||||
printf ("got error from mixer %d\n", res);
|
||||
break;
|
||||
}
|
||||
|
|
@ -149,22 +147,21 @@ on_sink_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
switch (event->type) {
|
||||
case SPA_NODE_EVENT_TYPE_NEED_INPUT:
|
||||
{
|
||||
SpaPortInputInfo iinfo;
|
||||
SpaPortOutputInfo oinfo;
|
||||
SpaPortInput pi = { 0, };
|
||||
SpaPortOutput po = { 0, };
|
||||
SpaResult res;
|
||||
SpaNodeEventNeedInput *ni = (SpaNodeEventNeedInput *)event;
|
||||
|
||||
oinfo.port_id = 0;
|
||||
oinfo.flags = SPA_PORT_OUTPUT_FLAG_PULL;
|
||||
po.flags = SPA_PORT_OUTPUT_FLAG_PULL;
|
||||
|
||||
if ((res = spa_node_port_pull_output (data->mix, 1, &oinfo)) < 0)
|
||||
spa_node_port_set_output (data->mix, 0, &po);
|
||||
if ((res = spa_node_process_output (data->mix)) < 0)
|
||||
printf ("got error %d\n", res);
|
||||
|
||||
iinfo.port_id = ni->port_id;
|
||||
iinfo.flags = SPA_PORT_INPUT_FLAG_NONE;
|
||||
iinfo.buffer_id = oinfo.buffer_id;
|
||||
pi.buffer_id = po.buffer_id;
|
||||
|
||||
if ((res = spa_node_port_push_input (data->sink, 1, &iinfo)) < 0)
|
||||
spa_node_port_set_input (data->mix, ni->port_id, &pi);
|
||||
if ((res = spa_node_process_input (data->sink)) < 0)
|
||||
printf ("got error %d\n", res);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ on_source_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
switch (event->type) {
|
||||
case SPA_NODE_EVENT_TYPE_HAVE_OUTPUT:
|
||||
{
|
||||
SpaPortOutputInfo info[1] = { 0, };
|
||||
SpaPortOutput po = { 0, };
|
||||
SpaResult res;
|
||||
SpaBuffer *b;
|
||||
void *sdata, *ddata;
|
||||
|
|
@ -141,10 +141,11 @@ on_source_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
SpaMeta *metas;
|
||||
SpaData *datas;
|
||||
|
||||
if ((res = spa_node_port_pull_output (data->source, 1, info)) < 0)
|
||||
spa_node_port_set_output (data->source, 0, &po);
|
||||
if ((res = spa_node_process_output (data->source)) < 0)
|
||||
printf ("got pull error %d\n", res);
|
||||
|
||||
b = data->bp[info->buffer_id];
|
||||
b = data->bp[po.buffer_id];
|
||||
metas = b->metas;
|
||||
datas = b->datas;
|
||||
|
||||
|
|
@ -188,7 +189,7 @@ on_source_event (SpaNode *node, SpaNodeEvent *event, void *user_data)
|
|||
SDL_RenderCopy (data->renderer, data->texture, NULL, NULL);
|
||||
SDL_RenderPresent (data->renderer);
|
||||
}
|
||||
spa_node_port_reuse_buffer (data->source, 0, info->buffer_id);
|
||||
spa_node_port_reuse_buffer (data->source, 0, po.buffer_id);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue