mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
impl-link: add an active state
Avoid emission of events for each state change. Add an active state and aim to only emit events for paused<->active state changed or error.
This commit is contained in:
parent
f67cbd7444
commit
391fa81fa8
3 changed files with 11 additions and 4 deletions
|
|
@ -112,7 +112,10 @@ static void link_update_state(struct pw_impl_link *link, enum pw_link_state stat
|
||||||
pw_impl_link_emit_state_changed(link, old, state, error);
|
pw_impl_link_emit_state_changed(link, old, state, error);
|
||||||
|
|
||||||
link->info.change_mask |= PW_LINK_CHANGE_MASK_STATE;
|
link->info.change_mask |= PW_LINK_CHANGE_MASK_STATE;
|
||||||
info_changed(link);
|
if (state == PW_LINK_STATE_ERROR ||
|
||||||
|
state == PW_LINK_STATE_PAUSED ||
|
||||||
|
state == PW_LINK_STATE_ACTIVE)
|
||||||
|
info_changed(link);
|
||||||
|
|
||||||
if (state == PW_LINK_STATE_ERROR && link->global) {
|
if (state == PW_LINK_STATE_ERROR && link->global) {
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
@ -331,10 +334,9 @@ static int do_negotiate(struct pw_impl_link *this)
|
||||||
free(this->info.format);
|
free(this->info.format);
|
||||||
this->info.format = format;
|
this->info.format = format;
|
||||||
|
|
||||||
if (changed) {
|
if (changed)
|
||||||
this->info.change_mask |= PW_LINK_CHANGE_MASK_FORMAT;
|
this->info.change_mask |= PW_LINK_CHANGE_MASK_FORMAT;
|
||||||
info_changed(this);
|
|
||||||
}
|
|
||||||
pw_log_debug(NAME" %p: result %d", this, res);
|
pw_log_debug(NAME" %p: result %d", this, res);
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|
@ -551,6 +553,7 @@ int pw_impl_link_activate(struct pw_impl_link *this)
|
||||||
|
|
||||||
impl->activated = true;
|
impl->activated = true;
|
||||||
pw_log_info("(%s) activated", this->name);
|
pw_log_info("(%s) activated", this->name);
|
||||||
|
link_update_state(this, PW_LINK_STATE_ACTIVE, 0, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -719,6 +722,7 @@ int pw_impl_link_deactivate(struct pw_impl_link *this)
|
||||||
impl->io_set = false;
|
impl->io_set = false;
|
||||||
impl->activated = false;
|
impl->activated = false;
|
||||||
pw_log_info("(%s) deactivated", this->name);
|
pw_log_info("(%s) deactivated", this->name);
|
||||||
|
link_update_state(this, PW_LINK_STATE_PAUSED, 0, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,8 @@ const char *pw_link_state_as_string(enum pw_link_state state)
|
||||||
return "allocating";
|
return "allocating";
|
||||||
case PW_LINK_STATE_PAUSED:
|
case PW_LINK_STATE_PAUSED:
|
||||||
return "paused";
|
return "paused";
|
||||||
|
case PW_LINK_STATE_ACTIVE:
|
||||||
|
return "active";
|
||||||
}
|
}
|
||||||
return "invalid-state";
|
return "invalid-state";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ enum pw_link_state {
|
||||||
PW_LINK_STATE_NEGOTIATING = 1, /**< the link is negotiating formats */
|
PW_LINK_STATE_NEGOTIATING = 1, /**< the link is negotiating formats */
|
||||||
PW_LINK_STATE_ALLOCATING = 2, /**< the link is allocating buffers */
|
PW_LINK_STATE_ALLOCATING = 2, /**< the link is allocating buffers */
|
||||||
PW_LINK_STATE_PAUSED = 3, /**< the link is paused */
|
PW_LINK_STATE_PAUSED = 3, /**< the link is paused */
|
||||||
|
PW_LINK_STATE_ACTIVE = 4, /**< the link is active */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Convert a \ref pw_link_state to a readable string \memberof pw_link */
|
/** Convert a \ref pw_link_state to a readable string \memberof pw_link */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue