Skip to content
Snippets Groups Projects
Commit 5ab3e74b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

variables: privatise the callback CV

The condition variable was shared across all variables of a given
object to save space, but it ends up waking up the wrong waiting
threads.

vlc_cond_t is not as large as it used to be. In fact, it could be as
small as a single pointer: if we required holding the mutex during
signal/broadcast. The nested mutex is only there to handle unprotected
signalling.
parent 3103c63b
No related branches found
No related tags found
No related merge requests found
Pipeline #49877 passed with stages
in 26 minutes and 39 seconds
......@@ -69,7 +69,6 @@ int vlc_object_init(vlc_object_t *restrict obj, vlc_object_t *parent,
priv->typename = typename;
priv->var_root = NULL;
vlc_mutex_init (&priv->var_lock);
vlc_cond_init (&priv->var_wait);
priv->resources = NULL;
obj->priv = priv;
......
......@@ -96,6 +96,8 @@ struct variable_t
callback_entry_t *value_callbacks;
/** Registered list callbacks */
callback_entry_t *list_callbacks;
vlc_cond_t wait;
};
static int CmpBool( vlc_value_t v, vlc_value_t w )
......@@ -228,7 +230,7 @@ static void WaitUnused(vlc_object_t *obj, variable_t *var)
mutex_cleanup_push(&priv->var_lock);
while (var->b_incallback)
vlc_cond_wait(&priv->var_wait, &priv->var_lock);
vlc_cond_wait(&var->wait, &priv->var_lock);
vlc_cleanup_pop();
}
......@@ -256,7 +258,7 @@ static void TriggerCallback(vlc_object_t *obj, variable_t *var,
vlc_mutex_lock(&priv->var_lock);
var->b_incallback = false;
vlc_cond_broadcast(&priv->var_wait);
vlc_cond_broadcast(&var->wait);
}
static void TriggerListCallback(vlc_object_t *obj, variable_t *var,
......@@ -283,7 +285,7 @@ static void TriggerListCallback(vlc_object_t *obj, variable_t *var,
vlc_mutex_lock(&priv->var_lock);
var->b_incallback = false;
vlc_cond_broadcast(&priv->var_wait);
vlc_cond_broadcast(&var->wait);
}
int (var_Create)( vlc_object_t *p_this, const char *psz_name, int i_type )
......
......@@ -40,7 +40,6 @@ struct vlc_object_internals
/* Object variables */
void *var_root;
vlc_mutex_t var_lock;
vlc_cond_t var_wait;
/* Object resources */
struct vlc_res *resources;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment