mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05: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
|
|
@ -30,6 +30,7 @@
|
|||
#include <spa/utils/list.h>
|
||||
#include <spa/clock/clock.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>
|
||||
|
|
@ -53,6 +54,7 @@ struct type {
|
|||
uint32_t prop_volume;
|
||||
uint32_t wave_sine;
|
||||
uint32_t wave_square;
|
||||
struct spa_type_io io;
|
||||
struct spa_type_param param;
|
||||
struct spa_type_meta meta;
|
||||
struct spa_type_data data;
|
||||
|
|
@ -78,6 +80,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
|
|||
type->prop_volume = spa_type_map_get_id(map, SPA_TYPE_PROPS__volume);
|
||||
type->wave_sine = spa_type_map_get_id(map, SPA_TYPE_PROPS__waveType ":sine");
|
||||
type->wave_square = spa_type_map_get_id(map, SPA_TYPE_PROPS__waveType ":square");
|
||||
spa_type_io_map(map, &type->io);
|
||||
spa_type_param_map(map, &type->param);
|
||||
spa_type_meta_map(map, &type->meta);
|
||||
spa_type_data_map(map, &type->data);
|
||||
|
|
@ -132,7 +135,8 @@ struct impl {
|
|||
struct itimerspec timerspec;
|
||||
|
||||
struct spa_port_info info;
|
||||
struct spa_port_io *io;
|
||||
struct spa_io_buffers *io;
|
||||
struct spa_io_control_range *range;
|
||||
|
||||
bool have_format;
|
||||
struct spa_audio_info current_format;
|
||||
|
|
@ -295,7 +299,8 @@ static void read_timer(struct impl *this)
|
|||
static int make_buffer(struct impl *this)
|
||||
{
|
||||
struct buffer *b;
|
||||
struct spa_port_io *io = this->io;
|
||||
struct spa_io_buffers *io = this->io;
|
||||
struct spa_io_control_range *range = this->range;
|
||||
int n_bytes, n_samples;
|
||||
uint32_t maxsize;
|
||||
void *data;
|
||||
|
|
@ -319,10 +324,10 @@ static int make_buffer(struct impl *this)
|
|||
data = d[0].data;
|
||||
|
||||
n_bytes = maxsize;
|
||||
if (io->range.min_size != 0) {
|
||||
n_bytes = SPA_MIN(n_bytes, io->range.min_size);
|
||||
if (io->range.max_size < n_bytes)
|
||||
n_bytes = io->range.max_size;
|
||||
if (range && range->min_size != 0) {
|
||||
n_bytes = SPA_MIN(n_bytes, range->min_size);
|
||||
if (range->max_size < n_bytes)
|
||||
n_bytes = range->max_size;
|
||||
}
|
||||
|
||||
spa_log_trace(this->log, NAME " %p: dequeue buffer %d %d %d", this, b->outbuf->id,
|
||||
|
|
@ -808,17 +813,25 @@ static int
|
|||
impl_node_port_set_io(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_port_io *io)
|
||||
uint32_t id,
|
||||
void *io)
|
||||
{
|
||||
struct impl *this;
|
||||
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);
|
||||
|
||||
this->io = io;
|
||||
if (id == t->io.Buffers)
|
||||
this->io = io;
|
||||
else if (id == t->io.ControlRange)
|
||||
this->range = io;
|
||||
else
|
||||
return -ENOENT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -870,7 +883,7 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
struct spa_io_buffers *io;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue