mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
More work on implementing remote protocol
Rework things so that we negotiate buffer pools beforehand and only pass buffer ids around We can then remove the refcount of buffers, events and commands. More work on buffer reuse Use the node state changes to trigger the next step in the configuration sequence. Move most of the client-node to a plugin Do buffer allocation in the port link.
This commit is contained in:
parent
05829f33e6
commit
3ace7e9648
36 changed files with 1780 additions and 1450 deletions
|
|
@ -89,7 +89,9 @@ struct _SpaALSASink {
|
|||
SpaPortInfo info;
|
||||
SpaPortStatus status;
|
||||
|
||||
SpaBuffer *input_buffer;
|
||||
SpaBuffer *buffers;
|
||||
unsigned int n_buffers;
|
||||
uint32_t input_buffer;
|
||||
|
||||
ALSABuffer buffer;
|
||||
};
|
||||
|
|
@ -233,13 +235,13 @@ spa_alsa_sink_node_send_command (SpaNode *node,
|
|||
|
||||
if (this->event_cb) {
|
||||
SpaEvent event;
|
||||
SpaEventStateChange sc;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_STARTED;
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
||||
this->event_cb (node, &event, this->user_data);
|
||||
}
|
||||
|
|
@ -249,13 +251,13 @@ spa_alsa_sink_node_send_command (SpaNode *node,
|
|||
|
||||
if (this->event_cb) {
|
||||
SpaEvent event;
|
||||
SpaEventStateChange sc;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_STOPPED;
|
||||
event.type = SPA_EVENT_TYPE_STATE_CHANGE;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
event.data = ≻
|
||||
event.size = sizeof (sc);
|
||||
sc.state = SPA_NODE_STATE_STREAMING;
|
||||
|
||||
this->event_cb (node, &event, this->user_data);
|
||||
}
|
||||
|
|
@ -465,6 +467,36 @@ spa_alsa_sink_node_port_set_props (SpaNode *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_use_buffers (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaAllocParam **params,
|
||||
uint32_t n_params,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_reuse_buffer (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id,
|
||||
off_t offset,
|
||||
size_t size)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_get_status (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
|
|
@ -485,32 +517,6 @@ spa_alsa_sink_node_port_get_status (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_use_buffers (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaAllocParam **params,
|
||||
uint32_t n_params,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaBuffer *
|
||||
find_buffer (SpaALSASink *this, uint32_t id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_port_push_input (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
|
|
@ -526,29 +532,25 @@ spa_alsa_sink_node_port_push_input (SpaNode *node,
|
|||
this = (SpaALSASink *) node->handle;
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
SpaBuffer *buffer;
|
||||
|
||||
if (info[i].port_id != 0) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
buffer = find_buffer (this, info[i].id);
|
||||
|
||||
if (buffer != NULL) {
|
||||
if (info[i].buffer_id != SPA_ID_INVALID) {
|
||||
if (!this->have_format) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this->input_buffer != NULL) {
|
||||
if (this->input_buffer != -1) {
|
||||
info[i].status = SPA_RESULT_HAVE_ENOUGH_INPUT;
|
||||
have_enough = true;
|
||||
continue;
|
||||
}
|
||||
this->input_buffer = spa_buffer_ref (buffer);
|
||||
this->input_buffer = info[i].buffer_id;
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -587,6 +589,7 @@ 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_reuse_buffer,
|
||||
spa_alsa_sink_node_port_get_status,
|
||||
spa_alsa_sink_node_port_push_input,
|
||||
spa_alsa_sink_node_port_pull_output,
|
||||
|
|
|
|||
|
|
@ -205,40 +205,18 @@ static void
|
|||
pull_input (SpaALSASink *this, void *data, snd_pcm_uframes_t frames)
|
||||
{
|
||||
SpaEvent event;
|
||||
ALSABuffer *buffer = &this->buffer;
|
||||
SpaEventPullInput pi;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_PULL_INPUT;
|
||||
event.port_id = 0;
|
||||
event.size = frames * sizeof (uint16_t) * 2;
|
||||
event.data = buffer;
|
||||
event.data = π
|
||||
|
||||
buffer->buffer.refcount = 1;
|
||||
buffer->buffer.notify = NULL;
|
||||
buffer->buffer.size = frames * sizeof (uint16_t) * 2;
|
||||
buffer->buffer.n_metas = 1;
|
||||
buffer->buffer.metas = buffer->meta;
|
||||
buffer->buffer.n_datas = 1;
|
||||
buffer->buffer.datas = buffer->data;
|
||||
pi.buffer_id = this->buffer.buffer.id;
|
||||
pi.offset = 0;
|
||||
pi.size = frames * sizeof (uint16_t) * 2;
|
||||
|
||||
buffer->header.flags = 0;
|
||||
buffer->header.seq = 0;
|
||||
buffer->header.pts = 0;
|
||||
buffer->header.dts_offset = 0;
|
||||
|
||||
buffer->meta[0].type = SPA_META_TYPE_HEADER;
|
||||
buffer->meta[0].data = &buffer->header;
|
||||
buffer->meta[0].size = sizeof (buffer->header);
|
||||
|
||||
buffer->data[0].type = SPA_DATA_TYPE_MEMPTR;
|
||||
buffer->data[0].ptr = data;
|
||||
buffer->data[0].ptr_type = "sysmem";
|
||||
buffer->data[0].size = frames * sizeof (uint16_t) * 2;
|
||||
|
||||
this->event_cb (&this->node, &event,this->user_data);
|
||||
|
||||
spa_buffer_unref ((SpaBuffer *)event.data);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -273,11 +251,10 @@ mmap_write (SpaALSASink *this)
|
|||
frames);
|
||||
|
||||
if (this->input_buffer) {
|
||||
if (this->input_buffer != &this->buffer.buffer) {
|
||||
if (this->input_buffer != this->buffer.buffer.id) {
|
||||
/* FIXME, copy input */
|
||||
}
|
||||
spa_buffer_unref (this->input_buffer);
|
||||
this->input_buffer = NULL;
|
||||
this->input_buffer = -1;
|
||||
}
|
||||
|
||||
commitres = snd_pcm_mmap_commit (handle, offset, frames);
|
||||
|
|
@ -366,8 +343,6 @@ spa_alsa_start (SpaALSASink *this)
|
|||
return err;
|
||||
}
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_ADD_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &state->poll;
|
||||
|
|
@ -394,8 +369,6 @@ spa_alsa_stop (SpaALSASink *this)
|
|||
|
||||
snd_pcm_drop (state->handle);
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_REMOVE_POLL;
|
||||
event.port_id = 0;
|
||||
event.data = &state->poll;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue