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

@ -75,9 +75,9 @@ struct data {
struct spa_graph_port graph_source_port_0; struct spa_graph_port graph_source_port_0;
struct spa_graph_port graph_sink_port_0; struct spa_graph_port graph_sink_port_0;
struct spa_node *source_slave_node; // audiotestsrc struct spa_node *source_follower_node; // audiotestsrc
struct spa_node *source_node; // adapter for audiotestsrc struct spa_node *source_node; // adapter for audiotestsrc
struct spa_node *sink_slave_node; // alsa-pcm-sink struct spa_node *sink_follower_node; // alsa-pcm-sink
struct spa_node *sink_node; // adapter for alsa-pcm-sink struct spa_node *sink_node; // adapter for alsa-pcm-sink
struct spa_io_buffers source_sink_io[1]; struct spa_io_buffers source_sink_io[1];
@ -264,11 +264,11 @@ static int make_nodes(struct data *data, const char *device)
struct spa_pod *param; struct spa_pod *param;
/* make the source node (audiotestsrc) */ /* make the source node (audiotestsrc) */
if ((res = make_node(data, &data->source_slave_node, if ((res = make_node(data, &data->source_follower_node,
"build/spa/plugins/audiotestsrc/libspa-audiotestsrc.so", "build/spa/plugins/audiotestsrc/libspa-audiotestsrc.so",
"audiotestsrc", "audiotestsrc",
NULL)) < 0) { NULL)) < 0) {
printf("can't create source slave node (audiotestsrc): %d\n", res); printf("can't create source follower node (audiotestsrc): %d\n", res);
return res; return res;
} }
@ -279,16 +279,16 @@ static int make_nodes(struct data *data, const char *device)
.format = SPA_AUDIO_FORMAT_S16, .format = SPA_AUDIO_FORMAT_S16,
.rate = 48000, .rate = 48000,
.channels = 2 )); .channels = 2 ));
if ((res = spa_node_port_set_param(data->source_slave_node, if ((res = spa_node_port_set_param(data->source_follower_node,
SPA_DIRECTION_OUTPUT, 0, SPA_DIRECTION_OUTPUT, 0,
SPA_PARAM_Format, 0, param)) < 0) { SPA_PARAM_Format, 0, param)) < 0) {
printf("can't set format on slave node (audiotestsrc): %d\n", res); printf("can't set format on follower node (audiotestsrc): %d\n", res);
return res; return res;
} }
/* make the sink adapter node */ /* make the sink adapter node */
snprintf(value, sizeof(value), "pointer:%p", data->source_slave_node); snprintf(value, sizeof(value), "pointer:%p", data->source_follower_node);
items[0] = SPA_DICT_ITEM_INIT("audio.adapt.slave", value); items[0] = SPA_DICT_ITEM_INIT("audio.adapt.follower", value);
if ((res = make_node(data, &data->source_node, if ((res = make_node(data, &data->source_node,
"build/spa/plugins/audioconvert/libspa-audioconvert.so", "build/spa/plugins/audioconvert/libspa-audioconvert.so",
SPA_NAME_AUDIO_ADAPT, SPA_NAME_AUDIO_ADAPT,
@ -305,7 +305,7 @@ static int make_nodes(struct data *data, const char *device)
SPA_PROP_volume, SPA_POD_Float(0.5), SPA_PROP_volume, SPA_POD_Float(0.5),
SPA_PROP_live, SPA_POD_Bool(false)); SPA_PROP_live, SPA_POD_Bool(false));
if ((res = spa_node_set_param(data->source_node, SPA_PARAM_Props, 0, props)) < 0) { if ((res = spa_node_set_param(data->source_node, SPA_PARAM_Props, 0, props)) < 0) {
printf("can't setup source slave node %d\n", res); printf("can't setup source follower node %d\n", res);
return res; return res;
} }
@ -327,18 +327,18 @@ static int make_nodes(struct data *data, const char *device)
return res; return res;
} }
/* make the sink slave node (alsa-pcm-sink) */ /* make the sink follower node (alsa-pcm-sink) */
if ((res = make_node(data, &data->sink_slave_node, if ((res = make_node(data, &data->sink_follower_node,
"build/spa/plugins/alsa/libspa-alsa.so", "build/spa/plugins/alsa/libspa-alsa.so",
SPA_NAME_API_ALSA_PCM_SINK, SPA_NAME_API_ALSA_PCM_SINK,
NULL)) < 0) { NULL)) < 0) {
printf("can't create sink slave node (alsa-pcm-sink): %d\n", res); printf("can't create sink follower node (alsa-pcm-sink): %d\n", res);
return res; return res;
} }
/* make the sink adapter node */ /* make the sink adapter node */
snprintf(value, sizeof(value), "pointer:%p", data->sink_slave_node); snprintf(value, sizeof(value), "pointer:%p", data->sink_follower_node);
items[0] = SPA_DICT_ITEM_INIT("audio.adapt.slave", value); items[0] = SPA_DICT_ITEM_INIT("audio.adapt.follower", value);
if ((res = make_node(data, &data->sink_node, if ((res = make_node(data, &data->sink_node,
"build/spa/plugins/audioconvert/libspa-audioconvert.so", "build/spa/plugins/audioconvert/libspa-audioconvert.so",
SPA_NAME_AUDIO_ADAPT, SPA_NAME_AUDIO_ADAPT,
@ -347,7 +347,7 @@ static int make_nodes(struct data *data, const char *device)
return res; return res;
} }
/* add sink slave node callbacks */ /* add sink follower node callbacks */
spa_node_set_callbacks(data->sink_node, &sink_node_callbacks, data); spa_node_set_callbacks(data->sink_node, &sink_node_callbacks, data);
/* setup the sink node props */ /* setup the sink node props */
@ -356,8 +356,8 @@ static int make_nodes(struct data *data, const char *device)
SPA_TYPE_OBJECT_Props, 0, SPA_TYPE_OBJECT_Props, 0,
SPA_PROP_device, SPA_POD_String(device ? device : "hw:0"), SPA_PROP_device, SPA_POD_String(device ? device : "hw:0"),
SPA_PROP_minLatency, SPA_POD_Int(MIN_LATENCY)); SPA_PROP_minLatency, SPA_POD_Int(MIN_LATENCY));
if ((res = spa_node_set_param(data->sink_slave_node, SPA_PARAM_Props, 0, props)) < 0) { if ((res = spa_node_set_param(data->sink_follower_node, SPA_PARAM_Props, 0, props)) < 0) {
printf("can't setup sink slave node %d\n", res); printf("can't setup sink follower node %d\n", res);
return res; return res;
} }
@ -461,9 +461,9 @@ static int negotiate_formats(struct data *data)
uint32_t state = 0; uint32_t state = 0;
size_t buffer_size = 1024; size_t buffer_size = 1024;
/* get the source slave node buffer size */ /* get the source follower node buffer size */
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
if (spa_node_port_enum_params_sync(data->source_slave_node, if (spa_node_port_enum_params_sync(data->source_follower_node,
SPA_DIRECTION_OUTPUT, 0, SPA_DIRECTION_OUTPUT, 0,
SPA_PARAM_Buffers, &state, filter, &param, &b) != 1) SPA_PARAM_Buffers, &state, filter, &param, &b) != 1)
return res; return res;
@ -561,7 +561,7 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
/* make the nodes (audiotestsrc and adapter with alsa-pcm-sink as slave) */ /* make the nodes (audiotestsrc and adapter with alsa-pcm-sink as follower) */
if ((res = make_nodes(&data, argc > 1 ? argv[1] : NULL)) < 0) { if ((res = make_nodes(&data, argc > 1 ? argv[1] : NULL)) < 0) {
printf("can't make nodes: %d (%s)\n", res, spa_strerror(res)); printf("can't make nodes: %d (%s)\n", res, spa_strerror(res));
return -1; return -1;

View file

@ -189,7 +189,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
default: default:
return -ENOENT; return -ENOENT;
} }
spa_alsa_reslave(this); spa_alsa_reassign_follower(this);
return 0; return 0;
} }

View file

@ -188,7 +188,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
default: default:
return -ENOENT; return -ENOENT;
} }
spa_alsa_reslave(this); spa_alsa_reassign_follower(this);
return 0; return 0;
} }
@ -647,10 +647,10 @@ static int impl_node_process(void *object)
io->buffer_id = SPA_ID_INVALID; io->buffer_id = SPA_ID_INVALID;
} }
if (spa_list_is_empty(&this->ready) && this->slaved) if (spa_list_is_empty(&this->ready) && this->following)
spa_alsa_read(this, 0); spa_alsa_read(this, 0);
if (spa_list_is_empty(&this->ready) || !this->slaved) if (spa_list_is_empty(&this->ready) || !this->following)
return SPA_STATUS_OK; return SPA_STATUS_OK;
b = spa_list_first(&this->ready, struct buffer, link); b = spa_list_first(&this->ready, struct buffer, link);

View file

@ -647,7 +647,7 @@ static int get_status(struct state *state, snd_pcm_uframes_t *delay, snd_pcm_ufr
} }
static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t delay, static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t delay,
snd_pcm_sframes_t target, bool slave) snd_pcm_sframes_t target, bool follower)
{ {
double err, corr; double err, corr;
@ -669,8 +669,8 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
if (state->last_threshold != state->threshold) { if (state->last_threshold != state->threshold) {
int32_t diff = (int32_t) (state->last_threshold - state->threshold); int32_t diff = (int32_t) (state->last_threshold - state->threshold);
spa_log_trace(state->log, NAME" %p: slave:%d quantum change %d", spa_log_trace(state->log, NAME" %p: follower:%d quantum change %d",
state, slave, diff); state, follower, diff);
state->next_time += diff / corr * 1e9 / state->rate; state->next_time += diff / corr * 1e9 / state->rate;
state->last_threshold = state->threshold; state->last_threshold = state->threshold;
} }
@ -682,8 +682,8 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
else if (state->bw == BW_MED) else if (state->bw == BW_MED)
set_loop(state, BW_MIN); set_loop(state, BW_MIN);
spa_log_debug(state->log, NAME" %p: slave:%d match:%d rate:%f bw:%f del:%d target:%ld err:%f (%f %f %f)", spa_log_debug(state->log, NAME" %p: follower:%d match:%d rate:%f bw:%f del:%d target:%ld err:%f (%f %f %f)",
state, slave, state->matching, corr, state->bw, state->delay, target, state, follower, state->matching, corr, state->bw, state->delay, target,
err, state->z1, state->z2, state->z3); err, state->z1, state->z2, state->z3);
} }
@ -698,7 +698,7 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
state->next_time += state->threshold / corr * 1e9 / state->rate; state->next_time += state->threshold / corr * 1e9 / state->rate;
if (!slave && state->clock) { if (!follower && state->clock) {
state->clock->nsec = nsec; state->clock->nsec = nsec;
state->clock->position += state->duration; state->clock->position += state->duration;
state->clock->duration = state->duration; state->clock->duration = state->duration;
@ -707,8 +707,8 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
state->clock->next_nsec = state->next_time; state->clock->next_nsec = state->next_time;
} }
spa_log_trace_fp(state->log, NAME" %p: slave:%d %"PRIu64" %f %ld %f %f %d", spa_log_trace_fp(state->log, NAME" %p: follower:%d %"PRIu64" %f %ld %f %f %d",
state, slave, nsec, corr, delay, err, state->threshold * corr, state, follower, nsec, corr, delay, err, state->threshold * corr,
state->threshold); state->threshold);
return 0; return 0;
@ -726,7 +726,7 @@ int spa_alsa_write(struct state *state, snd_pcm_uframes_t silence)
state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom; state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
} }
if (state->slaved && state->alsa_started) { if (state->following && state->alsa_started) {
uint64_t nsec; uint64_t nsec;
snd_pcm_uframes_t delay, target; snd_pcm_uframes_t delay, target;
@ -734,7 +734,7 @@ int spa_alsa_write(struct state *state, snd_pcm_uframes_t silence)
return res; return res;
if (!state->alsa_recovering && delay > target + state->threshold) { if (!state->alsa_recovering && delay > target + state->threshold) {
spa_log_warn(state->log, NAME" %p: slave delay:%ld resync %f %f %f", spa_log_warn(state->log, NAME" %p: follower delay:%ld resync %f %f %f",
state, delay, state->z1, state->z2, state->z3); state, delay, state->z1, state->z2, state->z3);
init_loop(state); init_loop(state);
state->alsa_sync = true; state->alsa_sync = true;
@ -927,7 +927,7 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence)
state->duration = state->position->clock.duration; state->duration = state->position->clock.duration;
state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom; state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
} }
if (!state->slaved) { if (!state->following) {
uint64_t position; uint64_t position;
position = state->position->clock.position; position = state->position->clock.position;
@ -941,7 +941,7 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence)
} }
} }
if (state->slaved && state->alsa_started) { if (state->following && state->alsa_started) {
uint64_t nsec; uint64_t nsec;
snd_pcm_uframes_t delay, target; snd_pcm_uframes_t delay, target;
uint32_t threshold = state->threshold; uint32_t threshold = state->threshold;
@ -950,13 +950,13 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence)
return res; return res;
if (!state->alsa_recovering && (delay < target || delay > target * 2)) { if (!state->alsa_recovering && (delay < target || delay > target * 2)) {
spa_log_warn(state->log, NAME" %p: slave delay:%lu target:%lu resync %f %f %f", spa_log_warn(state->log, NAME" %p: follower delay:%lu target:%lu resync %f %f %f",
state, delay, target, state->z1, state->z2, state->z3); state, delay, target, state->z1, state->z2, state->z3);
init_loop(state); init_loop(state);
state->alsa_sync = true; state->alsa_sync = true;
} }
if (state->alsa_sync) { if (state->alsa_sync) {
spa_log_warn(state->log, NAME" %p: slave resync %ld %d %ld", spa_log_warn(state->log, NAME" %p: follower resync %ld %d %ld",
state, delay, threshold, target); state, delay, threshold, target);
if (delay < target) if (delay < target)
snd_pcm_rewind(state->hndl, target - delay + 32); snd_pcm_rewind(state->hndl, target - delay + 32);
@ -1131,7 +1131,7 @@ static int set_timers(struct state *state)
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now); spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now);
state->next_time = SPA_TIMESPEC_TO_NSEC(&now); state->next_time = SPA_TIMESPEC_TO_NSEC(&now);
if (state->slaved) { if (state->following) {
set_timeout(state, 0); set_timeout(state, 0);
} else { } else {
set_timeout(state, state->next_time); set_timeout(state, state->next_time);
@ -1139,7 +1139,7 @@ static int set_timers(struct state *state)
return 0; return 0;
} }
static inline bool is_slaved(struct state *state) static inline bool is_following(struct state *state)
{ {
return state->position && state->clock && state->position->clock.id != state->clock->id; return state->position && state->clock && state->position->clock.id != state->clock->id;
} }
@ -1151,8 +1151,8 @@ int spa_alsa_start(struct state *state)
if (state->started) if (state->started)
return 0; return 0;
state->slaved = is_slaved(state); state->following = is_following(state);
state->matching = state->slaved; state->matching = state->following;
if (state->position) { if (state->position) {
int card; int card;
@ -1175,9 +1175,9 @@ int spa_alsa_start(struct state *state)
init_loop(state); init_loop(state);
state->safety = 0.0; state->safety = 0.0;
spa_log_debug(state->log, NAME" %p: start %d duration:%d rate:%d slave:%d match:%d", spa_log_debug(state->log, NAME" %p: start %d duration:%d rate:%d follower:%d match:%d",
state, state->threshold, state->duration, state->rate_denom, state, state->threshold, state->duration, state->rate_denom,
state->slaved, state->matching); state->following, state->matching);
CHECK(set_swparams(state), "swparams"); CHECK(set_swparams(state), "swparams");
if (SPA_UNLIKELY(spa_log_level_enabled(state->log, SPA_LOG_LEVEL_DEBUG))) if (SPA_UNLIKELY(spa_log_level_enabled(state->log, SPA_LOG_LEVEL_DEBUG)))
@ -1218,7 +1218,7 @@ int spa_alsa_start(struct state *state)
return 0; return 0;
} }
static int do_reslave(struct spa_loop *loop, static int do_reassign_follower(struct spa_loop *loop,
bool async, bool async,
uint32_t seq, uint32_t seq,
const void *data, const void *data,
@ -1231,18 +1231,18 @@ static int do_reslave(struct spa_loop *loop,
return 0; return 0;
} }
int spa_alsa_reslave(struct state *state) int spa_alsa_reassign_follower(struct state *state)
{ {
bool slaved; bool following;
if (!state->started) if (!state->started)
return 0; return 0;
slaved = is_slaved(state); following = is_following(state);
if (slaved != state->slaved) { if (following != state->following) {
spa_log_debug(state->log, NAME" %p: reslave %d->%d", state, state->slaved, slaved); spa_log_debug(state->log, NAME" %p: reassign follower %d->%d", state, state->following, following);
state->slaved = slaved; state->following = following;
spa_loop_invoke(state->data_loop, do_reslave, 0, NULL, 0, true, state); spa_loop_invoke(state->data_loop, do_reassign_follower, 0, NULL, 0, true, state);
} }
return 0; return 0;
} }

View file

@ -139,7 +139,7 @@ struct state {
unsigned int alsa_started:1; unsigned int alsa_started:1;
unsigned int alsa_sync:1; unsigned int alsa_sync:1;
unsigned int alsa_recovering:1; unsigned int alsa_recovering:1;
unsigned int slaved:1; unsigned int following:1;
unsigned int matching:1; unsigned int matching:1;
int64_t sample_count; int64_t sample_count;
@ -165,7 +165,7 @@ spa_alsa_enum_format(struct state *state, int seq,
int spa_alsa_set_format(struct state *state, struct spa_audio_info *info, uint32_t flags); int spa_alsa_set_format(struct state *state, struct spa_audio_info *info, uint32_t flags);
int spa_alsa_start(struct state *state); int spa_alsa_start(struct state *state);
int spa_alsa_reslave(struct state *state); int spa_alsa_reassign_follower(struct state *state);
int spa_alsa_pause(struct state *state); int spa_alsa_pause(struct state *state);
int spa_alsa_close(struct state *state); int spa_alsa_close(struct state *state);

View file

@ -149,7 +149,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
default: default:
return -ENOENT; return -ENOENT;
} }
spa_alsa_seq_reslave(this); spa_alsa_seq_reassign_follower(this);
return 0; return 0;
} }

View file

@ -647,7 +647,7 @@ static void set_loop(struct seq_state *state, double bw)
#define NSEC_TO_CLOCK(c,n) ((n) * (c)->rate.denom / ((c)->rate.num * SPA_NSEC_PER_SEC)) #define NSEC_TO_CLOCK(c,n) ((n) * (c)->rate.denom / ((c)->rate.num * SPA_NSEC_PER_SEC))
static int update_time(struct seq_state *state, uint64_t nsec, bool slave) static int update_time(struct seq_state *state, uint64_t nsec, bool follower)
{ {
snd_seq_queue_status_t *status; snd_seq_queue_status_t *status;
const snd_seq_real_time_t* queue_time; const snd_seq_real_time_t* queue_time;
@ -699,13 +699,13 @@ static int update_time(struct seq_state *state, uint64_t nsec, bool slave)
else if (state->bw == BW_MED) else if (state->bw == BW_MED)
set_loop(state, BW_MIN); set_loop(state, BW_MIN);
spa_log_debug(state->log, NAME" %p: slave:%d rate:%f bw:%f err:%f (%f %f %f)", spa_log_debug(state->log, NAME" %p: follower:%d rate:%f bw:%f err:%f (%f %f %f)",
state, slave, corr, state->bw, err, state->z1, state->z2, state->z3); state, follower, corr, state->bw, err, state->z1, state->z2, state->z3);
} }
state->next_time += state->threshold / corr * 1e9 / state->rate.denom; state->next_time += state->threshold / corr * 1e9 / state->rate.denom;
if (!slave && state->clock) { if (!follower && state->clock) {
state->clock->nsec = nsec; state->clock->nsec = nsec;
state->clock->position += state->duration; state->clock->position += state->duration;
state->clock->duration = state->duration; state->clock->duration = state->duration;
@ -726,7 +726,7 @@ int spa_alsa_seq_process(struct seq_state *state)
res = process_recycle(state); res = process_recycle(state);
if (state->slaved) { if (state->following) {
update_time(state, state->position->clock.nsec, true); update_time(state, state->position->clock.nsec, true);
res |= process_read(state); res |= process_read(state);
} }
@ -791,7 +791,7 @@ static int set_timers(struct seq_state *state)
spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now); spa_system_clock_gettime(state->data_system, CLOCK_MONOTONIC, &now);
state->next_time = SPA_TIMESPEC_TO_NSEC(&now); state->next_time = SPA_TIMESPEC_TO_NSEC(&now);
if (state->slaved) { if (state->following) {
set_timeout(state, 0); set_timeout(state, 0);
} else { } else {
set_timeout(state, state->next_time); set_timeout(state, state->next_time);
@ -799,7 +799,7 @@ static int set_timers(struct seq_state *state)
return 0; return 0;
} }
static inline bool is_slaved(struct seq_state *state) static inline bool is_following(struct seq_state *state)
{ {
return state->position && state->clock && state->position->clock.id != state->clock->id; return state->position && state->clock && state->position->clock.id != state->clock->id;
} }
@ -811,9 +811,9 @@ int spa_alsa_seq_start(struct seq_state *state)
if (state->started) if (state->started)
return 0; return 0;
state->slaved = is_slaved(state); state->following = is_following(state);
spa_log_debug(state->log, "alsa %p: start slave:%d", state, state->slaved); spa_log_debug(state->log, "alsa %p: start follower:%d", state, state->following);
if ((res = seq_start(state, &state->event)) < 0) if ((res = seq_start(state, &state->event)) < 0)
return res; return res;
@ -844,7 +844,7 @@ int spa_alsa_seq_start(struct seq_state *state)
return 0; return 0;
} }
static int do_reslave(struct spa_loop *loop, static int do_reassign_follower(struct spa_loop *loop,
bool async, bool async,
uint32_t seq, uint32_t seq,
const void *data, const void *data,
@ -856,18 +856,18 @@ static int do_reslave(struct spa_loop *loop,
return 0; return 0;
} }
int spa_alsa_seq_reslave(struct seq_state *state) int spa_alsa_seq_reassign_follower(struct seq_state *state)
{ {
bool slaved; bool following;
if (!state->started) if (!state->started)
return 0; return 0;
slaved = is_slaved(state); following = is_following(state);
if (slaved != state->slaved) { if (following != state->following) {
spa_log_debug(state->log, "alsa %p: reslave %d->%d", state, state->slaved, slaved); spa_log_debug(state->log, "alsa %p: reassign follower %d->%d", state, state->following, following);
state->slaved = slaved; state->following = following;
spa_loop_invoke(state->data_loop, do_reslave, 0, NULL, 0, true, state); spa_loop_invoke(state->data_loop, do_reassign_follower, 0, NULL, 0, true, state);
} }
return 0; return 0;
} }

View file

@ -149,7 +149,7 @@ struct seq_state {
unsigned int opened:1; unsigned int opened:1;
unsigned int started:1; unsigned int started:1;
unsigned int slaved:1; unsigned int following:1;
struct seq_stream streams[2]; struct seq_stream streams[2];
@ -171,7 +171,7 @@ int spa_alsa_seq_close(struct seq_state *state);
int spa_alsa_seq_start(struct seq_state *state); int spa_alsa_seq_start(struct seq_state *state);
int spa_alsa_seq_pause(struct seq_state *state); int spa_alsa_seq_pause(struct seq_state *state);
int spa_alsa_seq_reslave(struct seq_state *state); int spa_alsa_seq_reassign_follower(struct seq_state *state);
int spa_alsa_seq_recycle_buffer(struct seq_state *state, struct seq_port *port, uint32_t buffer_id); int spa_alsa_seq_recycle_buffer(struct seq_state *state, struct seq_port *port, uint32_t buffer_id);

View file

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

View file

@ -43,8 +43,8 @@ SPA_LOG_IMPL(logger);
extern const struct spa_handle_factory test_source_factory; extern const struct spa_handle_factory test_source_factory;
struct context { struct context {
struct spa_handle *slave_handle; struct spa_handle *follower_handle;
struct spa_node *slave_node; struct spa_node *follower_node;
struct spa_handle *adapter_handle; struct spa_handle *adapter_handle;
struct spa_node *adapter_node; struct spa_node *adapter_node;
@ -75,22 +75,22 @@ static int setup_context(struct context *ctx)
logger.log.level = SPA_LOG_LEVEL_TRACE; logger.log.level = SPA_LOG_LEVEL_TRACE;
support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, &logger.log); support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, &logger.log);
/* make slave */ /* make follower */
factory = &test_source_factory; factory = &test_source_factory;
size = spa_handle_factory_get_size(factory, NULL); size = spa_handle_factory_get_size(factory, NULL);
ctx->slave_handle = calloc(1, size); ctx->follower_handle = calloc(1, size);
spa_assert(ctx->slave_handle != NULL); spa_assert(ctx->follower_handle != NULL);
res = spa_handle_factory_init(factory, res = spa_handle_factory_init(factory,
ctx->slave_handle, ctx->follower_handle,
NULL, support, 1); NULL, support, 1);
spa_assert(res >= 0); spa_assert(res >= 0);
res = spa_handle_get_interface(ctx->slave_handle, res = spa_handle_get_interface(ctx->follower_handle,
SPA_TYPE_INTERFACE_Node, &iface); SPA_TYPE_INTERFACE_Node, &iface);
spa_assert(res >= 0); spa_assert(res >= 0);
ctx->slave_node = iface; ctx->follower_node = iface;
/* make adapter */ /* make adapter */
factory = find_factory(SPA_NAME_AUDIO_ADAPT); factory = find_factory(SPA_NAME_AUDIO_ADAPT);
@ -101,8 +101,8 @@ static int setup_context(struct context *ctx)
ctx->adapter_handle = calloc(1, size); ctx->adapter_handle = calloc(1, size);
spa_assert(ctx->adapter_handle != NULL); spa_assert(ctx->adapter_handle != NULL);
snprintf(value, sizeof(value), "pointer:%p", ctx->slave_node); snprintf(value, sizeof(value), "pointer:%p", ctx->follower_node);
items[0] = SPA_DICT_ITEM_INIT("audio.adapt.slave", value); items[0] = SPA_DICT_ITEM_INIT("audio.adapt.follower", value);
res = spa_handle_factory_init(factory, res = spa_handle_factory_init(factory,
ctx->adapter_handle, ctx->adapter_handle,
@ -121,9 +121,9 @@ static int setup_context(struct context *ctx)
static int clean_context(struct context *ctx) static int clean_context(struct context *ctx)
{ {
spa_handle_clear(ctx->adapter_handle); spa_handle_clear(ctx->adapter_handle);
spa_handle_clear(ctx->slave_handle); spa_handle_clear(ctx->follower_handle);
free(ctx->adapter_handle); free(ctx->adapter_handle);
free(ctx->slave_handle); free(ctx->follower_handle);
return 0; return 0;
} }

View file

@ -112,7 +112,7 @@ struct impl {
struct port port; struct port port;
unsigned int started:1; unsigned int started:1;
unsigned int slaved:1; unsigned int following:1;
struct spa_source source; struct spa_source source;
int timerfd; int timerfd;
@ -246,7 +246,7 @@ static int set_timers(struct impl *this)
int res; int res;
ts.it_value.tv_sec = 0; ts.it_value.tv_sec = 0;
if (this->slaved) { if (this->following) {
ts.it_value.tv_nsec = 0; ts.it_value.tv_nsec = 0;
} else { } else {
ts.it_value.tv_nsec = 1; ts.it_value.tv_nsec = 1;
@ -260,7 +260,7 @@ static int set_timers(struct impl *this)
return res; return res;
} }
static int do_reslave(struct spa_loop *loop, static int do_reassign_follower(struct spa_loop *loop,
bool async, bool async,
uint32_t seq, uint32_t seq,
const void *data, const void *data,
@ -272,7 +272,7 @@ static int do_reslave(struct spa_loop *loop,
return 0; return 0;
} }
static inline bool is_slaved(struct impl *this) static inline bool is_following(struct impl *this)
{ {
return this->position && this->clock && this->position->clock.id != this->clock->id; return this->position && this->clock && this->position->clock.id != this->clock->id;
} }
@ -280,7 +280,7 @@ static inline bool is_slaved(struct impl *this)
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
{ {
struct impl *this = object; struct impl *this = object;
bool slaved; bool following;
spa_return_val_if_fail(this != NULL, -EINVAL); spa_return_val_if_fail(this != NULL, -EINVAL);
@ -295,11 +295,11 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
return -ENOENT; return -ENOENT;
} }
slaved = is_slaved(this); following = is_following(this);
if (this->started && slaved != this->slaved) { if (this->started && following != this->following) {
spa_log_debug(this->log, NAME " %p: reslave %d->%d", this, this->slaved, slaved); spa_log_debug(this->log, NAME " %p: reassign follower %d->%d", this, this->following, following);
this->slaved = slaved; this->following = following;
spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this);
} }
return 0; return 0;
} }
@ -626,7 +626,7 @@ static int flush_data(struct impl *this, uint64_t now_time)
spa_log_trace(this->log, NAME" %p: %"PRIu64" %"PRIi64" %"PRIu64" %"PRIu64" %d", this, spa_log_trace(this->log, NAME" %p: %"PRIu64" %"PRIi64" %"PRIu64" %"PRIu64" %d", this,
now_time, queued, this->sample_time, elapsed, this->write_samples); now_time, queued, this->sample_time, elapsed, this->write_samples);
if (!this->slaved) { if (!this->following) {
if (queued < FILL_FRAMES * this->write_samples) { if (queued < FILL_FRAMES * this->write_samples) {
queued = (FILL_FRAMES + 1) * this->write_samples; queued = (FILL_FRAMES + 1) * this->write_samples;
if (this->sample_time < elapsed) { if (this->sample_time < elapsed) {
@ -797,9 +797,9 @@ static int do_start(struct impl *this)
if (this->started) if (this->started)
return 0; return 0;
this->slaved = is_slaved(this); this->following = is_following(this);
spa_log_debug(this->log, NAME " %p: start slaved:%d", this, this->slaved); spa_log_debug(this->log, NAME " %p: start following:%d", this, this->following);
if ((res = spa_bt_transport_acquire(this->transport, false)) < 0) if ((res = spa_bt_transport_acquire(this->transport, false)) < 0)
return res; return res;

View file

@ -113,7 +113,7 @@ struct impl {
struct port port; struct port port;
unsigned int started:1; unsigned int started:1;
unsigned int slaved:1; unsigned int following:1;
struct spa_source source; struct spa_source source;
@ -216,7 +216,7 @@ static int impl_node_enum_params(void *object, int seq,
return 0; return 0;
} }
static int do_reslave(struct spa_loop *loop, static int do_reassing_follower(struct spa_loop *loop,
bool async, bool async,
uint32_t seq, uint32_t seq,
const void *data, const void *data,
@ -226,7 +226,7 @@ static int do_reslave(struct spa_loop *loop,
return 0; return 0;
} }
static inline bool is_slaved(struct impl *this) static inline bool is_following(struct impl *this)
{ {
return this->position && this->clock && this->position->clock.id != this->clock->id; return this->position && this->clock && this->position->clock.id != this->clock->id;
} }
@ -234,7 +234,7 @@ static inline bool is_slaved(struct impl *this)
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
{ {
struct impl *this = object; struct impl *this = object;
bool slaved; bool following;
spa_return_val_if_fail(this != NULL, -EINVAL); spa_return_val_if_fail(this != NULL, -EINVAL);
@ -249,11 +249,11 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
return -ENOENT; return -ENOENT;
} }
slaved = is_slaved(this); following = is_following(this);
if (this->started && slaved != this->slaved) { if (this->started && following != this->following) {
spa_log_debug(this->log, NAME" %p: reslave %d->%d", this, this->slaved, slaved); spa_log_debug(this->log, NAME" %p: reassign follower %d->%d", this, this->following, following);
this->slaved = slaved; this->following = following;
spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); spa_loop_invoke(this->data_loop, do_reassing_follower, 0, NULL, 0, true, this);
} }
return 0; return 0;
} }

View file

@ -112,7 +112,7 @@ struct impl {
/* Flags */ /* Flags */
unsigned int started:1; unsigned int started:1;
unsigned int slaved:1; unsigned int following:1;
/* Sources */ /* Sources */
struct spa_source source; struct spa_source source;
@ -238,7 +238,7 @@ static void set_timeout(struct impl *this, time_t sec, long nsec)
static void reset_timeout(struct impl *this) static void reset_timeout(struct impl *this)
{ {
set_timeout(this, 0, this->slaved ? 0 : 1); set_timeout(this, 0, this->following ? 0 : 1);
} }
@ -246,8 +246,8 @@ static void set_next_timeout(struct impl *this, uint64_t now_time)
{ {
struct port *port = &this->port; struct port *port = &this->port;
/* Set the next timeout if not slaved, otherwise reset values */ /* Set the next timeout if not following, otherwise reset values */
if (!this->slaved) { if (!this->following) {
/* Get the elapsed time */ /* Get the elapsed time */
uint64_t elapsed_time = 0; uint64_t elapsed_time = 0;
if (now_time > this->start_time) if (now_time > this->start_time)
@ -271,7 +271,7 @@ static void set_next_timeout(struct impl *this, uint64_t now_time)
} }
} }
static int do_reslave(struct spa_loop *loop, static int do_reassign_follower(struct spa_loop *loop,
bool async, bool async,
uint32_t seq, uint32_t seq,
const void *data, const void *data,
@ -283,7 +283,7 @@ static int do_reslave(struct spa_loop *loop,
return 0; return 0;
} }
static inline bool is_slaved(struct impl *this) static inline bool is_following(struct impl *this)
{ {
return this->position && this->clock && this->position->clock.id != this->clock->id; return this->position && this->clock && this->position->clock.id != this->clock->id;
} }
@ -291,7 +291,7 @@ static inline bool is_slaved(struct impl *this)
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
{ {
struct impl *this = object; struct impl *this = object;
bool slaved; bool following;
spa_return_val_if_fail(object != NULL, -EINVAL); spa_return_val_if_fail(object != NULL, -EINVAL);
@ -306,11 +306,11 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
return -ENOENT; return -ENOENT;
} }
slaved = is_slaved(this); following = is_following(this);
if (this->started && slaved != this->slaved) { if (this->started && following != this->following) {
spa_log_debug(this->log, "sco-sink %p: reslave %d->%d", this, this->slaved, slaved); spa_log_debug(this->log, "sco-sink %p: reassign follower %d->%d", this, this->following, following);
this->slaved = slaved; this->following = following;
spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this);
} }
return 0; return 0;
} }
@ -505,8 +505,8 @@ static int do_start(struct impl *this)
/* Make sure the transport is valid */ /* Make sure the transport is valid */
spa_return_val_if_fail (this->transport != NULL, -EIO); spa_return_val_if_fail (this->transport != NULL, -EIO);
/* Set the slaved flag */ /* Set the following flag */
this->slaved = is_slaved(this); this->following = is_following(this);
/* Do accept if Gateway; otherwise do connect for Head Unit */ /* Do accept if Gateway; otherwise do connect for Head Unit */
do_accept = this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY; do_accept = this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY;

View file

@ -108,7 +108,7 @@ struct impl {
struct port port; struct port port;
unsigned int started:1; unsigned int started:1;
unsigned int slaved:1; unsigned int following:1;
struct spa_source source; struct spa_source source;
@ -209,7 +209,7 @@ static int impl_node_enum_params(void *object, int seq,
return 0; return 0;
} }
static int do_reslave(struct spa_loop *loop, static int do_reassign_follower(struct spa_loop *loop,
bool async, bool async,
uint32_t seq, uint32_t seq,
const void *data, const void *data,
@ -219,7 +219,7 @@ static int do_reslave(struct spa_loop *loop,
return 0; return 0;
} }
static inline bool is_slaved(struct impl *this) static inline bool is_following(struct impl *this)
{ {
return this->position && this->clock && this->position->clock.id != this->clock->id; return this->position && this->clock && this->position->clock.id != this->clock->id;
} }
@ -227,7 +227,7 @@ static inline bool is_slaved(struct impl *this)
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
{ {
struct impl *this = object; struct impl *this = object;
bool slaved; bool following;
spa_return_val_if_fail(this != NULL, -EINVAL); spa_return_val_if_fail(this != NULL, -EINVAL);
@ -242,11 +242,11 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
return -ENOENT; return -ENOENT;
} }
slaved = is_slaved(this); following = is_following(this);
if (this->started && slaved != this->slaved) { if (this->started && following != this->following) {
spa_log_debug(this->log, "sco-source %p: reslave %d->%d", this, this->slaved, slaved); spa_log_debug(this->log, "sco-source %p: reassign follower %d->%d", this, this->following, following);
this->slaved = slaved; this->following = following;
spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this);
} }
return 0; return 0;
} }

View file

@ -52,9 +52,9 @@ struct impl {
struct spa_node *target; struct spa_node *target;
struct spa_hook target_listener; struct spa_hook target_listener;
struct spa_node *slave; struct spa_node *follower;
struct spa_hook slave_listener; struct spa_hook follower_listener;
uint32_t slave_flags; uint32_t follower_flags;
struct spa_handle *hnd_convert; struct spa_handle *hnd_convert;
struct spa_node *convert; struct spa_node *convert;
@ -116,7 +116,7 @@ next:
case SPA_PARAM_EnumFormat: case SPA_PARAM_EnumFormat:
case SPA_PARAM_Format: 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, this->direction, 0,
id, &start, filter, &param, &b)) != 1) id, &start, filter, &param, &b)) != 1)
return res; return res;
@ -150,11 +150,11 @@ static int link_io(struct impl *this)
spa_zero(this->io_rate_match); spa_zero(this->io_rate_match);
this->io_rate_match.rate = 1.0; 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, this->direction, 0,
SPA_IO_RateMatch, SPA_IO_RateMatch,
&this->io_rate_match, sizeof(this->io_rate_match))) < 0) { &this->io_rate_match, sizeof(this->io_rate_match))) < 0) {
spa_log_warn(this->log, NAME " %p: set RateMatch on slave failed %d %s", this, spa_log_warn(this->log, NAME " %p: set RateMatch on follower failed %d %s", this,
res, spa_strerror(res)); res, spa_strerror(res));
} }
else if ((res = spa_node_port_set_io(this->convert, else if ((res = spa_node_port_set_io(this->convert,
@ -167,11 +167,11 @@ static int link_io(struct impl *this)
spa_zero(this->io_buffers); 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, this->direction, 0,
SPA_IO_Buffers, SPA_IO_Buffers,
&this->io_buffers, sizeof(this->io_buffers))) < 0) { &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)); res, spa_strerror(res));
return res; return res;
} }
@ -216,13 +216,13 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
case SPA_PARAM_PortConfig: case SPA_PARAM_PortConfig:
if (this->started) if (this->started)
return -EIO; return -EIO;
if (this->target != this->slave) { if (this->target != this->follower) {
if ((res = spa_node_set_param(this->target, id, flags, param)) < 0) if ((res = spa_node_set_param(this->target, id, flags, param)) < 0)
return res; return res;
} }
break; break;
case SPA_PARAM_Props: 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) if ((res = spa_node_set_param(this->target, id, flags, param)) < 0)
return res; return res;
@ -248,8 +248,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
if (this->target) if (this->target)
res = spa_node_set_io(this->target, id, data, size); res = spa_node_set_io(this->target, id, data, size);
if (this->target != this->slave) if (this->target != this->follower)
res = spa_node_set_io(this->slave, id, data, size); res = spa_node_set_io(this->follower, id, data, size);
return res; return res;
} }
@ -278,9 +278,9 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
return res; return res;
} }
if (this->target != this->slave) { if (this->target != this->follower) {
if ((res = spa_node_send_command(this->slave, command)) < 0) { if ((res = spa_node_send_command(this->follower, command)) < 0) {
spa_log_error(this->log, NAME " %p: can't start slave: %s", spa_log_error(this->log, NAME " %p: can't start follower: %s",
this, spa_strerror(res)); this, spa_strerror(res));
return res; return res;
} }
@ -320,7 +320,7 @@ static const struct spa_node_events target_node_events = {
.result = target_result, .result = target_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; struct impl *this = data;
const char *str; const char *str;
@ -330,7 +330,7 @@ static void slave_info(void *data, const struct spa_node_info *info)
else else
this->direction = SPA_DIRECTION_OUTPUT; this->direction = SPA_DIRECTION_OUTPUT;
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 ? this->direction == SPA_DIRECTION_INPUT ?
"Input" : "Output"); "Input" : "Output");
@ -340,12 +340,12 @@ static void slave_info(void *data, const struct spa_node_info *info)
} }
} }
static const struct spa_node_events slave_node_events = { static const struct spa_node_events follower_node_events = {
SPA_VERSION_NODE_EVENTS, SPA_VERSION_NODE_EVENTS,
.info = slave_info, .info = follower_info,
}; };
static int slave_ready(void *data, int status) static int follower_ready(void *data, int status)
{ {
struct impl *this = data; struct impl *this = data;
@ -357,7 +357,7 @@ static int slave_ready(void *data, int status)
return spa_node_call_ready(&this->callbacks, 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; int res;
struct impl *this = data; struct impl *this = data;
@ -370,10 +370,10 @@ static int slave_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id)
return res; return res;
} }
static const struct spa_node_callbacks slave_node_callbacks = { static const struct spa_node_callbacks follower_node_callbacks = {
SPA_VERSION_NODE_CALLBACKS, SPA_VERSION_NODE_CALLBACKS,
.ready = slave_ready, .ready = follower_ready,
.reuse_buffer = slave_reuse_buffer, .reuse_buffer = follower_reuse_buffer,
}; };
static int impl_node_add_listener(void *object, static int impl_node_add_listener(void *object,
@ -424,7 +424,7 @@ impl_node_sync(void *object, int seq)
spa_return_val_if_fail(this != NULL, -EINVAL); spa_return_val_if_fail(this != NULL, -EINVAL);
return spa_node_sync(this->slave, seq); return spa_node_sync(this->follower, seq);
} }
static int static int
@ -525,12 +525,12 @@ static int negotiate_format(struct impl *this)
state = 0; state = 0;
format = NULL; format = NULL;
if ((res = spa_node_port_enum_params_sync(this->slave, if ((res = spa_node_port_enum_params_sync(this->follower,
this->direction, 0, this->direction, 0,
SPA_PARAM_EnumFormat, &state, SPA_PARAM_EnumFormat, &state,
format, &format, &b)) < 0) { format, &format, &b)) < 0) {
debug_params(this, this->slave, this->direction, 0, debug_params(this, this->follower, this->direction, 0,
SPA_PARAM_EnumFormat, format, "slave format", res); SPA_PARAM_EnumFormat, format, "follower format", res);
return -ENOTSUP; return -ENOTSUP;
} }
@ -555,7 +555,7 @@ static int negotiate_format(struct impl *this)
format)) < 0) format)) < 0)
return res; return res;
if ((res = spa_node_port_set_param(this->slave, if ((res = spa_node_port_set_param(this->follower,
this->direction, 0, this->direction, 0,
SPA_PARAM_Format, 0, SPA_PARAM_Format, 0,
format)) < 0) format)) < 0)
@ -571,11 +571,11 @@ static int negotiate_buffers(struct impl *this)
uint32_t state; uint32_t state;
struct spa_pod *param; struct spa_pod *param;
int res, i; int res, i;
bool slave_alloc, conv_alloc; bool follower_alloc, conv_alloc;
int32_t size, buffers, blocks, align, flags; int32_t size, buffers, blocks, align, flags;
uint32_t *aligns; uint32_t *aligns;
struct spa_data *datas; 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); spa_log_debug(this->log, "%p: %d", this, this->n_buffers);
@ -584,12 +584,12 @@ static int negotiate_buffers(struct impl *this)
state = 0; state = 0;
param = NULL; 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, this->direction, 0,
SPA_PARAM_Buffers, &state, SPA_PARAM_Buffers, &state,
param, &param, &b)) < 0) { param, &param, &b)) < 0) {
debug_params(this, this->slave, this->direction, 0, debug_params(this, this->follower, this->direction, 0,
SPA_PARAM_Buffers, param, "slave buffers", res); SPA_PARAM_Buffers, param, "follower buffers", res);
return -ENOTSUP; return -ENOTSUP;
} }
@ -606,17 +606,17 @@ static int negotiate_buffers(struct impl *this)
spa_pod_fixate(param); spa_pod_fixate(param);
slave_flags = this->slave_flags; follower_flags = this->follower_flags;
conv_flags = this->convert_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); conv_alloc = SPA_FLAG_IS_SET(conv_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS);
flags = 0; flags = 0;
if (conv_alloc || slave_alloc) { if (conv_alloc || follower_alloc) {
flags |= SPA_BUFFER_ALLOC_FLAG_NO_DATA; flags |= SPA_BUFFER_ALLOC_FLAG_NO_DATA;
if (conv_alloc) if (conv_alloc)
slave_alloc = false; follower_alloc = false;
} }
if ((res = spa_pod_parse_object(param, if ((res = spa_pod_parse_object(param,
@ -628,7 +628,7 @@ static int negotiate_buffers(struct impl *this)
return res; return res;
spa_log_debug(this->log, "%p: buffers %d, blocks %d, size %d, align %d %d:%d", 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);
datas = alloca(sizeof(struct spa_data) * blocks); datas = alloca(sizeof(struct spa_data) * blocks);
memset(datas, 0, sizeof(struct spa_data) * blocks); memset(datas, 0, sizeof(struct spa_data) * blocks);
@ -652,9 +652,9 @@ static int negotiate_buffers(struct impl *this)
this->buffers, this->n_buffers)) < 0) this->buffers, this->n_buffers)) < 0)
return res; return res;
if ((res = spa_node_port_use_buffers(this->slave, if ((res = spa_node_port_use_buffers(this->follower,
this->direction, 0, 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) { this->buffers, this->n_buffers)) < 0) {
return res; return res;
} }
@ -770,7 +770,7 @@ static int impl_node_process(void *object)
status = spa_node_process(this->convert); status = spa_node_process(this->convert);
} }
status = spa_node_process(this->slave); status = spa_node_process(this->follower);
if (this->monitor) if (this->monitor)
status |= SPA_STATUS_HAVE_DATA; status |= SPA_STATUS_HAVE_DATA;
@ -826,8 +826,8 @@ static int impl_clear(struct spa_handle *handle)
this = (struct impl *) handle; this = (struct impl *) handle;
spa_hook_remove(&this->slave_listener); spa_hook_remove(&this->follower_listener);
spa_node_set_callbacks(this->slave, NULL, NULL); spa_node_set_callbacks(this->follower, NULL, NULL);
if (this->buffers) if (this->buffers)
free(this->buffers); free(this->buffers);
@ -875,16 +875,16 @@ impl_init(const struct spa_handle_factory *factory,
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log); this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
if (info == NULL || (str = spa_dict_lookup(info, "video.adapt.slave")) == NULL) if (info == NULL || (str = spa_dict_lookup(info, "video.adapt.follower")) == NULL)
return -EINVAL; return -EINVAL;
sscanf(str, "pointer:%p", &this->slave); sscanf(str, "pointer:%p", &this->follower);
if (this->slave == NULL) if (this->follower == NULL)
return -EINVAL; return -EINVAL;
spa_node_add_listener(this->slave, spa_node_add_listener(this->follower,
&this->slave_listener, &slave_node_events, this); &this->follower_listener, &follower_node_events, this);
spa_node_set_callbacks(this->slave, &slave_node_callbacks, this); spa_node_set_callbacks(this->follower, &follower_node_callbacks, this);
this->node.iface = SPA_INTERFACE_INIT( this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node, SPA_TYPE_INTERFACE_Node,
@ -908,7 +908,7 @@ impl_init(const struct spa_handle_factory *factory,
link_io(this); link_io(this);
#else #else
this->target = this->slave; this->target = this->follower;
spa_node_add_listener(this->target, spa_node_add_listener(this->target,
&this->target_listener, &target_node_events, this); &this->target_listener, &target_node_events, this);

View file

@ -64,7 +64,7 @@ struct node_data {
struct factory_data *data; struct factory_data *data;
struct spa_list link; struct spa_list link;
struct pw_impl_node *adapter; struct pw_impl_node *adapter;
struct pw_impl_node *slave; struct pw_impl_node *follower;
struct spa_hook adapter_listener; struct spa_hook adapter_listener;
struct pw_resource *resource; struct pw_resource *resource;
struct spa_hook resource_listener; struct spa_hook resource_listener;
@ -95,7 +95,7 @@ static void node_destroy(void *data)
static void node_free(void *data) static void node_free(void *data)
{ {
struct node_data *nd = data; struct node_data *nd = data;
pw_impl_node_destroy(nd->slave); pw_impl_node_destroy(nd->follower);
} }
static void node_initialized(void *data) static void node_initialized(void *data)
@ -145,7 +145,7 @@ static void *create_object(void *_data,
{ {
struct factory_data *d = _data; struct factory_data *d = _data;
struct pw_impl_client *client; struct pw_impl_client *client;
struct pw_impl_node *adapter, *slave; struct pw_impl_node *adapter, *follower;
const char *str, *factory_name; const char *str, *factory_name;
int res; int res;
struct node_data *nd; struct node_data *nd;
@ -163,30 +163,30 @@ static void *create_object(void *_data,
pw_impl_client_get_info(client)->id); pw_impl_client_get_info(client)->id);
} }
slave = NULL; follower = NULL;
str = pw_properties_get(properties, "adapt.slave.node"); str = pw_properties_get(properties, "adapt.follower.node");
if (str != NULL) { if (str != NULL) {
if (sscanf(str, "pointer:%p", &slave) != 1) if (sscanf(str, "pointer:%p", &follower) != 1)
goto error_properties; goto error_properties;
pw_properties_setf(properties, "audio.adapt.slave", "pointer:%p", slave); pw_properties_setf(properties, "audio.adapt.follower", "pointer:%p", follower);
} }
if (slave == NULL) { if (follower == NULL) {
factory_name = pw_properties_get(properties, SPA_KEY_FACTORY_NAME); factory_name = pw_properties_get(properties, SPA_KEY_FACTORY_NAME);
if (factory_name == NULL) if (factory_name == NULL)
goto error_properties; goto error_properties;
slave = pw_spa_node_load(d->context, follower = pw_spa_node_load(d->context,
factory_name, factory_name,
PW_SPA_NODE_FLAG_ACTIVATE | PW_SPA_NODE_FLAG_ACTIVATE |
PW_SPA_NODE_FLAG_NO_REGISTER, PW_SPA_NODE_FLAG_NO_REGISTER,
pw_properties_copy(properties), 0); pw_properties_copy(properties), 0);
if (slave == NULL) if (follower == NULL)
goto error_no_mem; goto error_no_mem;
} }
adapter = pw_adapter_new(pw_impl_module_get_context(d->module), adapter = pw_adapter_new(pw_impl_module_get_context(d->module),
slave, follower,
properties, properties,
sizeof(struct node_data)); sizeof(struct node_data));
properties = NULL; properties = NULL;
@ -201,7 +201,7 @@ static void *create_object(void *_data,
nd = pw_adapter_get_user_data(adapter); nd = pw_adapter_get_user_data(adapter);
nd->data = d; nd->data = d;
nd->adapter = adapter; nd->adapter = adapter;
nd->slave = slave; nd->follower = follower;
nd->resource = resource; nd->resource = resource;
nd->new_id = new_id; nd->new_id = new_id;
spa_list_append(&d->node_list, &nd->link); spa_list_append(&d->node_list, &nd->link);

View file

@ -60,7 +60,7 @@ struct node {
struct pw_impl_node *node; struct pw_impl_node *node;
struct spa_hook node_listener; struct spa_hook node_listener;
struct pw_impl_node *slave; struct pw_impl_node *follower;
void *user_data; void *user_data;
enum pw_direction direction; enum pw_direction direction;
@ -186,7 +186,7 @@ static int find_format(struct pw_impl_node *node, enum pw_direction direction,
struct pw_impl_node *pw_adapter_new(struct pw_context *context, struct pw_impl_node *pw_adapter_new(struct pw_context *context,
struct pw_impl_node *slave, struct pw_impl_node *follower,
struct pw_properties *props, struct pw_properties *props,
size_t user_data_size) size_t user_data_size)
{ {
@ -198,13 +198,13 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
int res; int res;
uint32_t media_type, media_subtype; uint32_t media_type, media_subtype;
info = pw_impl_node_get_info(slave); info = pw_impl_node_get_info(follower);
if (info == NULL) { if (info == NULL) {
res = -EINVAL; res = -EINVAL;
goto error; goto error;
} }
pw_log_debug(NAME " %p: in %d/%d out %d/%d", slave, pw_log_debug(NAME " %p: in %d/%d out %d/%d", follower,
info->n_input_ports, info->max_input_ports, info->n_input_ports, info->max_input_ports,
info->n_output_ports, info->max_output_ports); info->n_output_ports, info->max_output_ports);
@ -231,12 +231,12 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
pw_properties_set(props, "factory.mode", str); pw_properties_set(props, "factory.mode", str);
} }
if ((res = find_format(slave, direction, &media_type, &media_subtype)) < 0) if ((res = find_format(follower, direction, &media_type, &media_subtype)) < 0)
goto error; goto error;
if (media_type == SPA_MEDIA_TYPE_audio) { if (media_type == SPA_MEDIA_TYPE_audio) {
pw_properties_setf(props, "audio.adapt.slave", "pointer:%p", pw_properties_setf(props, "audio.adapt.follower", "pointer:%p",
pw_impl_node_get_implementation(slave)); pw_impl_node_get_implementation(follower));
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert"); pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert");
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL) if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL)
pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Audio/%s", pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Audio/%s",
@ -244,8 +244,8 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
factory_name = SPA_NAME_AUDIO_ADAPT; factory_name = SPA_NAME_AUDIO_ADAPT;
} }
else if (media_type == SPA_MEDIA_TYPE_video) { else if (media_type == SPA_MEDIA_TYPE_video) {
pw_properties_setf(props, "video.adapt.slave", "pointer:%p", pw_properties_setf(props, "video.adapt.follower", "pointer:%p",
pw_impl_node_get_implementation(slave)); pw_impl_node_get_implementation(follower));
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "videoconvert/libspa-videoconvert"); pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "videoconvert/libspa-videoconvert");
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL) if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL)
pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Video/%s", pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Video/%s",
@ -270,7 +270,7 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
n = pw_spa_node_get_user_data(node); n = pw_spa_node_get_user_data(node);
n->context = context; n->context = context;
n->node = node; n->node = node;
n->slave = slave; n->follower = follower;
n->direction = direction; n->direction = direction;
n->props = props; n->props = props;
n->media_type = media_type; n->media_type = media_type;

View file

@ -35,7 +35,7 @@ extern "C" {
struct pw_impl_node * struct pw_impl_node *
pw_adapter_new(struct pw_context *context, pw_adapter_new(struct pw_context *context,
struct pw_impl_node *slave, struct pw_impl_node *follower,
struct pw_properties *properties, struct pw_properties *properties,
size_t user_data_size); size_t user_data_size);

View file

@ -729,12 +729,12 @@ static int collect_nodes(struct pw_impl_node *driver)
uint32_t min_quantum = 0; uint32_t min_quantum = 0;
uint32_t quantum; uint32_t quantum;
spa_list_consume(t, &driver->slave_list, slave_link) { spa_list_consume(t, &driver->follower_list, follower_link) {
spa_list_remove(&t->slave_link); spa_list_remove(&t->follower_link);
spa_list_init(&t->slave_link); spa_list_init(&t->follower_link);
} }
pw_log_info("driver %p: '%s'", driver, driver->name); pw_log_debug("driver %p: '%s'", driver, driver->name);
spa_list_init(&queue); spa_list_init(&queue);
spa_list_append(&queue, &driver->sort_link); spa_list_append(&queue, &driver->sort_link);
@ -791,34 +791,34 @@ int pw_context_recalc_graph(struct pw_context *context)
/* start from all drivers and group all nodes that are linked /* start from all drivers and group all nodes that are linked
* to it. Some nodes are not (yet) linked to anything and they * to it. Some nodes are not (yet) linked to anything and they
* will end up 'unassigned' to a master. Other nodes are master * will end up 'unassigned' to a master. Other nodes are master
* and if they have active slaves, we can use them to schedule * and if they have active followers, we can use them to schedule
* the unassigned nodes. */ * the unassigned nodes. */
target = NULL; target = NULL;
spa_list_for_each(n, &context->driver_list, driver_link) { spa_list_for_each(n, &context->driver_list, driver_link) {
uint32_t active_slaves; uint32_t active_followers;
if (n->active && !n->visited) if (n->active && !n->visited)
collect_nodes(n); collect_nodes(n);
/* from now on we are only interested in nodes that are /* from now on we are only interested in nodes that are
* a master. We're going to count the number of slaves it * a master. We're going to count the number of followers it
* has. */ * has. */
if (!n->master) if (!n->master)
continue; continue;
active_slaves = 0; active_followers = 0;
spa_list_for_each(s, &n->slave_list, slave_link) { spa_list_for_each(s, &n->follower_list, follower_link) {
pw_log_info(NAME" %p: driver %p: slave %p %s: %d", pw_log_debug(NAME" %p: driver %p: follower %p %s: %d",
context, n, s, s->name, s->active); context, n, s, s->name, s->active);
if (s != n && s->active) if (s != n && s->active)
active_slaves++; active_followers++;
} }
pw_log_info(NAME" %p: driver %p active slaves %d", pw_log_debug(NAME" %p: driver %p active followers %d",
context, n, active_slaves); context, n, active_followers);
/* if the master has active slaves, it is a target for our /* if the master has active followers, it is a target for our
* unassigned nodes */ * unassigned nodes */
if (active_slaves > 0) { if (active_followers > 0) {
if (target == NULL) if (target == NULL)
target = n; target = n;
} }
@ -830,7 +830,7 @@ int pw_context_recalc_graph(struct pw_context *context)
spa_list_for_each(n, &context->node_list, link) { spa_list_for_each(n, &context->node_list, link) {
if (!n->visited) { if (!n->visited) {
pw_log_info(NAME" %p: unassigned node %p: '%s' %d %d", context, pw_log_debug(NAME" %p: unassigned node %p: '%s' %d %d", context,
n, n->name, n->active, n->want_driver); n, n->name, n->active, n->want_driver);
if (!n->want_driver) if (!n->want_driver)
@ -848,7 +848,7 @@ int pw_context_recalc_graph(struct pw_context *context)
n->visited = false; n->visited = false;
} }
/* assign final quantum and debug masters and slaves */ /* assign final quantum and debug masters and followers */
spa_list_for_each(n, &context->driver_list, driver_link) { spa_list_for_each(n, &context->driver_list, driver_link) {
if (!n->master) if (!n->master)
continue; continue;
@ -859,8 +859,8 @@ int pw_context_recalc_graph(struct pw_context *context)
pw_log_info(NAME" %p: master %p quantum:%u '%s'", context, n, pw_log_info(NAME" %p: master %p quantum:%u '%s'", context, n,
n->quantum_current, n->name); n->quantum_current, n->name);
spa_list_for_each(s, &n->slave_list, slave_link) spa_list_for_each(s, &n->follower_list, follower_link)
pw_log_info(NAME" %p: slave %p: active:%d '%s'", pw_log_info(NAME" %p: follower %p: active:%d '%s'",
context, s, s->active, s->name); context, s, s->active, s->name);
} }
return 0; return 0;

View file

@ -657,8 +657,8 @@ int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driv
if (driver == NULL) if (driver == NULL)
driver = node; driver = node;
spa_list_remove(&node->slave_link); spa_list_remove(&node->follower_link);
spa_list_append(&driver->slave_list, &node->slave_link); spa_list_append(&driver->follower_list, &node->follower_link);
if (old == driver) if (old == driver)
return 0; return 0;
@ -992,7 +992,7 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context,
this->data_loop = context->data_loop; this->data_loop = context->data_loop;
spa_list_init(&this->slave_list); spa_list_init(&this->follower_list);
spa_hook_list_init(&this->listener_list); spa_hook_list_init(&this->listener_list);
@ -1023,7 +1023,7 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context,
check_properties(this); check_properties(this);
this->driver_node = this; this->driver_node = this;
spa_list_append(&this->slave_list, &this->slave_link); spa_list_append(&this->follower_list, &this->follower_link);
this->master = true; this->master = true;
return this; return this;
@ -1480,7 +1480,7 @@ void pw_impl_node_destroy(struct pw_impl_node *node)
{ {
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this); struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
struct pw_impl_port *port; struct pw_impl_port *port;
struct pw_impl_node *slave; struct pw_impl_node *follower;
node->active = false; node->active = false;
@ -1491,13 +1491,13 @@ void pw_impl_node_destroy(struct pw_impl_node *node)
pw_log_debug(NAME" %p: driver node %p", impl, node->driver_node); pw_log_debug(NAME" %p: driver node %p", impl, node->driver_node);
/* remove ourself as a slave from the driver node */ /* remove ourself as a follower from the driver node */
spa_list_remove(&node->slave_link); spa_list_remove(&node->follower_link);
remove_segment_master(node->driver_node, node->info.id); remove_segment_master(node->driver_node, node->info.id);
spa_list_consume(slave, &node->slave_list, slave_link) { spa_list_consume(follower, &node->follower_list, follower_link) {
pw_log_debug(NAME" %p: reslave %p", impl, slave); pw_log_debug(NAME" %p: reassign follower %p", impl, follower);
pw_impl_node_set_driver(slave, NULL); pw_impl_node_set_driver(follower, NULL);
} }
if (node->registered) { if (node->registered) {

View file

@ -524,8 +524,8 @@ struct pw_impl_node {
struct spa_list driver_link; struct spa_list driver_link;
struct pw_impl_node *driver_node; struct pw_impl_node *driver_node;
struct spa_list slave_list; struct spa_list follower_list;
struct spa_list slave_link; struct spa_list follower_link;
struct spa_list sort_link; /**< link used to sort nodes */ struct spa_list sort_link; /**< link used to sort nodes */

View file

@ -1349,7 +1349,7 @@ pw_stream_connect(struct pw_stream *stream,
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
struct pw_impl_factory *factory; struct pw_impl_factory *factory;
struct pw_properties *props; struct pw_properties *props;
struct pw_impl_node *slave; struct pw_impl_node *follower;
const char *str; const char *str;
uint32_t i; uint32_t i;
int res; int res;
@ -1446,13 +1446,13 @@ pw_stream_connect(struct pw_stream *stream,
pw_properties_set(props, "resample.peaks", "1"); pw_properties_set(props, "resample.peaks", "1");
} }
slave = pw_context_create_node(impl->context, pw_properties_copy(props), 0); follower = pw_context_create_node(impl->context, pw_properties_copy(props), 0);
if (slave == NULL) { if (follower == NULL) {
res = -errno; res = -errno;
goto error_node; goto error_node;
} }
pw_impl_node_set_implementation(slave, &impl->impl_node); pw_impl_node_set_implementation(follower, &impl->impl_node);
if (impl->media_type == SPA_MEDIA_TYPE_audio && if (impl->media_type == SPA_MEDIA_TYPE_audio &&
impl->media_subtype == SPA_MEDIA_SUBTYPE_raw) { impl->media_subtype == SPA_MEDIA_SUBTYPE_raw) {
@ -1462,7 +1462,7 @@ pw_stream_connect(struct pw_stream *stream,
res = -ENOENT; res = -ENOENT;
goto error_node; goto error_node;
} }
pw_properties_setf(props, "adapt.slave.node", "pointer:%p", slave); pw_properties_setf(props, "adapt.follower.node", "pointer:%p", follower);
impl->node = pw_impl_factory_create_object(factory, impl->node = pw_impl_factory_create_object(factory,
NULL, NULL,
PW_TYPE_INTERFACE_Node, PW_TYPE_INTERFACE_Node,
@ -1474,7 +1474,7 @@ pw_stream_connect(struct pw_stream *stream,
goto error_node; goto error_node;
} }
} else { } else {
impl->node = slave; impl->node = follower;
} }
if (!SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_INACTIVE)) if (!SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_INACTIVE))
pw_impl_node_set_active(impl->node, true); pw_impl_node_set_active(impl->node, true);