mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
node: Add id to set_io
Make it possible to configure multiple io areas on a port by giving an id to set_io. Add some types to enumerate the supported ids Make an area to exchange buffers and one to specify pull ranges. The idea is to make more area types for controlable properties. Implement enumeration of IO areas in volume.
This commit is contained in:
parent
4288a634f4
commit
8efea3e1ea
40 changed files with 583 additions and 208 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include <spa/support/type-map.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/io.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/param/buffers.h>
|
||||
#include <spa/param/meta.h>
|
||||
|
|
@ -50,7 +51,8 @@ struct buffer {
|
|||
struct port {
|
||||
bool valid;
|
||||
|
||||
struct spa_port_io *io;
|
||||
struct spa_io_buffers *io;
|
||||
struct spa_io_control_range *range;
|
||||
|
||||
struct spa_port_info info;
|
||||
|
||||
|
|
@ -66,6 +68,7 @@ struct port {
|
|||
struct type {
|
||||
uint32_t node;
|
||||
uint32_t format;
|
||||
struct spa_type_io io;
|
||||
struct spa_type_param param;
|
||||
struct spa_type_media_type media_type;
|
||||
struct spa_type_media_subtype media_subtype;
|
||||
|
|
@ -82,6 +85,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
|
|||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
|
||||
spa_type_io_map(map, &type->io);
|
||||
spa_type_param_map(map, &type->param);
|
||||
spa_type_media_type_map(map, &type->media_type);
|
||||
spa_type_media_subtype_map(map, &type->media_subtype);
|
||||
|
|
@ -625,21 +629,28 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
|
||||
static int
|
||||
impl_node_port_set_io(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_port_io *io)
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, void *io)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
port->io = io;
|
||||
|
||||
if (id == t->io.Buffers)
|
||||
port->io = io;
|
||||
else if (id == t->io.ControlRange)
|
||||
port->range = io;
|
||||
else
|
||||
return -ENOENT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -730,7 +741,7 @@ static int mix_output(struct impl *this, size_t n_bytes)
|
|||
struct buffer *outbuf;
|
||||
int i, layer;
|
||||
struct port *outport;
|
||||
struct spa_port_io *outio;
|
||||
struct spa_io_buffers *outio;
|
||||
struct spa_data *od;
|
||||
uint32_t avail, index, maxsize, len1, len2, offset;
|
||||
|
||||
|
|
@ -793,7 +804,7 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
uint32_t i;
|
||||
struct port *outport;
|
||||
size_t min_queued = SIZE_MAX;
|
||||
struct spa_port_io *outio;
|
||||
struct spa_io_buffers *outio;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -808,7 +819,7 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
|
||||
for (i = 0; i < this->last_port; i++) {
|
||||
struct port *inport = GET_IN_PORT(this, i);
|
||||
struct spa_port_io *inio;
|
||||
struct spa_io_buffers *inio;
|
||||
|
||||
if ((inio = inport->io) == NULL)
|
||||
continue;
|
||||
|
|
@ -852,7 +863,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
{
|
||||
struct impl *this;
|
||||
struct port *outport;
|
||||
struct spa_port_io *outio;
|
||||
struct spa_io_buffers *outio;
|
||||
int i;
|
||||
size_t min_queued = SIZE_MAX;
|
||||
|
||||
|
|
@ -888,19 +899,20 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
/* take requested output range and apply to input */
|
||||
for (i = 0; i < this->last_port; i++) {
|
||||
struct port *inport = GET_IN_PORT(this, i);
|
||||
struct spa_port_io *inio;
|
||||
struct spa_io_buffers *inio;
|
||||
|
||||
if ((inio = inport->io) == NULL || inport->n_buffers == 0)
|
||||
continue;
|
||||
|
||||
if (inport->queued_bytes == 0) {
|
||||
inio->range = outio->range;
|
||||
if (inport->range && outport->range)
|
||||
*inport->range = *outport->range;
|
||||
inio->status = SPA_STATUS_NEED_BUFFER;
|
||||
} else {
|
||||
inio->status = SPA_STATUS_OK;
|
||||
}
|
||||
spa_log_trace(this->log, NAME " %p: port %d %d queued %zd, res %d", this,
|
||||
i, outio->range.min_size, inport->queued_bytes, inio->status);
|
||||
spa_log_trace(this->log, NAME " %p: port %d queued %zd, res %d", this,
|
||||
i, inport->queued_bytes, inio->status);
|
||||
}
|
||||
}
|
||||
return outio->status;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue