mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-14 05:34:06 -04:00
modules: try to improve code readability some more
This commit is contained in:
parent
41520f1022
commit
3e209f6d20
1 changed files with 23 additions and 18 deletions
|
|
@ -107,12 +107,17 @@ static int ensure_state(struct pw_impl_node *node, bool running)
|
|||
}
|
||||
|
||||
/* Make a node runnable. Peer nodes are also made runnable when the passive_mode
|
||||
* of the port is false or follow.
|
||||
* of the peer port is !TRUE.
|
||||
*
|
||||
* A (*) -> B if A running -> B set to running
|
||||
* A (*) -> (f) B if A running -> B set to running
|
||||
* A (*) -> (p) B if A running -> B no change
|
||||
* A (*) -> B if A running -> B set to running
|
||||
* A (*) -> (f) B if A running -> B set to running
|
||||
* A (*) -> (fs) B if A running -> B set to running
|
||||
* A (*) -> (p) B if A running -> B no change
|
||||
*/
|
||||
static inline bool makes_runnable(struct pw_impl_port *a, struct pw_impl_port *b)
|
||||
{
|
||||
return b->passive_mode != PASSIVE_MODE_TRUE;
|
||||
}
|
||||
static void make_runnable(struct pw_context *context, struct pw_impl_node *node)
|
||||
{
|
||||
struct pw_impl_port *p;
|
||||
|
|
@ -141,7 +146,7 @@ static void make_runnable(struct pw_context *context, struct pw_impl_node *node)
|
|||
n = l->input->node;
|
||||
pw_log_trace(" out-port %p: link %p passive:%d prepared:%d active:%d runn:%d", p,
|
||||
l, l->input->passive_mode, l->prepared, n->active, n->runnable);
|
||||
if (!n->active || l->input->passive_mode == PASSIVE_MODE_TRUE)
|
||||
if (!n->active || !makes_runnable(p, l->input))
|
||||
continue;
|
||||
pw_impl_link_prepare(l);
|
||||
if (!l->prepared)
|
||||
|
|
@ -155,7 +160,7 @@ static void make_runnable(struct pw_context *context, struct pw_impl_node *node)
|
|||
n = l->output->node;
|
||||
pw_log_trace(" in-port %p: link %p passive:%d prepared:%d active:%d runn:%d", p,
|
||||
l, l->output->passive_mode, l->prepared, n->active, n->runnable);
|
||||
if (!n->active || l->output->passive_mode == PASSIVE_MODE_TRUE)
|
||||
if (!n->active || !makes_runnable(p, l->output))
|
||||
continue;
|
||||
pw_impl_link_prepare(l);
|
||||
if (!l->prepared)
|
||||
|
|
@ -188,20 +193,20 @@ static void make_runnable(struct pw_context *context, struct pw_impl_node *node)
|
|||
* Only consider ports that have a PASSIVE_MODE_FALSE link.
|
||||
* All other port modes don't make A and B runnable.
|
||||
*
|
||||
* A -> B A + B both set to running
|
||||
* A -> (p) B A + B both set to running
|
||||
* A -> (f) B A + B both set to running
|
||||
* A (p) -> (*) B A + B no change
|
||||
* A (f) -> (*) B A + B no change
|
||||
* A (fs) -> (*) B A + B no change
|
||||
* A -> B A + B both set to running
|
||||
* A -> (p) B A + B both set to running
|
||||
* A -> (f) B A + B both set to running
|
||||
* A (fs) -> (fs) B A + B both set to running
|
||||
* A (p) -> (*) B A + B no change
|
||||
* A (f) -> (*) B A + B no change
|
||||
* A (fs) -> (*) B A + B no change
|
||||
*/
|
||||
static inline bool may_follow(struct pw_impl_port *p, struct pw_impl_port *other)
|
||||
static inline bool runnable_pair(struct pw_impl_port *a, struct pw_impl_port *b)
|
||||
{
|
||||
if (p->passive_mode == PASSIVE_MODE_FALSE)
|
||||
if (a->passive_mode == PASSIVE_MODE_FALSE)
|
||||
return true;
|
||||
if (p->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND &&
|
||||
other->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND)
|
||||
if (a->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND &&
|
||||
b->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -224,7 +229,7 @@ static void check_runnable(struct pw_context *context, struct pw_impl_node *node
|
|||
* with a non-passive link */
|
||||
pw_log_trace(" out-port %p: link %p passive:%d prepared:%d active:%d", p,
|
||||
l, p->passive_mode, l->prepared, n->active);
|
||||
if (!n->active || !may_follow(p, l->input))
|
||||
if (!n->active || !runnable_pair(p, l->input))
|
||||
continue;
|
||||
/* explicitly prepare the link in case it was suspended */
|
||||
pw_impl_link_prepare(l);
|
||||
|
|
@ -239,7 +244,7 @@ static void check_runnable(struct pw_context *context, struct pw_impl_node *node
|
|||
n = l->output->node;
|
||||
pw_log_trace(" in-port %p: link %p passive:%d prepared:%d active:%d", p,
|
||||
l, p->passive_mode, l->prepared, n->active);
|
||||
if (!n->active || !may_follow(p, l->output))
|
||||
if (!n->active || !runnable_pair(p, l->output))
|
||||
continue;
|
||||
pw_impl_link_prepare(l);
|
||||
if (!l->prepared)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue