From a528189d26a4e9f41305e190e2b1aa7c692117f7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 21 Feb 2020 10:47:32 +0100 Subject: [PATCH] slave -> follower We use master/follower terminology everywhere. --- spa/examples/adapter-control.c | 40 +++---- spa/plugins/alsa/alsa-pcm-sink.c | 2 +- spa/plugins/alsa/alsa-pcm-source.c | 6 +- spa/plugins/alsa/alsa-pcm.c | 56 ++++----- spa/plugins/alsa/alsa-pcm.h | 4 +- spa/plugins/alsa/alsa-seq-source.c | 2 +- spa/plugins/alsa/alsa-seq.c | 34 +++--- spa/plugins/alsa/alsa-seq.h | 4 +- spa/plugins/audioconvert/audioadapter.c | 117 ++++++++++--------- spa/plugins/audioconvert/test-audioadapter.c | 24 ++-- spa/plugins/bluez5/a2dp-sink.c | 26 ++--- spa/plugins/bluez5/a2dp-source.c | 18 +-- spa/plugins/bluez5/sco-sink.c | 28 ++--- spa/plugins/bluez5/sco-source.c | 18 +-- spa/plugins/videoconvert/videoadapter.c | 102 ++++++++-------- src/modules/module-adapter.c | 24 ++-- src/modules/module-adapter/adapter.c | 20 ++-- src/modules/module-adapter/adapter.h | 2 +- src/pipewire/context.c | 38 +++--- src/pipewire/impl-node.c | 20 ++-- src/pipewire/private.h | 4 +- src/pipewire/stream.c | 12 +- 22 files changed, 301 insertions(+), 300 deletions(-) diff --git a/spa/examples/adapter-control.c b/spa/examples/adapter-control.c index 661bc46f1..7cf652d86 100644 --- a/spa/examples/adapter-control.c +++ b/spa/examples/adapter-control.c @@ -75,9 +75,9 @@ struct data { struct spa_graph_port graph_source_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 *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_io_buffers source_sink_io[1]; @@ -264,11 +264,11 @@ static int make_nodes(struct data *data, const char *device) struct spa_pod *param; /* 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", "audiotestsrc", 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; } @@ -279,16 +279,16 @@ static int make_nodes(struct data *data, const char *device) .format = SPA_AUDIO_FORMAT_S16, .rate = 48000, .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_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; } /* make the sink adapter node */ - snprintf(value, sizeof(value), "pointer:%p", data->source_slave_node); - items[0] = SPA_DICT_ITEM_INIT("audio.adapt.slave", value); + snprintf(value, sizeof(value), "pointer:%p", data->source_follower_node); + items[0] = SPA_DICT_ITEM_INIT("audio.adapt.follower", value); if ((res = make_node(data, &data->source_node, "build/spa/plugins/audioconvert/libspa-audioconvert.so", 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_live, SPA_POD_Bool(false)); 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; } @@ -327,18 +327,18 @@ static int make_nodes(struct data *data, const char *device) return res; } - /* make the sink slave node (alsa-pcm-sink) */ - if ((res = make_node(data, &data->sink_slave_node, + /* make the sink follower node (alsa-pcm-sink) */ + if ((res = make_node(data, &data->sink_follower_node, "build/spa/plugins/alsa/libspa-alsa.so", SPA_NAME_API_ALSA_PCM_SINK, 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; } /* make the sink adapter node */ - snprintf(value, sizeof(value), "pointer:%p", data->sink_slave_node); - items[0] = SPA_DICT_ITEM_INIT("audio.adapt.slave", value); + snprintf(value, sizeof(value), "pointer:%p", data->sink_follower_node); + items[0] = SPA_DICT_ITEM_INIT("audio.adapt.follower", value); if ((res = make_node(data, &data->sink_node, "build/spa/plugins/audioconvert/libspa-audioconvert.so", SPA_NAME_AUDIO_ADAPT, @@ -347,7 +347,7 @@ static int make_nodes(struct data *data, const char *device) return res; } - /* add sink slave node callbacks */ + /* add sink follower node callbacks */ spa_node_set_callbacks(data->sink_node, &sink_node_callbacks, data); /* 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_PROP_device, SPA_POD_String(device ? device : "hw:0"), SPA_PROP_minLatency, SPA_POD_Int(MIN_LATENCY)); - if ((res = spa_node_set_param(data->sink_slave_node, SPA_PARAM_Props, 0, props)) < 0) { - printf("can't setup sink slave node %d\n", res); + if ((res = spa_node_set_param(data->sink_follower_node, SPA_PARAM_Props, 0, props)) < 0) { + printf("can't setup sink follower node %d\n", res); return res; } @@ -461,9 +461,9 @@ static int negotiate_formats(struct data *data) uint32_t state = 0; 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)); - 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_PARAM_Buffers, &state, filter, ¶m, &b) != 1) return res; @@ -561,7 +561,7 @@ int main(int argc, char *argv[]) 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) { printf("can't make nodes: %d (%s)\n", res, spa_strerror(res)); return -1; diff --git a/spa/plugins/alsa/alsa-pcm-sink.c b/spa/plugins/alsa/alsa-pcm-sink.c index c468b9431..c5079dfe6 100644 --- a/spa/plugins/alsa/alsa-pcm-sink.c +++ b/spa/plugins/alsa/alsa-pcm-sink.c @@ -189,7 +189,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) default: return -ENOENT; } - spa_alsa_reslave(this); + spa_alsa_reassign_follower(this); return 0; } diff --git a/spa/plugins/alsa/alsa-pcm-source.c b/spa/plugins/alsa/alsa-pcm-source.c index 1cdf4cd94..46cce4efe 100644 --- a/spa/plugins/alsa/alsa-pcm-source.c +++ b/spa/plugins/alsa/alsa-pcm-source.c @@ -188,7 +188,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) default: return -ENOENT; } - spa_alsa_reslave(this); + spa_alsa_reassign_follower(this); return 0; } @@ -647,10 +647,10 @@ static int impl_node_process(void *object) 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); - if (spa_list_is_empty(&this->ready) || !this->slaved) + if (spa_list_is_empty(&this->ready) || !this->following) return SPA_STATUS_OK; b = spa_list_first(&this->ready, struct buffer, link); diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index c392f5cba..a0a831656 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -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, - snd_pcm_sframes_t target, bool slave) + snd_pcm_sframes_t target, bool follower) { 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) { int32_t diff = (int32_t) (state->last_threshold - state->threshold); - spa_log_trace(state->log, NAME" %p: slave:%d quantum change %d", - state, slave, diff); + spa_log_trace(state->log, NAME" %p: follower:%d quantum change %d", + state, follower, diff); state->next_time += diff / corr * 1e9 / state->rate; 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) 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)", - state, slave, state->matching, corr, state->bw, state->delay, target, + 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, follower, state->matching, corr, state->bw, state->delay, target, 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; - if (!slave && state->clock) { + if (!follower && state->clock) { state->clock->nsec = nsec; state->clock->position += 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; } - spa_log_trace_fp(state->log, NAME" %p: slave:%d %"PRIu64" %f %ld %f %f %d", - state, slave, nsec, corr, delay, err, state->threshold * corr, + spa_log_trace_fp(state->log, NAME" %p: follower:%d %"PRIu64" %f %ld %f %f %d", + state, follower, nsec, corr, delay, err, state->threshold * corr, state->threshold); 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; } - if (state->slaved && state->alsa_started) { + if (state->following && state->alsa_started) { uint64_t nsec; snd_pcm_uframes_t delay, target; @@ -734,7 +734,7 @@ int spa_alsa_write(struct state *state, snd_pcm_uframes_t silence) return res; 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); init_loop(state); 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->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom; } - if (!state->slaved) { + if (!state->following) { uint64_t 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; snd_pcm_uframes_t delay, target; uint32_t threshold = state->threshold; @@ -950,13 +950,13 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence) return res; 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); init_loop(state); state->alsa_sync = true; } 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); if (delay < target) 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); state->next_time = SPA_TIMESPEC_TO_NSEC(&now); - if (state->slaved) { + if (state->following) { set_timeout(state, 0); } else { set_timeout(state, state->next_time); @@ -1139,7 +1139,7 @@ static int set_timers(struct state *state) 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; } @@ -1151,8 +1151,8 @@ int spa_alsa_start(struct state *state) if (state->started) return 0; - state->slaved = is_slaved(state); - state->matching = state->slaved; + state->following = is_following(state); + state->matching = state->following; if (state->position) { int card; @@ -1175,9 +1175,9 @@ int spa_alsa_start(struct state *state) init_loop(state); 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->slaved, state->matching); + state->following, state->matching); CHECK(set_swparams(state), "swparams"); 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; } -static int do_reslave(struct spa_loop *loop, +static int do_reassign_follower(struct spa_loop *loop, bool async, uint32_t seq, const void *data, @@ -1231,18 +1231,18 @@ static int do_reslave(struct spa_loop *loop, return 0; } -int spa_alsa_reslave(struct state *state) +int spa_alsa_reassign_follower(struct state *state) { - bool slaved; + bool following; if (!state->started) return 0; - slaved = is_slaved(state); - if (slaved != state->slaved) { - spa_log_debug(state->log, NAME" %p: reslave %d->%d", state, state->slaved, slaved); - state->slaved = slaved; - spa_loop_invoke(state->data_loop, do_reslave, 0, NULL, 0, true, state); + following = is_following(state); + if (following != state->following) { + spa_log_debug(state->log, NAME" %p: reassign follower %d->%d", state, state->following, following); + state->following = following; + spa_loop_invoke(state->data_loop, do_reassign_follower, 0, NULL, 0, true, state); } return 0; } diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h index b7a2dd294..733b0b0b9 100644 --- a/spa/plugins/alsa/alsa-pcm.h +++ b/spa/plugins/alsa/alsa-pcm.h @@ -139,7 +139,7 @@ struct state { unsigned int alsa_started:1; unsigned int alsa_sync:1; unsigned int alsa_recovering:1; - unsigned int slaved:1; + unsigned int following:1; unsigned int matching:1; 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_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_close(struct state *state); diff --git a/spa/plugins/alsa/alsa-seq-source.c b/spa/plugins/alsa/alsa-seq-source.c index f59ce2c34..36da7d704 100644 --- a/spa/plugins/alsa/alsa-seq-source.c +++ b/spa/plugins/alsa/alsa-seq-source.c @@ -149,7 +149,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) default: return -ENOENT; } - spa_alsa_seq_reslave(this); + spa_alsa_seq_reassign_follower(this); return 0; } diff --git a/spa/plugins/alsa/alsa-seq.c b/spa/plugins/alsa/alsa-seq.c index 4f553d6fe..8ec987aee 100644 --- a/spa/plugins/alsa/alsa-seq.c +++ b/spa/plugins/alsa/alsa-seq.c @@ -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)) -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; 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) set_loop(state, BW_MIN); - spa_log_debug(state->log, NAME" %p: slave:%d rate:%f bw:%f err:%f (%f %f %f)", - state, slave, corr, state->bw, err, state->z1, state->z2, state->z3); + spa_log_debug(state->log, NAME" %p: follower:%d rate:%f bw:%f err:%f (%f %f %f)", + state, follower, corr, state->bw, err, state->z1, state->z2, state->z3); } state->next_time += state->threshold / corr * 1e9 / state->rate.denom; - if (!slave && state->clock) { + if (!follower && state->clock) { state->clock->nsec = nsec; state->clock->position += state->duration; state->clock->duration = state->duration; @@ -726,7 +726,7 @@ int spa_alsa_seq_process(struct seq_state *state) res = process_recycle(state); - if (state->slaved) { + if (state->following) { update_time(state, state->position->clock.nsec, true); 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); state->next_time = SPA_TIMESPEC_TO_NSEC(&now); - if (state->slaved) { + if (state->following) { set_timeout(state, 0); } else { set_timeout(state, state->next_time); @@ -799,7 +799,7 @@ static int set_timers(struct seq_state *state) 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; } @@ -811,9 +811,9 @@ int spa_alsa_seq_start(struct seq_state *state) if (state->started) 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) return res; @@ -844,7 +844,7 @@ int spa_alsa_seq_start(struct seq_state *state) return 0; } -static int do_reslave(struct spa_loop *loop, +static int do_reassign_follower(struct spa_loop *loop, bool async, uint32_t seq, const void *data, @@ -856,18 +856,18 @@ static int do_reslave(struct spa_loop *loop, 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) return 0; - slaved = is_slaved(state); - if (slaved != state->slaved) { - spa_log_debug(state->log, "alsa %p: reslave %d->%d", state, state->slaved, slaved); - state->slaved = slaved; - spa_loop_invoke(state->data_loop, do_reslave, 0, NULL, 0, true, state); + following = is_following(state); + if (following != state->following) { + spa_log_debug(state->log, "alsa %p: reassign follower %d->%d", state, state->following, following); + state->following = following; + spa_loop_invoke(state->data_loop, do_reassign_follower, 0, NULL, 0, true, state); } return 0; } diff --git a/spa/plugins/alsa/alsa-seq.h b/spa/plugins/alsa/alsa-seq.h index 903b15b47..eb8d3d000 100644 --- a/spa/plugins/alsa/alsa-seq.h +++ b/spa/plugins/alsa/alsa-seq.h @@ -149,7 +149,7 @@ struct seq_state { unsigned int opened:1; unsigned int started:1; - unsigned int slaved:1; + unsigned int following:1; 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_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); diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index ebdfb8f4e..64f436446 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -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, ¶m, &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, ¶m, &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); diff --git a/spa/plugins/audioconvert/test-audioadapter.c b/spa/plugins/audioconvert/test-audioadapter.c index 4c09b941b..00b021a1f 100644 --- a/spa/plugins/audioconvert/test-audioadapter.c +++ b/spa/plugins/audioconvert/test-audioadapter.c @@ -43,8 +43,8 @@ SPA_LOG_IMPL(logger); extern const struct spa_handle_factory test_source_factory; struct context { - struct spa_handle *slave_handle; - struct spa_node *slave_node; + struct spa_handle *follower_handle; + struct spa_node *follower_node; struct spa_handle *adapter_handle; struct spa_node *adapter_node; @@ -75,22 +75,22 @@ static int setup_context(struct context *ctx) logger.log.level = SPA_LOG_LEVEL_TRACE; support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, &logger.log); - /* make slave */ + /* make follower */ factory = &test_source_factory; size = spa_handle_factory_get_size(factory, NULL); - ctx->slave_handle = calloc(1, size); - spa_assert(ctx->slave_handle != NULL); + ctx->follower_handle = calloc(1, size); + spa_assert(ctx->follower_handle != NULL); res = spa_handle_factory_init(factory, - ctx->slave_handle, + ctx->follower_handle, NULL, support, 1); 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_assert(res >= 0); - ctx->slave_node = iface; + ctx->follower_node = iface; /* make adapter */ factory = find_factory(SPA_NAME_AUDIO_ADAPT); @@ -101,8 +101,8 @@ static int setup_context(struct context *ctx) ctx->adapter_handle = calloc(1, size); spa_assert(ctx->adapter_handle != NULL); - snprintf(value, sizeof(value), "pointer:%p", ctx->slave_node); - items[0] = SPA_DICT_ITEM_INIT("audio.adapt.slave", value); + snprintf(value, sizeof(value), "pointer:%p", ctx->follower_node); + items[0] = SPA_DICT_ITEM_INIT("audio.adapt.follower", value); res = spa_handle_factory_init(factory, ctx->adapter_handle, @@ -121,9 +121,9 @@ static int setup_context(struct context *ctx) static int clean_context(struct context *ctx) { spa_handle_clear(ctx->adapter_handle); - spa_handle_clear(ctx->slave_handle); + spa_handle_clear(ctx->follower_handle); free(ctx->adapter_handle); - free(ctx->slave_handle); + free(ctx->follower_handle); return 0; } diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 3a414a9a1..882b58e0b 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -112,7 +112,7 @@ struct impl { struct port port; unsigned int started:1; - unsigned int slaved:1; + unsigned int following:1; struct spa_source source; int timerfd; @@ -246,7 +246,7 @@ static int set_timers(struct impl *this) int res; ts.it_value.tv_sec = 0; - if (this->slaved) { + if (this->following) { ts.it_value.tv_nsec = 0; } else { ts.it_value.tv_nsec = 1; @@ -260,7 +260,7 @@ static int set_timers(struct impl *this) return res; } -static int do_reslave(struct spa_loop *loop, +static int do_reassign_follower(struct spa_loop *loop, bool async, uint32_t seq, const void *data, @@ -272,7 +272,7 @@ static int do_reslave(struct spa_loop *loop, 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; } @@ -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) { struct impl *this = object; - bool slaved; + bool following; 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; } - slaved = is_slaved(this); - if (this->started && slaved != this->slaved) { - spa_log_debug(this->log, NAME " %p: reslave %d->%d", this, this->slaved, slaved); - this->slaved = slaved; - spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); + following = is_following(this); + if (this->started && following != this->following) { + spa_log_debug(this->log, NAME " %p: reassign follower %d->%d", this, this->following, following); + this->following = following; + spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this); } 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, now_time, queued, this->sample_time, elapsed, this->write_samples); - if (!this->slaved) { + if (!this->following) { if (queued < FILL_FRAMES * this->write_samples) { queued = (FILL_FRAMES + 1) * this->write_samples; if (this->sample_time < elapsed) { @@ -797,9 +797,9 @@ static int do_start(struct impl *this) if (this->started) 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) return res; diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index a22de1127..e4d312f88 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -113,7 +113,7 @@ struct impl { struct port port; unsigned int started:1; - unsigned int slaved:1; + unsigned int following:1; struct spa_source source; @@ -216,7 +216,7 @@ static int impl_node_enum_params(void *object, int seq, return 0; } -static int do_reslave(struct spa_loop *loop, +static int do_reassing_follower(struct spa_loop *loop, bool async, uint32_t seq, const void *data, @@ -226,7 +226,7 @@ static int do_reslave(struct spa_loop *loop, 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; } @@ -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) { struct impl *this = object; - bool slaved; + bool following; 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; } - slaved = is_slaved(this); - if (this->started && slaved != this->slaved) { - spa_log_debug(this->log, NAME" %p: reslave %d->%d", this, this->slaved, slaved); - this->slaved = slaved; - spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); + following = is_following(this); + if (this->started && following != this->following) { + spa_log_debug(this->log, NAME" %p: reassign follower %d->%d", this, this->following, following); + this->following = following; + spa_loop_invoke(this->data_loop, do_reassing_follower, 0, NULL, 0, true, this); } return 0; } diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index 378298f88..ffb0cc732 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -112,7 +112,7 @@ struct impl { /* Flags */ unsigned int started:1; - unsigned int slaved:1; + unsigned int following:1; /* Sources */ 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) { - 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; - /* Set the next timeout if not slaved, otherwise reset values */ - if (!this->slaved) { + /* Set the next timeout if not following, otherwise reset values */ + if (!this->following) { /* Get the elapsed time */ uint64_t elapsed_time = 0; 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, uint32_t seq, const void *data, @@ -283,7 +283,7 @@ static int do_reslave(struct spa_loop *loop, 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; } @@ -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) { struct impl *this = object; - bool slaved; + bool following; 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; } - slaved = is_slaved(this); - if (this->started && slaved != this->slaved) { - spa_log_debug(this->log, "sco-sink %p: reslave %d->%d", this, this->slaved, slaved); - this->slaved = slaved; - spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); + following = is_following(this); + if (this->started && following != this->following) { + spa_log_debug(this->log, "sco-sink %p: reassign follower %d->%d", this, this->following, following); + this->following = following; + spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this); } return 0; } @@ -505,8 +505,8 @@ static int do_start(struct impl *this) /* Make sure the transport is valid */ spa_return_val_if_fail (this->transport != NULL, -EIO); - /* Set the slaved flag */ - this->slaved = is_slaved(this); + /* Set the following flag */ + this->following = is_following(this); /* Do accept if Gateway; otherwise do connect for Head Unit */ do_accept = this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY; diff --git a/spa/plugins/bluez5/sco-source.c b/spa/plugins/bluez5/sco-source.c index c7492f924..065a27e44 100644 --- a/spa/plugins/bluez5/sco-source.c +++ b/spa/plugins/bluez5/sco-source.c @@ -108,7 +108,7 @@ struct impl { struct port port; unsigned int started:1; - unsigned int slaved:1; + unsigned int following:1; struct spa_source source; @@ -209,7 +209,7 @@ static int impl_node_enum_params(void *object, int seq, return 0; } -static int do_reslave(struct spa_loop *loop, +static int do_reassign_follower(struct spa_loop *loop, bool async, uint32_t seq, const void *data, @@ -219,7 +219,7 @@ static int do_reslave(struct spa_loop *loop, 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; } @@ -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) { struct impl *this = object; - bool slaved; + bool following; 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; } - slaved = is_slaved(this); - if (this->started && slaved != this->slaved) { - spa_log_debug(this->log, "sco-source %p: reslave %d->%d", this, this->slaved, slaved); - this->slaved = slaved; - spa_loop_invoke(this->data_loop, do_reslave, 0, NULL, 0, true, this); + following = is_following(this); + if (this->started && following != this->following) { + spa_log_debug(this->log, "sco-source %p: reassign follower %d->%d", this, this->following, following); + this->following = following; + spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this); } return 0; } diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c index 57ae3d8d3..b262d2349 100644 --- a/spa/plugins/videoconvert/videoadapter.c +++ b/spa/plugins/videoconvert/videoadapter.c @@ -52,9 +52,9 @@ struct impl { struct spa_node *target; struct spa_hook target_listener; - struct spa_node *slave; - struct spa_hook slave_listener; - uint32_t slave_flags; + struct spa_node *follower; + struct spa_hook follower_listener; + uint32_t follower_flags; struct spa_handle *hnd_convert; struct spa_node *convert; @@ -116,7 +116,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, &start, filter, ¶m, &b)) != 1) return res; @@ -150,11 +150,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_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)); } 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); - 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; } @@ -216,13 +216,13 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags, 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; @@ -248,8 +248,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; } @@ -278,9 +278,9 @@ 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) { - spa_log_error(this->log, NAME " %p: can't start slave: %s", + if (this->target != this->follower) { + if ((res = spa_node_send_command(this->follower, command)) < 0) { + spa_log_error(this->log, NAME " %p: can't start follower: %s", this, spa_strerror(res)); return res; } @@ -320,7 +320,7 @@ static const struct spa_node_events target_node_events = { .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; const char *str; @@ -330,7 +330,7 @@ static void slave_info(void *data, const struct spa_node_info *info) else 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 ? "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, - .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; @@ -357,7 +357,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; @@ -370,10 +370,10 @@ static int slave_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id) return res; } -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, + .ready = follower_ready, + .reuse_buffer = follower_reuse_buffer, }; 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); - return spa_node_sync(this->slave, seq); + return spa_node_sync(this->follower, seq); } static int @@ -525,12 +525,12 @@ static int negotiate_format(struct impl *this) state = 0; 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, 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; } @@ -555,7 +555,7 @@ static int negotiate_format(struct impl *this) format)) < 0) 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, 0, format)) < 0) @@ -571,11 +571,11 @@ static int negotiate_buffers(struct impl *this) uint32_t state; struct spa_pod *param; int res, i; - bool slave_alloc, conv_alloc; + bool follower_alloc, conv_alloc; int32_t 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); @@ -584,12 +584,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, ¶m, &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; } @@ -606,17 +606,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, @@ -628,7 +628,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); datas = alloca(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) 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; } @@ -770,7 +770,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->monitor) status |= SPA_STATUS_HAVE_DATA; @@ -826,8 +826,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); @@ -875,16 +875,16 @@ impl_init(const struct spa_handle_factory *factory, 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; - sscanf(str, "pointer:%p", &this->slave); - if (this->slave == NULL) + sscanf(str, "pointer:%p", &this->follower); + if (this->follower == NULL) return -EINVAL; - 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); this->node.iface = SPA_INTERFACE_INIT( SPA_TYPE_INTERFACE_Node, @@ -908,7 +908,7 @@ impl_init(const struct spa_handle_factory *factory, link_io(this); #else - this->target = this->slave; + this->target = this->follower; spa_node_add_listener(this->target, &this->target_listener, &target_node_events, this); diff --git a/src/modules/module-adapter.c b/src/modules/module-adapter.c index 788499275..bb6db61e8 100644 --- a/src/modules/module-adapter.c +++ b/src/modules/module-adapter.c @@ -64,7 +64,7 @@ struct node_data { struct factory_data *data; struct spa_list link; struct pw_impl_node *adapter; - struct pw_impl_node *slave; + struct pw_impl_node *follower; struct spa_hook adapter_listener; struct pw_resource *resource; struct spa_hook resource_listener; @@ -95,7 +95,7 @@ static void node_destroy(void *data) static void node_free(void *data) { struct node_data *nd = data; - pw_impl_node_destroy(nd->slave); + pw_impl_node_destroy(nd->follower); } static void node_initialized(void *data) @@ -145,7 +145,7 @@ static void *create_object(void *_data, { struct factory_data *d = _data; struct pw_impl_client *client; - struct pw_impl_node *adapter, *slave; + struct pw_impl_node *adapter, *follower; const char *str, *factory_name; int res; struct node_data *nd; @@ -163,30 +163,30 @@ static void *create_object(void *_data, pw_impl_client_get_info(client)->id); } - slave = NULL; - str = pw_properties_get(properties, "adapt.slave.node"); + follower = NULL; + str = pw_properties_get(properties, "adapt.follower.node"); if (str != NULL) { - if (sscanf(str, "pointer:%p", &slave) != 1) + if (sscanf(str, "pointer:%p", &follower) != 1) 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); if (factory_name == NULL) goto error_properties; - slave = pw_spa_node_load(d->context, + follower = pw_spa_node_load(d->context, factory_name, PW_SPA_NODE_FLAG_ACTIVATE | PW_SPA_NODE_FLAG_NO_REGISTER, pw_properties_copy(properties), 0); - if (slave == NULL) + if (follower == NULL) goto error_no_mem; } adapter = pw_adapter_new(pw_impl_module_get_context(d->module), - slave, + follower, properties, sizeof(struct node_data)); properties = NULL; @@ -201,7 +201,7 @@ static void *create_object(void *_data, nd = pw_adapter_get_user_data(adapter); nd->data = d; nd->adapter = adapter; - nd->slave = slave; + nd->follower = follower; nd->resource = resource; nd->new_id = new_id; spa_list_append(&d->node_list, &nd->link); diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index 49e8aea6c..32c423aa4 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -60,7 +60,7 @@ struct node { struct pw_impl_node *node; struct spa_hook node_listener; - struct pw_impl_node *slave; + struct pw_impl_node *follower; void *user_data; 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 *slave, + struct pw_impl_node *follower, struct pw_properties *props, size_t user_data_size) { @@ -198,13 +198,13 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context, int res; uint32_t media_type, media_subtype; - info = pw_impl_node_get_info(slave); + info = pw_impl_node_get_info(follower); if (info == NULL) { res = -EINVAL; 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_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); } - if ((res = find_format(slave, direction, &media_type, &media_subtype)) < 0) + if ((res = find_format(follower, direction, &media_type, &media_subtype)) < 0) goto error; if (media_type == SPA_MEDIA_TYPE_audio) { - pw_properties_setf(props, "audio.adapt.slave", "pointer:%p", - pw_impl_node_get_implementation(slave)); + pw_properties_setf(props, "audio.adapt.follower", "pointer:%p", + pw_impl_node_get_implementation(follower)); pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert"); if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL) 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; } else if (media_type == SPA_MEDIA_TYPE_video) { - pw_properties_setf(props, "video.adapt.slave", "pointer:%p", - pw_impl_node_get_implementation(slave)); + pw_properties_setf(props, "video.adapt.follower", "pointer:%p", + pw_impl_node_get_implementation(follower)); pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "videoconvert/libspa-videoconvert"); if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL) 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->context = context; n->node = node; - n->slave = slave; + n->follower = follower; n->direction = direction; n->props = props; n->media_type = media_type; diff --git a/src/modules/module-adapter/adapter.h b/src/modules/module-adapter/adapter.h index 113ab72f4..110ed12f1 100644 --- a/src/modules/module-adapter/adapter.h +++ b/src/modules/module-adapter/adapter.h @@ -35,7 +35,7 @@ extern "C" { struct pw_impl_node * pw_adapter_new(struct pw_context *context, - struct pw_impl_node *slave, + struct pw_impl_node *follower, struct pw_properties *properties, size_t user_data_size); diff --git a/src/pipewire/context.c b/src/pipewire/context.c index 4f72729a7..164ff864a 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -729,12 +729,12 @@ static int collect_nodes(struct pw_impl_node *driver) uint32_t min_quantum = 0; uint32_t quantum; - spa_list_consume(t, &driver->slave_list, slave_link) { - spa_list_remove(&t->slave_link); - spa_list_init(&t->slave_link); + spa_list_consume(t, &driver->follower_list, follower_link) { + spa_list_remove(&t->follower_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_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 * to it. Some nodes are not (yet) linked to anything and they * 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. */ target = NULL; spa_list_for_each(n, &context->driver_list, driver_link) { - uint32_t active_slaves; + uint32_t active_followers; if (n->active && !n->visited) collect_nodes(n); /* 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. */ if (!n->master) continue; - active_slaves = 0; - spa_list_for_each(s, &n->slave_list, slave_link) { - pw_log_info(NAME" %p: driver %p: slave %p %s: %d", + active_followers = 0; + spa_list_for_each(s, &n->follower_list, follower_link) { + pw_log_debug(NAME" %p: driver %p: follower %p %s: %d", context, n, s, s->name, s->active); if (s != n && s->active) - active_slaves++; + active_followers++; } - pw_log_info(NAME" %p: driver %p active slaves %d", - context, n, active_slaves); + pw_log_debug(NAME" %p: driver %p active followers %d", + 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 */ - if (active_slaves > 0) { + if (active_followers > 0) { if (target == NULL) target = n; } @@ -830,7 +830,7 @@ int pw_context_recalc_graph(struct pw_context *context) spa_list_for_each(n, &context->node_list, link) { 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); if (!n->want_driver) @@ -848,7 +848,7 @@ int pw_context_recalc_graph(struct pw_context *context) 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) { if (!n->master) 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, n->quantum_current, n->name); - spa_list_for_each(s, &n->slave_list, slave_link) - pw_log_info(NAME" %p: slave %p: active:%d '%s'", + spa_list_for_each(s, &n->follower_list, follower_link) + pw_log_info(NAME" %p: follower %p: active:%d '%s'", context, s, s->active, s->name); } return 0; diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index f1cb31953..b1b5c7498 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -657,8 +657,8 @@ int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driv if (driver == NULL) driver = node; - spa_list_remove(&node->slave_link); - spa_list_append(&driver->slave_list, &node->slave_link); + spa_list_remove(&node->follower_link); + spa_list_append(&driver->follower_list, &node->follower_link); if (old == driver) return 0; @@ -992,7 +992,7 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context, 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); @@ -1023,7 +1023,7 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context, check_properties(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; 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 pw_impl_port *port; - struct pw_impl_node *slave; + struct pw_impl_node *follower; 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); - /* remove ourself as a slave from the driver node */ - spa_list_remove(&node->slave_link); + /* remove ourself as a follower from the driver node */ + spa_list_remove(&node->follower_link); remove_segment_master(node->driver_node, node->info.id); - spa_list_consume(slave, &node->slave_list, slave_link) { - pw_log_debug(NAME" %p: reslave %p", impl, slave); - pw_impl_node_set_driver(slave, NULL); + spa_list_consume(follower, &node->follower_list, follower_link) { + pw_log_debug(NAME" %p: reassign follower %p", impl, follower); + pw_impl_node_set_driver(follower, NULL); } if (node->registered) { diff --git a/src/pipewire/private.h b/src/pipewire/private.h index e69457178..c1d1b9914 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -524,8 +524,8 @@ struct pw_impl_node { struct spa_list driver_link; struct pw_impl_node *driver_node; - struct spa_list slave_list; - struct spa_list slave_link; + struct spa_list follower_list; + struct spa_list follower_link; struct spa_list sort_link; /**< link used to sort nodes */ diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index eb7a18d43..fd0c8d314 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -1349,7 +1349,7 @@ pw_stream_connect(struct pw_stream *stream, struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct pw_impl_factory *factory; struct pw_properties *props; - struct pw_impl_node *slave; + struct pw_impl_node *follower; const char *str; uint32_t i; int res; @@ -1446,13 +1446,13 @@ pw_stream_connect(struct pw_stream *stream, pw_properties_set(props, "resample.peaks", "1"); } - slave = pw_context_create_node(impl->context, pw_properties_copy(props), 0); - if (slave == NULL) { + follower = pw_context_create_node(impl->context, pw_properties_copy(props), 0); + if (follower == NULL) { res = -errno; 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 && impl->media_subtype == SPA_MEDIA_SUBTYPE_raw) { @@ -1462,7 +1462,7 @@ pw_stream_connect(struct pw_stream *stream, res = -ENOENT; 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, NULL, PW_TYPE_INTERFACE_Node, @@ -1474,7 +1474,7 @@ pw_stream_connect(struct pw_stream *stream, goto error_node; } } else { - impl->node = slave; + impl->node = follower; } if (!SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_INACTIVE)) pw_impl_node_set_active(impl->node, true);