mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 06:18:04 +02:00
object: add new _abort_activation API
Allows aborting an object activation by returning a transition error for all pending transitions.
This commit is contained in:
parent
7483f3573f
commit
93c0b48bd9
2 changed files with 43 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "object.h"
|
||||
#include "log.h"
|
||||
#include "core.h"
|
||||
#include "error.h"
|
||||
|
||||
/*! \defgroup wpfeatureactivationtransition WpFeatureActivationTransition */
|
||||
/*!
|
||||
|
|
@ -466,6 +467,45 @@ wp_object_deactivate (WpObject * self, WpObjectFeatures features)
|
|||
WP_OBJECT_GET_CLASS (self)->deactivate (self, features & priv->ft_active);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Aborts the current object activation by returning a transition error
|
||||
* if any transitions are pending.
|
||||
*
|
||||
* This is usually used to stop any pending activation if an error happened.
|
||||
*
|
||||
* \ingroup wpobject
|
||||
* \param self the object
|
||||
* \param msg the message used in the transition error
|
||||
* \since 0.4.6
|
||||
*/
|
||||
void
|
||||
wp_object_abort_activation (WpObject * self, const gchar *msg)
|
||||
{
|
||||
WpObjectPrivate *priv;
|
||||
g_autoptr (WpTransition) t = NULL;
|
||||
|
||||
g_return_if_fail (WP_IS_OBJECT (self));
|
||||
|
||||
priv = wp_object_get_instance_private (self);
|
||||
|
||||
g_clear_pointer (&priv->idle_advnc_source, g_source_unref);
|
||||
|
||||
/* abort ongoing transition if any */
|
||||
t = g_weak_ref_get (&priv->ongoing_transition);
|
||||
if (t)
|
||||
wp_transition_return_error (t, g_error_new (WP_DOMAIN_LIBRARY,
|
||||
WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"Object activation aborted: %s", msg));
|
||||
|
||||
/* abort queued transitions */
|
||||
while (!g_queue_is_empty (priv->transitions)) {
|
||||
WpTransition *next = g_queue_pop_head (priv->transitions);
|
||||
wp_transition_return_error (next, g_error_new (WP_DOMAIN_LIBRARY,
|
||||
WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"Object activation aborted: %s", msg));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Allows subclasses to update the currently active features.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -106,6 +106,9 @@ void wp_object_deactivate (WpObject * self, WpObjectFeatures features);
|
|||
|
||||
/* for subclasses only */
|
||||
|
||||
WP_API
|
||||
void wp_object_abort_activation (WpObject * self, const gchar *msg);
|
||||
|
||||
WP_API
|
||||
void wp_object_update_features (WpObject * self, WpObjectFeatures activated,
|
||||
WpObjectFeatures deactivated);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue