Improve naming

master -> driving
priority_master -> priority_driver
segment_master -> segment_owner
This commit is contained in:
Wim Taymans 2020-08-06 13:49:33 +02:00
parent 98b7dc7c0c
commit e71936f870
14 changed files with 63 additions and 62 deletions

View file

@ -6,7 +6,7 @@ There are 2 main components that make up the PipeWire library:
2) An asynchronous IPC mechanism to manipulate and introspect 2) An asynchronous IPC mechanism to manipulate and introspect
a graph in another process. a graph in another process.
There is usually a daemon that implements the master graph and There is usually a daemon that implements the global graph and
clients that operate on this graph. clients that operate on this graph.
The IPC mechanism in PipeWire is inspired by wayland in that it The IPC mechanism in PipeWire is inspired by wayland in that it

View file

@ -102,8 +102,6 @@ struct global {
uint32_t permissions; uint32_t permissions;
struct pw_properties *props; struct pw_properties *props;
int priority_master;
struct pw_proxy *proxy; struct pw_proxy *proxy;
struct spa_hook proxy_listener; struct spa_hook proxy_listener;
struct spa_hook object_listener; struct spa_hook object_listener;
@ -905,7 +903,7 @@ static void node_event_info(void *object, const struct pw_node_info *info)
else else
g->node.device_id = SPA_ID_INVALID; g->node.device_id = SPA_ID_INVALID;
if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_PRIORITY_MASTER))) if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_PRIORITY_DRIVER)))
g->node.priority = atoi(str); g->node.priority = atoi(str);
if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_MEDIA_CLASS))) { if (info->props && (str = spa_dict_lookup(info->props, PW_KEY_MEDIA_CLASS))) {
if (strcmp(str, "Audio/Sink") == 0) if (strcmp(str, "Audio/Sink") == 0)

View file

@ -337,8 +337,8 @@ struct client {
unsigned int thread_entered:1; unsigned int thread_entered:1;
unsigned int has_transport:1; unsigned int has_transport:1;
unsigned int allow_mlock:1; unsigned int allow_mlock:1;
unsigned int timemaster_pending:1; unsigned int timeowner_pending:1;
unsigned int timemaster_conditional:1; unsigned int timeowner_conditional:1;
jack_position_t jack_position; jack_position_t jack_position;
jack_transport_state_t jack_state; jack_transport_state_t jack_state;
@ -1243,12 +1243,12 @@ static int client_node_set_param(void *object,
return -ENOTSUP; return -ENOTSUP;
} }
static int install_timemaster(struct client *c) static int install_timeowner(struct client *c)
{ {
struct pw_node_activation *a; struct pw_node_activation *a;
uint32_t owner; uint32_t owner;
if (!c->timemaster_pending) if (!c->timeowner_pending)
return 0; return 0;
if ((a = c->driver_activation) == NULL) if ((a = c->driver_activation) == NULL)
@ -1261,8 +1261,8 @@ static int install_timemaster(struct client *c)
if (owner == c->node_id) if (owner == c->node_id)
return 0; return 0;
/* try to become master */ /* try to become owner */
if (c->timemaster_conditional) { if (c->timeowner_conditional) {
if (!ATOMIC_CAS(a->segment_owner[0], 0, c->node_id)) { if (!ATOMIC_CAS(a->segment_owner[0], 0, c->node_id)) {
pw_log_debug(NAME" %p: owner:%u id:%u", c, owner, c->node_id); pw_log_debug(NAME" %p: owner:%u id:%u", c, owner, c->node_id);
return -EBUSY; return -EBUSY;
@ -1272,7 +1272,7 @@ static int install_timemaster(struct client *c)
} }
pw_log_debug(NAME" %p: timebase installed for id:%u", c, c->node_id); pw_log_debug(NAME" %p: timebase installed for id:%u", c, c->node_id);
c->timemaster_pending = false; c->timeowner_pending = false;
return 0; return 0;
} }
@ -1296,7 +1296,7 @@ static int update_driver_activation(struct client *c)
c->driver_activation = link ? link->activation : NULL; c->driver_activation = link ? link->activation : NULL;
pw_data_loop_invoke(c->loop, pw_data_loop_invoke(c->loop,
do_update_driver_activation, SPA_ID_INVALID, NULL, 0, true, c); do_update_driver_activation, SPA_ID_INVALID, NULL, 0, true, c);
install_timemaster(c); install_timeowner(c);
return 0; return 0;
} }
@ -2037,7 +2037,7 @@ static void registry_event_global(void *data, uint32_t id,
if (ot != NULL && o->node.client_id != ot->node.client_id) if (ot != NULL && o->node.client_id != ot->node.client_id)
snprintf(o->node.name, sizeof(o->node.name), "%s-%d", str, id); snprintf(o->node.name, sizeof(o->node.name), "%s-%d", str, id);
if ((str = spa_dict_lookup(props, PW_KEY_PRIORITY_MASTER)) != NULL) if ((str = spa_dict_lookup(props, PW_KEY_PRIORITY_DRIVER)) != NULL)
o->node.priority = pw_properties_parse_int(str); o->node.priority = pw_properties_parse_int(str);
pw_log_debug(NAME" %p: add node %d", c, id); pw_log_debug(NAME" %p: add node %d", c, id);
@ -4343,7 +4343,7 @@ int jack_release_timebase (jack_client_t *client)
c->timebase_callback = NULL; c->timebase_callback = NULL;
c->timebase_arg = NULL; c->timebase_arg = NULL;
c->activation->pending_new_pos = false; c->activation->pending_new_pos = false;
c->timemaster_pending = false; c->timeowner_pending = false;
return 0; return 0;
} }
@ -4399,9 +4399,9 @@ int jack_set_timebase_callback (jack_client_t *client,
c->timebase_callback = timebase_callback; c->timebase_callback = timebase_callback;
c->timebase_arg = arg; c->timebase_arg = arg;
c->timemaster_pending = true; c->timeowner_pending = true;
c->timemaster_conditional = conditional; c->timeowner_conditional = conditional;
install_timemaster(c); install_timeowner(c);
pw_log_debug(NAME" %p: timebase set id:%u", c, c->node_id); pw_log_debug(NAME" %p: timebase set id:%u", c, c->node_id);

View file

@ -1089,8 +1089,8 @@ static int set_mask(pa_context *c, struct global *g)
if (g->props == NULL) if (g->props == NULL)
return 0; return 0;
if ((str = pw_properties_get(g->props, PW_KEY_PRIORITY_MASTER)) != NULL) if ((str = pw_properties_get(g->props, PW_KEY_PRIORITY_DRIVER)) != NULL)
g->priority_master = pw_properties_parse_int(str); g->priority_driver = pw_properties_parse_int(str);
if ((str = pw_properties_get(g->props, PW_KEY_MEDIA_CLASS)) == NULL) { if ((str = pw_properties_get(g->props, PW_KEY_MEDIA_CLASS)) == NULL) {
pw_log_debug("node %d without "PW_KEY_MEDIA_CLASS, g->id); pw_log_debug("node %d without "PW_KEY_MEDIA_CLASS, g->id);
@ -1219,7 +1219,7 @@ static inline void insert_global(pa_context *c, struct global *global)
bool found = false; bool found = false;
spa_list_for_each(g, &c->globals, link) { spa_list_for_each(g, &c->globals, link) {
if (g->priority_master < global->priority_master) { if (g->priority_driver < global->priority_driver) {
g = spa_list_prev(g, link); g = spa_list_prev(g, link);
found = true; found = true;
break; break;

View file

@ -250,7 +250,7 @@ struct global {
pa_subscription_mask_t mask; pa_subscription_mask_t mask;
pa_subscription_event_type_t event; pa_subscription_event_type_t event;
int priority_master; int priority_driver;
int pending_seq; int pending_seq;
int init:1; int init:1;

View file

@ -254,7 +254,7 @@ enum spa_io_position_state {
* The position information adds extra meaning to the raw clock times. * The position information adds extra meaning to the raw clock times.
* *
* It is set on all nodes and the clock id will contain the clock of the * It is set on all nodes and the clock id will contain the clock of the
* master node in the graph. * driving node in the graph.
* *
* The position information contains 1 or more segments that convert the * The position information contains 1 or more segments that convert the
* raw clock times to a stream time. They are sorted based on their * raw clock times to a stream time. They are sorted based on their

View file

@ -82,7 +82,7 @@ struct impl {
unsigned int add_listener:1; unsigned int add_listener:1;
unsigned int have_format:1; unsigned int have_format:1;
unsigned int started:1; unsigned int started:1;
unsigned int master:1; unsigned int driver:1;
}; };
/** \endcond */ /** \endcond */
@ -655,7 +655,7 @@ static int follower_ready(void *data, int status)
spa_log_trace_fp(this->log, NAME " %p: ready %d", this, status); spa_log_trace_fp(this->log, NAME " %p: ready %d", this, status);
this->master = true; this->driver = true;
if (this->direction == SPA_DIRECTION_OUTPUT) if (this->direction == SPA_DIRECTION_OUTPUT)
status = spa_node_process(this->convert); status = spa_node_process(this->convert);
@ -880,8 +880,8 @@ static int impl_node_process(void *object)
struct impl *this = object; struct impl *this = object;
int status = 0; int status = 0;
spa_log_trace_fp(this->log, "%p: process convert:%p master:%d", spa_log_trace_fp(this->log, "%p: process convert:%p driver:%d",
this, this->convert, this->master); this, this->convert, this->driver);
if (this->direction == SPA_DIRECTION_INPUT) { if (this->direction == SPA_DIRECTION_INPUT) {
if (this->convert) if (this->convert)
@ -892,7 +892,7 @@ static int impl_node_process(void *object)
status = spa_node_process(this->follower); status = spa_node_process(this->follower);
if (this->direction == SPA_DIRECTION_OUTPUT && if (this->direction == SPA_DIRECTION_OUTPUT &&
!this->master && this->convert) { !this->driver && this->convert) {
while (status > 0) { while (status > 0) {
status = spa_node_process(this->convert); status = spa_node_process(this->convert);
if (status & (SPA_STATUS_HAVE_DATA | SPA_STATUS_DRAINED)) if (status & (SPA_STATUS_HAVE_DATA | SPA_STATUS_DRAINED))
@ -906,7 +906,7 @@ static int impl_node_process(void *object)
} }
spa_log_trace_fp(this->log, "%p: process status:%d", this, status); spa_log_trace_fp(this->log, "%p: process status:%d", this, status);
this->master = false; this->driver = false;
return status; return status;
} }

View file

@ -78,7 +78,7 @@ struct impl {
unsigned int started:1; unsigned int started:1;
unsigned int active:1; unsigned int active:1;
unsigned int driver:1; unsigned int driver:1;
unsigned int master:1; unsigned int driving:1;
unsigned int monitor:1; unsigned int monitor:1;
}; };
@ -775,7 +775,7 @@ static int impl_node_process(void *object)
if (this->monitor) if (this->monitor)
status |= SPA_STATUS_HAVE_DATA; status |= SPA_STATUS_HAVE_DATA;
if (this->direction == SPA_DIRECTION_OUTPUT && !this->master) { if (this->direction == SPA_DIRECTION_OUTPUT && !this->driving) {
if (this->use_converter) if (this->use_converter)
status = spa_node_process(this->convert); status = spa_node_process(this->convert);
} }

View file

@ -67,7 +67,7 @@ load-module libpipewire-module-session-manager
#create-object spa-device-factory factory.name=api.alsa.seq.bridge node.name=Internal-MIDI-Bridge #create-object spa-device-factory factory.name=api.alsa.seq.bridge node.name=Internal-MIDI-Bridge
#create-object adapter factory.name=audiotestsrc node.name=my-test #create-object adapter factory.name=audiotestsrc node.name=my-test
#create-object spa-node-factory factory.name=api.vulkan.compute.source node.name=my-compute-source #create-object spa-node-factory factory.name=api.vulkan.compute.source node.name=my-compute-source
create-object spa-node-factory factory.name=support.node.driver node.name=Dummy priority.master=8000 create-object spa-node-factory factory.name=support.node.driver node.name=Dummy priority.driver=8000
## exec <program-name> ## exec <program-name>
# #

View file

@ -247,8 +247,8 @@ static struct node *alsa_create_node(struct device *device, uint32_t id,
else if (strstr(profile, "iec958-") == profile) else if (strstr(profile, "iec958-") == profile)
priority += 8; priority += 8;
if (pw_properties_get(node->props, PW_KEY_PRIORITY_MASTER) == NULL) { if (pw_properties_get(node->props, PW_KEY_PRIORITY_DRIVER) == NULL) {
pw_properties_setf(node->props, PW_KEY_PRIORITY_MASTER, "%d", priority); pw_properties_setf(node->props, PW_KEY_PRIORITY_DRIVER, "%d", priority);
pw_properties_setf(node->props, PW_KEY_PRIORITY_SESSION, "%d", priority); pw_properties_setf(node->props, PW_KEY_PRIORITY_SESSION, "%d", priority);
} }

View file

@ -868,7 +868,7 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
/* 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 driver. Other nodes are drivers
* and if they have active followers, 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 = fallback = NULL; target = fallback = NULL;
@ -879,12 +879,12 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
if (!n->visited) if (!n->visited)
collect_nodes(n); collect_nodes(n);
/* from now on we are only interested in active master nodes. /* from now on we are only interested in active driving nodes.
* We're going to see if there are active followers. */ * We're going to see if there are active followers. */
if (!n->master || !n->active || n->passive) if (!n->driving || !n->active || n->passive)
continue; continue;
/* first active master node is fallback */ /* first active driving node is fallback */
if (fallback == NULL) if (fallback == NULL)
fallback = n; fallback = n;
@ -892,21 +892,21 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
pw_log_debug(NAME" %p: driver %p: follower %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) {
/* if the master has active followers, it is a target for our /* if the driving node has active followers, it
* unassigned nodes */ * is a target for our unassigned nodes */
if (target == NULL) if (target == NULL)
target = n; target = n;
break; break;
} }
} }
} }
/* no active node, use fallback master */ /* no active node, use fallback driving node */
if (target == NULL) if (target == NULL)
target = fallback; target = fallback;
/* now go through all available nodes. The ones we didn't visit /* now go through all available nodes. The ones we didn't visit
* in collect_nodes() are not linked to any master. We assign them * in collect_nodes() are not linked to any driver. We assign them
* to either an active master of the first master */ * to either an active driver of the first driver */
spa_list_for_each(n, &context->node_list, link) { spa_list_for_each(n, &context->node_list, link) {
if (n->exported) if (n->exported)
continue; continue;
@ -926,14 +926,14 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
n->visited = false; n->visited = false;
} }
/* assign final quantum and set state for followers and master */ /* assign final quantum and set state for followers and drivers */
spa_list_for_each(n, &context->driver_list, driver_link) { spa_list_for_each(n, &context->driver_list, driver_link) {
bool running = false; bool running = false;
uint32_t max_quantum = 0; uint32_t max_quantum = 0;
uint32_t min_quantum = 0; uint32_t min_quantum = 0;
uint32_t quantum; uint32_t quantum;
if (!n->master || n->exported) if (!n->driving || n->exported)
continue; continue;
/* collect quantum and count active nodes */ /* collect quantum and count active nodes */
@ -964,8 +964,8 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
n->rt.position->clock.duration = quantum; n->rt.position->clock.duration = quantum;
} }
pw_log_debug(NAME" %p: master %p running:%d passive:%d quantum:%u '%s'", context, n, pw_log_debug(NAME" %p: driving %p running:%d passive:%d quantum:%u '%s'",
running, n->passive, quantum, n->name); context, n, running, n->passive, quantum, n->name);
spa_list_for_each(s, &n->follower_list, follower_link) { spa_list_for_each(s, &n->follower_list, follower_link) {
if (s == n) if (s == n)

View file

@ -575,7 +575,7 @@ static inline void insert_driver(struct pw_context *context, struct pw_impl_node
struct pw_impl_node *n, *t; struct pw_impl_node *n, *t;
spa_list_for_each_safe(n, t, &context->driver_list, driver_link) { spa_list_for_each_safe(n, t, &context->driver_list, driver_link) {
if (n->priority_master < node->priority_master) if (n->priority_driver < node->priority_driver)
break; break;
} }
spa_list_append(&n->driver_link, &node->driver_link); spa_list_append(&n->driver_link, &node->driver_link);
@ -616,7 +616,7 @@ int pw_impl_node_register(struct pw_impl_node *this,
PW_KEY_CLIENT_ID, PW_KEY_CLIENT_ID,
PW_KEY_DEVICE_ID, PW_KEY_DEVICE_ID,
PW_KEY_PRIORITY_SESSION, PW_KEY_PRIORITY_SESSION,
PW_KEY_PRIORITY_MASTER, PW_KEY_PRIORITY_DRIVER,
PW_KEY_APP_NAME, PW_KEY_APP_NAME,
PW_KEY_NODE_DESCRIPTION, PW_KEY_NODE_DESCRIPTION,
PW_KEY_NODE_NAME, PW_KEY_NODE_NAME,
@ -706,7 +706,7 @@ do_move_nodes(struct spa_loop *loop,
return 0; return 0;
} }
static void remove_segment_master(struct pw_impl_node *driver, uint32_t node_id) static void remove_segment_owner(struct pw_impl_node *driver, uint32_t node_id)
{ {
struct pw_node_activation *a = driver->rt.activation; struct pw_node_activation *a = driver->rt.activation;
ATOMIC_CAS(a->segment_owner[0], node_id, 0); ATOMIC_CAS(a->segment_owner[0], node_id, 0);
@ -729,11 +729,11 @@ int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driv
if (old == driver) if (old == driver)
return 0; return 0;
remove_segment_master(old, node->info.id); remove_segment_owner(old, node->info.id);
node->master = node->driver && driver == node; node->driving = node->driver && driver == node;
pw_log_debug(NAME" %p: driver %p master:%u", node, pw_log_debug(NAME" %p: driver %p driving:%u", node,
driver, node->master); driver, node->driving);
pw_log_info("(%s-%u) -> change driver (%s-%d -> %s-%d)", pw_log_info("(%s-%u) -> change driver (%s-%d -> %s-%d)",
node->name, node->info.id, node->name, node->info.id,
old->name, old->info.id, driver->name, driver->info.id); old->name, old->info.id, driver->name, driver->info.id);
@ -775,9 +775,9 @@ static void check_properties(struct pw_impl_node *node)
const char *str; const char *str;
bool driver, do_recalc = false; bool driver, do_recalc = false;
if ((str = pw_properties_get(node->properties, PW_KEY_PRIORITY_MASTER))) { if ((str = pw_properties_get(node->properties, PW_KEY_PRIORITY_DRIVER))) {
node->priority_master = pw_properties_parse_int(str); node->priority_driver = pw_properties_parse_int(str);
pw_log_debug(NAME" %p: priority master %d", node, node->priority_master); pw_log_debug(NAME" %p: priority driver %d", node, node->priority_driver);
} }
if ((str = pw_properties_get(node->properties, PW_KEY_NODE_NAME)) && if ((str = pw_properties_get(node->properties, PW_KEY_NODE_NAME)) &&
@ -1122,7 +1122,7 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context,
this->driver_node = this; this->driver_node = this;
spa_list_append(&this->follower_list, &this->follower_link); spa_list_append(&this->follower_list, &this->follower_link);
this->master = true; this->driving = true;
return this; return this;
@ -1474,7 +1474,7 @@ static int node_ready(void *data, int status)
update_position(node, all_ready); update_position(node, all_ready);
} }
if (SPA_UNLIKELY(node->driver && !node->master)) if (SPA_UNLIKELY(node->driver && !node->driving))
return 0; return 0;
if (status & SPA_STATUS_HAVE_DATA) { if (status & SPA_STATUS_HAVE_DATA) {
@ -1602,7 +1602,7 @@ void pw_impl_node_destroy(struct pw_impl_node *node)
/* remove ourself as a follower from the driver node */ /* remove ourself as a follower from the driver node */
spa_list_remove(&node->follower_link); spa_list_remove(&node->follower_link);
remove_segment_master(node->driver_node, node->info.id); remove_segment_owner(node->driver_node, node->info.id);
spa_list_consume(follower, &node->follower_list, follower_link) { spa_list_consume(follower, &node->follower_list, follower_link) {
pw_log_debug(NAME" %p: reassign follower %p", impl, follower); pw_log_debug(NAME" %p: reassign follower %p", impl, follower);

View file

@ -79,7 +79,7 @@ extern "C" {
/* priorities */ /* priorities */
#define PW_KEY_PRIORITY_SESSION "priority.session" /**< priority in session manager */ #define PW_KEY_PRIORITY_SESSION "priority.session" /**< priority in session manager */
#define PW_KEY_PRIORITY_MASTER "priority.master" /**< priority to be a master */ #define PW_KEY_PRIORITY_DRIVER "priority.driver" /**< priority to be a driver */
/* remote keys */ /* remote keys */
#define PW_KEY_REMOTE_NAME "remote.name" /**< The name of the remote to connect to, #define PW_KEY_REMOTE_NAME "remote.name" /**< The name of the remote to connect to,
@ -264,6 +264,9 @@ extern "C" {
#define PW_KEY_VIDEO_FORMAT "video.format" /**< a video format */ #define PW_KEY_VIDEO_FORMAT "video.format" /**< a video format */
#define PW_KEY_VIDEO_SIZE "video.size" /**< a video size as "<width>x<height" */ #define PW_KEY_VIDEO_SIZE "video.size" /**< a video size as "<width>x<height" */
#ifdef PW_ENABLE_DEPRECATED
#define PW_KEY_PRIORITY_MASTER "priority.master" /**< deprecated */
#endif /* PW_ENABLE_DEPRECATED */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -535,7 +535,7 @@ struct pw_impl_node {
char *name; /** for debug */ char *name; /** for debug */
uint32_t priority_master; /** priority for being master driver */ uint32_t priority_driver; /** priority for being driver */
uint32_t spa_flags; uint32_t spa_flags;
unsigned int registered:1; unsigned int registered:1;
@ -544,7 +544,7 @@ struct pw_impl_node {
unsigned int driver:1; /**< if the node can drive the graph */ unsigned int driver:1; /**< if the node can drive the graph */
unsigned int exported:1; /**< if the node is exported */ unsigned int exported:1; /**< if the node is exported */
unsigned int remote:1; /**< if the node is implemented remotely */ unsigned int remote:1; /**< if the node is implemented remotely */
unsigned int master:1; /**< a master node is one of the driver nodes that unsigned int driving:1; /**< a driving node is one of the driver nodes that
* is selected to drive the graph */ * is selected to drive the graph */
unsigned int visited:1; /**< for sorting */ unsigned int visited:1; /**< for sorting */
unsigned int want_driver:1; /**< this node wants to be assigned to a driver */ unsigned int want_driver:1; /**< this node wants to be assigned to a driver */