mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue