slave -> follower

We use master/follower terminology everywhere.
This commit is contained in:
Wim Taymans 2020-02-21 10:47:32 +01:00
parent bdeeebfdd4
commit a528189d26
22 changed files with 301 additions and 300 deletions

View file

@ -56,10 +56,10 @@ struct impl {
struct spa_node *target;
struct spa_node *slave;
struct spa_hook slave_listener;
uint32_t slave_flags;
struct spa_audio_info slave_current_format;
struct spa_node *follower;
struct spa_hook follower_listener;
uint32_t follower_flags;
struct spa_audio_info follower_current_format;
struct spa_handle *hnd_convert;
struct spa_node *convert;
@ -121,7 +121,7 @@ next:
case SPA_PARAM_EnumFormat:
case SPA_PARAM_Format:
if ((res = spa_node_port_enum_params_sync(this->slave,
if ((res = spa_node_port_enum_params_sync(this->follower,
this->direction, 0,
id, &result.next, filter, &param, &b)) != 1)
return res;
@ -154,11 +154,11 @@ static int link_io(struct impl *this)
spa_zero(this->io_rate_match);
this->io_rate_match.rate = 1.0;
if ((res = spa_node_port_set_io(this->slave,
if ((res = spa_node_port_set_io(this->follower,
this->direction, 0,
SPA_IO_RateMatch,
&this->io_rate_match, sizeof(this->io_rate_match))) < 0) {
spa_log_debug(this->log, NAME " %p: set RateMatch on slave disabled %d %s", this,
spa_log_debug(this->log, NAME " %p: set RateMatch on follower disabled %d %s", this,
res, spa_strerror(res));
}
else if ((res = spa_node_port_set_io(this->convert,
@ -171,11 +171,11 @@ static int link_io(struct impl *this)
spa_zero(this->io_buffers);
if ((res = spa_node_port_set_io(this->slave,
if ((res = spa_node_port_set_io(this->follower,
this->direction, 0,
SPA_IO_Buffers,
&this->io_buffers, sizeof(this->io_buffers))) < 0) {
spa_log_warn(this->log, NAME " %p: set Buffers on slave failed %d %s", this,
spa_log_warn(this->log, NAME " %p: set Buffers on follower failed %d %s", this,
res, spa_strerror(res));
return res;
}
@ -243,11 +243,11 @@ static int negotiate_buffers(struct impl *this)
uint32_t state;
struct spa_pod *param;
int res;
bool slave_alloc, conv_alloc;
bool follower_alloc, conv_alloc;
uint32_t i, size, buffers, blocks, align, flags;
uint32_t *aligns;
struct spa_data *datas;
uint32_t slave_flags, conv_flags;
uint32_t follower_flags, conv_flags;
spa_log_debug(this->log, "%p: %d", this, this->n_buffers);
@ -256,12 +256,12 @@ static int negotiate_buffers(struct impl *this)
state = 0;
param = NULL;
if ((res = spa_node_port_enum_params_sync(this->slave,
if ((res = spa_node_port_enum_params_sync(this->follower,
this->direction, 0,
SPA_PARAM_Buffers, &state,
param, &param, &b)) < 0) {
debug_params(this, this->slave, this->direction, 0,
SPA_PARAM_Buffers, param, "slave buffers", res);
debug_params(this, this->follower, this->direction, 0,
SPA_PARAM_Buffers, param, "follower buffers", res);
return -ENOTSUP;
}
@ -278,17 +278,17 @@ static int negotiate_buffers(struct impl *this)
spa_pod_fixate(param);
slave_flags = this->slave_flags;
follower_flags = this->follower_flags;
conv_flags = this->convert_flags;
slave_alloc = SPA_FLAG_IS_SET(slave_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
follower_alloc = SPA_FLAG_IS_SET(follower_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
conv_alloc = SPA_FLAG_IS_SET(conv_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
flags = 0;
if (conv_alloc || slave_alloc) {
if (conv_alloc || follower_alloc) {
flags |= SPA_BUFFER_ALLOC_FLAG_NO_DATA;
if (conv_alloc)
slave_alloc = false;
follower_alloc = false;
}
if ((res = spa_pod_parse_object(param,
@ -300,7 +300,7 @@ static int negotiate_buffers(struct impl *this)
return res;
spa_log_debug(this->log, "%p: buffers %d, blocks %d, size %d, align %d %d:%d",
this, buffers, blocks, size, align, slave_alloc, conv_alloc);
this, buffers, blocks, size, align, follower_alloc, conv_alloc);
align = SPA_MAX(align, this->max_align);
@ -326,9 +326,9 @@ static int negotiate_buffers(struct impl *this)
this->buffers, this->n_buffers)) < 0)
return res;
if ((res = spa_node_port_use_buffers(this->slave,
if ((res = spa_node_port_use_buffers(this->follower,
this->direction, 0,
slave_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
follower_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
this->buffers, this->n_buffers)) < 0)
return res;
@ -351,7 +351,7 @@ static int configure_format(struct impl *this, uint32_t flags, const struct spa_
return res;
}
if ((res = spa_node_port_set_param(this->slave,
if ((res = spa_node_port_set_param(this->follower,
this->direction, 0,
SPA_PARAM_Format, flags,
format)) < 0)
@ -391,20 +391,20 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
if (spa_format_audio_raw_parse(param, &info.info.raw) < 0)
return -EINVAL;
this->slave_current_format = info;
this->follower_current_format = info;
break;
case SPA_PARAM_PortConfig:
if (this->started)
return -EIO;
if (this->target != this->slave) {
if (this->target != this->follower) {
if ((res = spa_node_set_param(this->target, id, flags, param)) < 0)
return res;
}
break;
case SPA_PARAM_Props:
if (this->target != this->slave) {
if (this->target != this->follower) {
if ((res = spa_node_set_param(this->target, id, flags, param)) < 0)
return res;
}
@ -426,8 +426,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
if (this->target)
res = spa_node_set_io(this->target, id, data, size);
if (this->target != this->slave)
res = spa_node_set_io(this->slave, id, data, size);
if (this->target != this->follower)
res = spa_node_set_io(this->follower, id, data, size);
return res;
}
@ -451,14 +451,14 @@ static int negotiate_format(struct impl *this)
format = NULL;
if (this->have_format)
format = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &this->slave_current_format.info.raw);
format = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &this->follower_current_format.info.raw);
if ((res = spa_node_port_enum_params_sync(this->slave,
if ((res = spa_node_port_enum_params_sync(this->follower,
this->direction, 0,
SPA_PARAM_EnumFormat, &state,
format, &format, &b)) < 0) {
debug_params(this, this->slave, this->direction, 0,
SPA_PARAM_EnumFormat, format, "slave format", res);
debug_params(this, this->follower, this->direction, 0,
SPA_PARAM_EnumFormat, format, "follower format", res);
return -ENOTSUP;
}
@ -516,8 +516,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
return res;
}
if (this->target != this->slave) {
if ((res = spa_node_send_command(this->slave, command)) < 0) {
if (this->target != this->follower) {
if ((res = spa_node_send_command(this->follower, command)) < 0) {
spa_log_error(this->log, NAME " %p: can't send command: %s",
this, spa_strerror(res));
return res;
@ -583,7 +583,7 @@ static const struct spa_node_events convert_node_events = {
.result = convert_result,
};
static void slave_info(void *data, const struct spa_node_info *info)
static void follower_info(void *data, const struct spa_node_info *info)
{
struct impl *this = data;
@ -595,7 +595,7 @@ static void slave_info(void *data, const struct spa_node_info *info)
this->info.max_input_ports = this->direction == SPA_DIRECTION_INPUT ? 128 : 0;
this->info.max_output_ports = this->direction == SPA_DIRECTION_OUTPUT ? 128 : 0;
spa_log_debug(this->log, NAME" %p: slave info %s", this,
spa_log_debug(this->log, NAME" %p: follower info %s", this,
this->direction == SPA_DIRECTION_INPUT ?
"Input" : "Output");
@ -606,7 +606,7 @@ static void slave_info(void *data, const struct spa_node_info *info)
}
}
static void slave_port_info(void *data,
static void follower_port_info(void *data,
enum spa_direction direction, uint32_t port_id,
const struct spa_port_info *info)
{
@ -630,13 +630,13 @@ static void slave_port_info(void *data,
emit_node_info(this, false);
}
static const struct spa_node_events slave_node_events = {
static const struct spa_node_events follower_node_events = {
SPA_VERSION_NODE_EVENTS,
.info = slave_info,
.port_info = slave_port_info,
.info = follower_info,
.port_info = follower_port_info,
};
static int slave_ready(void *data, int status)
static int follower_ready(void *data, int status)
{
struct impl *this = data;
@ -650,7 +650,7 @@ static int slave_ready(void *data, int status)
return spa_node_call_ready(&this->callbacks, status);
}
static int slave_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id)
static int follower_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id)
{
int res;
struct impl *this = data;
@ -663,17 +663,17 @@ static int slave_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id)
return res;
}
static int slave_xrun(void *data, uint64_t trigger, uint64_t delay, struct spa_pod *info)
static int follower_xrun(void *data, uint64_t trigger, uint64_t delay, struct spa_pod *info)
{
struct impl *this = data;
return spa_node_call_xrun(&this->callbacks, trigger, delay, info);
}
static const struct spa_node_callbacks slave_node_callbacks = {
static const struct spa_node_callbacks follower_node_callbacks = {
SPA_VERSION_NODE_CALLBACKS,
.ready = slave_ready,
.reuse_buffer = slave_reuse_buffer,
.xrun = slave_xrun,
.ready = follower_ready,
.reuse_buffer = follower_reuse_buffer,
.xrun = follower_xrun,
};
static int impl_node_add_listener(void *object,
@ -695,7 +695,7 @@ static int impl_node_add_listener(void *object,
if (events->info || events->port_info) {
spa_zero(l);
spa_node_add_listener(this->slave, &l, &slave_node_events, this);
spa_node_add_listener(this->follower, &l, &follower_node_events, this);
spa_hook_remove(&l);
if (this->use_converter) {
@ -734,7 +734,7 @@ impl_node_sync(void *object, int seq)
spa_return_val_if_fail(this != NULL, -EINVAL);
return spa_node_sync(this->slave, seq);
return spa_node_sync(this->follower, seq);
}
static int
@ -875,7 +875,7 @@ static int impl_node_process(void *object)
status = spa_node_process(this->convert);
}
status = spa_node_process(this->slave);
status = spa_node_process(this->follower);
if (this->direction == SPA_DIRECTION_OUTPUT &&
!this->master && this->use_converter) {
@ -885,7 +885,7 @@ static int impl_node_process(void *object)
break;
if (status & SPA_STATUS_NEED_DATA) {
status = spa_node_process(this->slave);
status = spa_node_process(this->follower);
if (!(status & SPA_STATUS_HAVE_DATA))
break;
}
@ -942,8 +942,8 @@ static int impl_clear(struct spa_handle *handle)
this = (struct impl *) handle;
spa_hook_remove(&this->slave_listener);
spa_node_set_callbacks(this->slave, NULL, NULL);
spa_hook_remove(&this->follower_listener);
spa_node_set_callbacks(this->follower, NULL, NULL);
if (this->buffers)
free(this->buffers);
@ -1006,11 +1006,12 @@ impl_init(const struct spa_handle_factory *factory,
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
this->cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU);
if (info == NULL || (str = spa_dict_lookup(info, "audio.adapt.slave")) == NULL)
if (info == NULL ||
(str = spa_dict_lookup(info, "audio.adapt.follower")) == NULL)
return -EINVAL;
sscanf(str, "pointer:%p", &this->slave);
if (this->slave == NULL)
sscanf(str, "pointer:%p", &this->follower);
if (this->follower == NULL)
return -EINVAL;
if (this->cpu)
@ -1043,9 +1044,9 @@ impl_init(const struct spa_handle_factory *factory,
this->info.params = this->params;
this->info.n_params = 6;
spa_node_add_listener(this->slave,
&this->slave_listener, &slave_node_events, this);
spa_node_set_callbacks(this->slave, &slave_node_callbacks, this);
spa_node_add_listener(this->follower,
&this->follower_listener, &follower_node_events, this);
spa_node_set_callbacks(this->follower, &follower_node_callbacks, this);
spa_node_add_listener(this->convert,
&this->convert_listener, &convert_node_events, this);