Improve process_output

process_output is now to finish processing of the output in async nodes,
which means we need to fill the io area before sending the HAVE_OUTPUT
event. This simplifies some things and improves performance because we
don't need to deal with queues and additional checks.
This commit is contained in:
Wim Taymans 2016-12-20 18:10:50 +01:00
parent 5b0b9c43d0
commit f5dbdbc0df
10 changed files with 45 additions and 156 deletions

View file

@ -698,7 +698,7 @@ spa_alsa_sink_node_process_input (SpaNode *node)
this->ringbuffer->outstanding = true;
this->ringbuffer = b;
} else {
spa_list_insert (this->ready.prev, &b->list);
spa_list_insert (this->ready.prev, &b->link);
}
b->outstanding = false;
input->status = SPA_RESULT_OK;

View file

@ -408,7 +408,7 @@ recycle_buffer (SpaALSASource *this, uint32_t buffer_id)
return;
b->outstanding = false;
spa_list_insert (this->free.prev, &b->list);
spa_list_insert (this->free.prev, &b->link);
}
static SpaResult
@ -590,7 +590,7 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
default:
break;
}
spa_list_insert (this->free.prev, &b->list);
spa_list_insert (this->free.prev, &b->link);
}
this->n_buffers = n_buffers;
@ -731,35 +731,6 @@ spa_alsa_source_node_process_input (SpaNode *node)
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;
}
if (spa_list_is_empty (&this->ready)) {
output->status = SPA_RESULT_UNEXPECTED;
return SPA_RESULT_ERROR;
}
b = spa_list_first (&this->ready, SpaALSABuffer, list);
spa_list_remove (&b->list);
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;
}

View file

@ -282,7 +282,7 @@ pull_frames_queue (SpaALSAState *state,
off_t offs;
SpaALSABuffer *b;
b = spa_list_first (&state->ready, SpaALSABuffer, list);
b = spa_list_first (&state->ready, SpaALSABuffer, link);
offs = SPA_MIN (b->outbuf->datas[0].chunk->offset, b->outbuf->datas[0].maxsize);
src = SPA_MEMBER (b->outbuf->datas[0].data, offs, uint8_t);
@ -299,7 +299,7 @@ pull_frames_queue (SpaALSAState *state,
if (state->ready_offset >= size) {
SpaNodeEventReuseBuffer rb;
spa_list_remove (&b->list);
spa_list_remove (&b->link);
b->outstanding = true;
rb.event.type = SPA_NODE_EVENT_TYPE_REUSE_BUFFER;
@ -452,8 +452,8 @@ mmap_read (SpaALSAState *state)
b = NULL;
spa_log_warn (state->log, "no more buffers");
} else {
b = spa_list_first (&state->free, SpaALSABuffer, list);
spa_list_remove (&b->list);
b = spa_list_first (&state->free, SpaALSABuffer, link);
spa_list_remove (&b->link);
dest = b->outbuf->datas[0].data;
destsize = b->outbuf->datas[0].maxsize;
@ -495,14 +495,18 @@ mmap_read (SpaALSAState *state)
if (b) {
SpaNodeEventHaveOutput ho;
SpaData *d;
SpaPortOutput *output;
d = b->outbuf->datas;
d[0].chunk->offset = 0;
d[0].chunk->size = avail * state->frame_size;
d[0].chunk->stride = 0;
spa_list_insert (state->ready.prev, &b->list);
if ((output = state->io)) {
b->outstanding = true;
output->buffer_id = b->outbuf->id;
output->status = SPA_RESULT_OK;
}
ho.event.type = SPA_NODE_EVENT_TYPE_HAVE_OUTPUT;
ho.event.size = sizeof (ho);
ho.port_id = 0;

View file

@ -56,7 +56,7 @@ struct _SpaALSABuffer {
SpaMetaHeader *h;
SpaMetaRingbuffer *rb;
bool outstanding;
SpaList list;
SpaList link;
};
typedef struct {