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:
Wim Taymans 2016-11-07 18:23:09 +01:00
parent b774b99db5
commit e88a376d7c
21 changed files with 903 additions and 989 deletions

View file

@ -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;