mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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:
parent
5b0b9c43d0
commit
f5dbdbc0df
10 changed files with 45 additions and 156 deletions
|
|
@ -58,7 +58,7 @@ struct _VTSBuffer {
|
|||
SpaMetaHeader *h;
|
||||
void *ptr;
|
||||
size_t stride;
|
||||
SpaList list;
|
||||
SpaList link;
|
||||
};
|
||||
|
||||
struct _SpaVideoTestSrc {
|
||||
|
|
@ -100,7 +100,6 @@ struct _SpaVideoTestSrc {
|
|||
|
||||
uint64_t frame_count;
|
||||
SpaList empty;
|
||||
SpaList ready;
|
||||
};
|
||||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
|
|
@ -222,14 +221,15 @@ videotestsrc_on_output (SpaSource *source)
|
|||
{
|
||||
SpaVideoTestSrc *this = source->data;
|
||||
VTSBuffer *b;
|
||||
SpaPortOutput *output;
|
||||
|
||||
if (spa_list_is_empty (&this->empty)) {
|
||||
if (!this->props[1].live)
|
||||
update_loop_enabled (this, false);
|
||||
return;
|
||||
}
|
||||
b = spa_list_first (&this->empty, VTSBuffer, list);
|
||||
spa_list_remove (&b->list);
|
||||
b = spa_list_first (&this->empty, VTSBuffer, link);
|
||||
spa_list_remove (&b->link);
|
||||
|
||||
fill_buffer (this, b);
|
||||
|
||||
|
|
@ -254,8 +254,12 @@ videotestsrc_on_output (SpaSource *source)
|
|||
timerfd_settime (this->timer_source.fd, TFD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
}
|
||||
|
||||
spa_list_insert (this->ready.prev, &b->list);
|
||||
send_have_output (this);
|
||||
if ((output = this->output)) {
|
||||
b->outstanding = true;
|
||||
output->buffer_id = b->outbuf->id;
|
||||
output->status = SPA_RESULT_OK;
|
||||
send_have_output (this);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -481,7 +485,6 @@ clear_buffers (SpaVideoTestSrc *this)
|
|||
spa_log_info (this->log, "videotestsrc %p: clear buffers", this);
|
||||
this->n_buffers = 0;
|
||||
spa_list_init (&this->empty);
|
||||
spa_list_init (&this->ready);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -663,7 +666,7 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
spa_list_insert (this->empty.prev, &b->list);
|
||||
spa_list_insert (this->empty.prev, &b->link);
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
|
|
@ -759,7 +762,7 @@ spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
|
||||
b->outstanding = false;
|
||||
spa_list_insert (this->empty.prev, &b->list);
|
||||
spa_list_insert (this->empty.prev, &b->link);
|
||||
|
||||
if (!this->props[1].live)
|
||||
update_loop_enabled (this, true);
|
||||
|
|
@ -785,33 +788,6 @@ spa_videotestsrc_node_process_input (SpaNode *node)
|
|||
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;
|
||||
}
|
||||
|
||||
if (spa_list_is_empty (&this->ready)) {
|
||||
output->status = SPA_RESULT_UNEXPECTED;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
b = spa_list_first (&this->ready, VTSBuffer, list);
|
||||
b->outstanding = true;
|
||||
|
||||
output->buffer_id = b->outbuf->id;
|
||||
output->status = SPA_RESULT_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -969,7 +945,6 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
reset_videotestsrc_props (&this->props[1]);
|
||||
|
||||
spa_list_init (&this->empty);
|
||||
spa_list_init (&this->ready);
|
||||
|
||||
this->timer_source.func = videotestsrc_on_output;
|
||||
this->timer_source.data = this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue