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:
Wim Taymans 2017-11-21 19:34:37 +01:00
parent 4288a634f4
commit 8efea3e1ea
40 changed files with 583 additions and 208 deletions

View file

@ -517,17 +517,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)
impl_node_port_set_io(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t id,
void *io)
{
struct state *this;
struct type *t;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, 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;
}
@ -563,7 +574,7 @@ impl_node_port_send_command(struct spa_node *node,
static int impl_node_process_input(struct spa_node *node)
{
struct state *this;
struct spa_port_io *input;
struct spa_io_buffers *input;
spa_return_val_if_fail(node != NULL, -EINVAL);

View file

@ -552,17 +552,26 @@ 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)
impl_node_port_set_io(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t id,
void *io)
{
struct state *this;
struct type *t;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, 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
return -ENOENT;
return 0;
}
@ -619,7 +628,7 @@ static int impl_node_process_input(struct spa_node *node)
static int impl_node_process_output(struct spa_node *node)
{
struct state *this;
struct spa_port_io *io;
struct spa_io_buffers *io;
spa_return_val_if_fail(node != NULL, -EINVAL);

View file

@ -334,15 +334,17 @@ static inline void calc_timeout(size_t target, size_t current,
static inline void try_pull(struct state *state, snd_pcm_uframes_t frames,
snd_pcm_uframes_t written, bool do_pull)
{
struct spa_port_io *io = state->io;
struct spa_io_buffers *io = state->io;
if (spa_list_is_empty(&state->ready) && do_pull) {
spa_log_trace(state->log, "alsa-util %p: %d %lu", state, io->status,
state->filled + written);
io->status = SPA_STATUS_NEED_BUFFER;
io->range.offset = state->sample_count * state->frame_size;
io->range.min_size = state->threshold * state->frame_size;
io->range.max_size = frames * state->frame_size;
if (state->range) {
state->range->offset = state->sample_count * state->frame_size;
state->range->min_size = state->threshold * state->frame_size;
state->range->max_size = frames * state->frame_size;
}
state->callbacks->need_input(state->callbacks_data);
}
}
@ -428,7 +430,7 @@ push_frames(struct state *state,
snd_pcm_uframes_t frames)
{
snd_pcm_uframes_t total_frames = 0;
struct spa_port_io *io = state->io;
struct spa_io_buffers *io = state->io;
if (spa_list_is_empty(&state->free)) {
spa_log_trace(state->log, "no more buffers");

View file

@ -35,6 +35,7 @@ extern "C" {
#include <spa/clock/clock.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/param/buffers.h>
#include <spa/param/meta.h>
#include <spa/param/audio/format-utils.h>
@ -66,6 +67,7 @@ struct type {
uint32_t prop_card_name;
uint32_t prop_min_latency;
uint32_t prop_max_latency;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_meta meta;
struct spa_type_data data;
@ -92,6 +94,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
type->prop_min_latency = spa_type_map_get_id(map, SPA_TYPE_PROPS__minLatency);
type->prop_max_latency = spa_type_map_get_id(map, SPA_TYPE_PROPS__maxLatency);
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);
@ -141,7 +144,8 @@ struct state {
size_t frame_size;
struct spa_port_info info;
struct spa_port_io *io;
struct spa_io_buffers *io;
struct spa_io_control_range *range;
struct buffer buffers[MAX_BUFFERS];
unsigned int n_buffers;

View file

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

View file

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

View file

@ -26,11 +26,16 @@
#include <spa/support/type-map.h>
#include <spa/support/log.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/param/video/format-utils.h>
#include <lib/pod.h>
#define IS_VALID_PORT(this,d,id) ((id) == 0)
#define IS_VALID_PORT(this,d,id) ((id) == 0)
#define GET_IN_PORT(this,p) (&this->in_ports[p])
#define GET_OUT_PORT(this,p) (&this->out_ports[p])
#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
#define MAX_BUFFERS 32
struct buffer {
@ -45,11 +50,12 @@ struct port {
bool have_buffers;
struct buffer buffers[MAX_BUFFERS];
struct spa_port_info info;
struct spa_port_io *io;
struct spa_io_buffers *io;
};
struct type {
uint32_t node;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
@ -60,6 +66,7 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map)
{
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
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);
@ -209,8 +216,8 @@ spa_ffmpeg_dec_node_port_get_info(struct spa_node *node,
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port = GET_PORT(this, direction, port_id);
*info = &port->info;
return 0;
@ -253,8 +260,7 @@ static int port_get_format(struct spa_node *node,
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct port *port;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port = GET_PORT(this, direction, port_id);
if (!port->have_format)
return -EIO;
@ -330,8 +336,7 @@ static int port_set_format(struct spa_node *node,
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port = GET_PORT(this, direction, port_id);
if (format == NULL) {
port->have_format = false;
@ -406,22 +411,28 @@ static int
spa_ffmpeg_dec_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 port *port;
struct type *t;
if (node == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port->io = io;
port = GET_PORT(this, direction, port_id);
if (id == t->io.Buffers)
port->io = io;
else
return -ENOENT;
return 0;
}
@ -435,7 +446,7 @@ static int spa_ffmpeg_dec_node_process_output(struct spa_node *node)
{
struct impl *this;
struct port *port;
struct spa_port_io *output;
struct spa_io_buffers *output;
if (node == NULL)
return -EINVAL;

View file

@ -26,11 +26,16 @@
#include <spa/support/log.h>
#include <spa/support/type-map.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/param/video/format-utils.h>
#include <lib/pod.h>
#define IS_VALID_PORT(this,d,id) ((id) == 0)
#define IS_VALID_PORT(this,d,id) ((id) == 0)
#define GET_IN_PORT(this,p) (&this->in_ports[p])
#define GET_OUT_PORT(this,p) (&this->out_ports[p])
#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
#define MAX_BUFFERS 32
struct buffer {
@ -49,11 +54,12 @@ struct port {
bool have_buffers;
struct buffer buffers[MAX_BUFFERS];
struct spa_port_info info;
struct spa_port_io *io;
struct spa_io_buffers *io;
};
struct type {
uint32_t node;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
@ -64,6 +70,7 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map)
{
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
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);
@ -210,8 +217,7 @@ spa_ffmpeg_enc_node_port_get_info(struct spa_node *node,
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port = GET_PORT(this, direction, port_id);
*info = &port->info;
return 0;
@ -227,7 +233,7 @@ static int port_enum_formats(struct spa_node *node,
//struct impl *this = SPA_CONTAINER_OF (node, struct impl, node);
//struct port *port;
//port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
//port = GET_PORT(this, direction, port_id);
switch (*index) {
case 0:
@ -249,8 +255,7 @@ static int port_get_format(struct spa_node *node,
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct port *port;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port = GET_PORT(this, direction, port_id);
if (!port->have_format)
return -EIO;
@ -317,8 +322,7 @@ static int port_set_format(struct spa_node *node,
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct port *port;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port = GET_PORT(this, direction, port_id);
if (format == NULL) {
port->have_format = false;
@ -391,22 +395,29 @@ spa_ffmpeg_enc_node_port_alloc_buffers(struct spa_node *node,
static int
spa_ffmpeg_enc_node_port_set_io(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id, struct spa_port_io *io)
uint32_t port_id,
uint32_t id,
void *io)
{
struct impl *this;
struct port *port;
struct type *t;
if (node == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
port->io = io;
port = GET_PORT(this, direction, port_id);
if (id == t->io.Buffers)
port->io = io;
else
return -ENOENT;
return 0;
}
@ -440,7 +451,7 @@ static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
{
struct impl *this;
struct port *port;
struct spa_port_io *output;
struct spa_io_buffers *output;
if (node == NULL)
return -EINVAL;

View file

@ -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/buffers.h>
#include <spa/param/meta.h>
#include <spa/param/format.h>
@ -45,6 +46,7 @@ struct type {
uint32_t format;
uint32_t props;
uint32_t prop_live;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_meta meta;
struct spa_type_data data;
@ -61,6 +63,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live);
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);
@ -103,7 +106,7 @@ struct impl {
struct itimerspec timerspec;
struct spa_port_info info;
struct spa_port_io *io;
struct spa_io_buffers *io;
bool have_format;
uint8_t format_buffer[1024];
@ -243,7 +246,7 @@ static void render_buffer(struct impl *this, struct buffer *b)
static int consume_buffer(struct impl *this)
{
struct buffer *b;
struct spa_port_io *io = this->io;
struct spa_io_buffers *io = this->io;
int n_bytes;
read_timer(this);
@ -665,17 +668,23 @@ 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
return -ENOENT;
return 0;
}
@ -697,7 +706,7 @@ impl_node_port_send_command(struct spa_node *node,
static int impl_node_process_input(struct spa_node *node)
{
struct impl *this;
struct spa_port_io *input;
struct spa_io_buffers *input;
spa_return_val_if_fail(node != NULL, -EINVAL);

View file

@ -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/buffers.h>
#include <spa/param/meta.h>
#include <spa/param/format.h>
@ -46,6 +47,7 @@ struct type {
uint32_t props;
uint32_t prop_live;
uint32_t prop_pattern;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_meta meta;
struct spa_type_data data;
@ -63,6 +65,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_live = spa_type_map_get_id(map, SPA_TYPE_PROPS__live);
type->prop_pattern = spa_type_map_get_id(map, SPA_TYPE_PROPS__patternType);
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);
@ -106,7 +109,7 @@ struct impl {
struct itimerspec timerspec;
struct spa_port_info info;
struct spa_port_io *io;
struct spa_io_buffers *io;
bool have_format;
uint8_t format_buffer[1024];
@ -258,7 +261,7 @@ static inline 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;
int n_bytes;
read_timer(this);
@ -682,17 +685,23 @@ 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
return -ENOENT;
return 0;
}
@ -746,7 +755,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);

View file

@ -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/video/format-utils.h>
#include <spa/param/buffers.h>
#include <spa/param/meta.h>
@ -70,6 +71,7 @@ struct type {
uint32_t prop_device;
uint32_t prop_device_name;
uint32_t prop_device_fd;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
@ -93,6 +95,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
type->prop_device = spa_type_map_get_id(map, SPA_TYPE_PROPS__device);
type->prop_device_name = spa_type_map_get_id(map, SPA_TYPE_PROPS__deviceName);
type->prop_device_fd = spa_type_map_get_id(map, SPA_TYPE_PROPS__deviceFd);
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);
@ -138,7 +141,7 @@ struct port {
struct spa_source source;
struct spa_port_info info;
struct spa_port_io *io;
struct spa_io_buffers *io;
int64_t last_ticks;
int64_t last_monotonic;
@ -759,17 +762,23 @@ 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)
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->out_ports[port_id].io = io;
if (id == t->io.Buffers)
this->out_ports[port_id].io = io;
else
return -ENOENT;
return 0;
}
@ -828,7 +837,7 @@ static int impl_node_process_output(struct spa_node *node)
{
struct impl *this;
int res = SPA_STATUS_OK;
struct spa_port_io *io;
struct spa_io_buffers *io;
struct port *port;
spa_return_val_if_fail(node != NULL, -EINVAL);

View file

@ -902,7 +902,7 @@ static int mmap_read(struct impl *this)
struct buffer *b;
struct spa_data *d;
int64_t pts;
struct spa_port_io *io = port->io;
struct spa_io_buffers *io = port->io;
spa_zero(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

View file

@ -31,6 +31,7 @@
#include <spa/utils/list.h>
#include <spa/clock/clock.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/param/video/format-utils.h>
#include <spa/param/buffers.h>
#include <spa/param/meta.h>
@ -51,6 +52,7 @@ struct type {
uint32_t prop_pattern;
uint32_t pattern_smpte_snow;
uint32_t pattern_snow;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_meta meta;
struct spa_type_data data;
@ -74,6 +76,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
type->prop_pattern = spa_type_map_get_id(map, SPA_TYPE_PROPS__patternType);
type->pattern_smpte_snow = spa_type_map_get_id(map, SPA_TYPE_PROPS__patternType ":smpte-snow");
type->pattern_snow = spa_type_map_get_id(map, SPA_TYPE_PROPS__patternType ":snow");
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);
@ -122,7 +125,7 @@ struct impl {
struct itimerspec timerspec;
struct spa_port_info info;
struct spa_port_io *io;
struct spa_io_buffers *io;
bool have_format;
struct spa_video_info current_format;
@ -274,7 +277,7 @@ 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;
uint32_t n_bytes;
read_timer(this);
@ -753,17 +756,23 @@ 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
return -ENOENT;
return 0;
}
@ -815,7 +824,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);

View file

@ -25,9 +25,11 @@
#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>
#include <spa/param/io.h>
#include <lib/pod.h>
@ -56,7 +58,8 @@ struct port {
struct buffer buffers[MAX_BUFFERS];
uint32_t n_buffers;
struct spa_port_io *io;
struct spa_io_buffers *io;
struct spa_io_control_range *range;
struct spa_list empty;
};
@ -67,6 +70,7 @@ struct type {
uint32_t props;
uint32_t prop_volume;
uint32_t prop_mute;
struct spa_type_io io;
struct spa_type_param param;
struct spa_type_meta meta;
struct spa_type_data data;
@ -78,6 +82,7 @@ struct type {
struct spa_type_command_node command_node;
struct spa_type_param_buffers param_buffers;
struct spa_type_param_meta param_meta;
struct spa_type_param_io param_io;
};
static inline void init_type(struct type *type, struct spa_type_map *map)
@ -87,6 +92,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
type->props = spa_type_map_get_id(map, SPA_TYPE__Props);
type->prop_volume = spa_type_map_get_id(map, SPA_TYPE_PROPS__volume);
type->prop_mute = spa_type_map_get_id(map, SPA_TYPE_PROPS__mute);
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);
@ -98,6 +104,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
spa_type_command_node_map(map, &type->command_node);
spa_type_param_buffers_map(map, &type->param_buffers);
spa_type_param_meta_map(map, &type->param_meta);
spa_type_param_io_map(map, &type->param_io);
}
struct impl {
@ -417,7 +424,8 @@ impl_node_port_enum_params(struct spa_node *node,
uint32_t list[] = { t->param.idEnumFormat,
t->param.idFormat,
t->param.idBuffers,
t->param.idMeta };
t->param.idMeta,
t->param.idIO };
if (*index < SPA_N_ELEMENTS(list))
param = spa_pod_builder_object(&b, id, t->param.List,
@ -461,6 +469,24 @@ impl_node_port_enum_params(struct spa_node *node,
return 0;
}
}
else if (id == t->param.idIO) {
switch (*index) {
case 0:
param = spa_pod_builder_object(&b,
id, t->param_io.IO,
":", t->param_io.id, "I", t->io.Buffers,
":", t->param_io.size, "i", sizeof(struct spa_io_buffers));
break;
case 1:
param = spa_pod_builder_object(&b,
id, t->param_io.IO,
":", t->param_io.id, "I", t->io.ControlRange,
":", t->param_io.size, "i", sizeof(struct spa_io_control_range));
break;
default:
return 0;
}
}
else
return -ENOENT;
@ -607,19 +633,28 @@ 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 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;
}
@ -733,8 +768,7 @@ static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buf
static int impl_node_process_input(struct spa_node *node)
{
struct impl *this;
struct spa_port_io *input;
struct spa_port_io *output;
struct spa_io_buffers *input, *output;
struct port *in_port, *out_port;
struct spa_buffer *dbuf, *sbuf;
@ -780,7 +814,7 @@ static int impl_node_process_output(struct spa_node *node)
{
struct impl *this;
struct port *in_port, *out_port;
struct spa_port_io *input, *output;
struct spa_io_buffers *input, *output;
spa_return_val_if_fail(node != NULL, -EINVAL);
@ -803,7 +837,8 @@ static int impl_node_process_output(struct spa_node *node)
input = in_port->io;
spa_return_val_if_fail(input != NULL, -EIO);
input->range = output->range;
if (in_port->range && out_port->range)
*in_port->range = *out_port->range;
input->status = SPA_STATUS_NEED_BUFFER;
return SPA_STATUS_NEED_BUFFER;