mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-01 06:57:58 +02:00
core: add idle & timeout method variants that take a GClosure
This commit is contained in:
parent
6501307d27
commit
a10ee91bd4
2 changed files with 68 additions and 2 deletions
|
|
@ -495,6 +495,34 @@ wp_core_idle_add (WpCore * self, GSource **source, GSourceFunc function,
|
|||
*source = g_source_ref (s);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_core_idle_add_closure: (rename-to wp_core_idle_add)
|
||||
* @self: the core
|
||||
* @source: (out) (optional): the source
|
||||
* @closure: the closure to invoke
|
||||
*
|
||||
* Adds an idle callback to be called in the same #GMainContext as the
|
||||
* one used by this core.
|
||||
*
|
||||
* This is the same as wp_core_idle_add(), but it allows you to specify
|
||||
* a #GClosure instead of a C callback.
|
||||
*/
|
||||
void
|
||||
wp_core_idle_add_closure (WpCore * self, GSource **source, GClosure * closure)
|
||||
{
|
||||
g_autoptr (GSource) s = NULL;
|
||||
|
||||
g_return_if_fail (WP_IS_CORE (self));
|
||||
g_return_if_fail (closure != NULL);
|
||||
|
||||
s = g_idle_source_new ();
|
||||
g_source_set_closure (s, closure);
|
||||
g_source_attach (s, self->context);
|
||||
|
||||
if (source)
|
||||
*source = g_source_ref (s);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_core_timeout_add:
|
||||
* @self: the core
|
||||
|
|
@ -513,7 +541,7 @@ wp_core_idle_add (WpCore * self, GSource **source, GSourceFunc function,
|
|||
* used by this core instead of the default context.
|
||||
*/
|
||||
void
|
||||
wp_core_timeout_add (WpCore * self, GSource **source, guint64 timeout_ms,
|
||||
wp_core_timeout_add (WpCore * self, GSource **source, guint timeout_ms,
|
||||
GSourceFunc function, gpointer data, GDestroyNotify destroy)
|
||||
{
|
||||
g_autoptr (GSource) s = NULL;
|
||||
|
|
@ -528,6 +556,36 @@ wp_core_timeout_add (WpCore * self, GSource **source, guint64 timeout_ms,
|
|||
*source = g_source_ref (s);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_core_timeout_add_closure: (rename-to wp_core_timeout_add)
|
||||
* @self: the core
|
||||
* @source: (out) (optional): the source
|
||||
* @timeout_ms: the timeout in milliseconds
|
||||
* @closure: the closure to invoke
|
||||
*
|
||||
* Adds a timeout callback to be called at regular intervals in the same
|
||||
* #GMainContext as the one used by this core.
|
||||
*
|
||||
* This is the same as wp_core_timeout_add(), but it allows you to specify
|
||||
* a #GClosure instead of a C callback.
|
||||
*/
|
||||
void
|
||||
wp_core_timeout_add_closure (WpCore * self, GSource **source, guint timeout_ms,
|
||||
GClosure * closure)
|
||||
{
|
||||
g_autoptr (GSource) s = NULL;
|
||||
|
||||
g_return_if_fail (WP_IS_CORE (self));
|
||||
g_return_if_fail (closure != NULL);
|
||||
|
||||
s = g_timeout_source_new (timeout_ms);
|
||||
g_source_set_closure (s, closure);
|
||||
g_source_attach (s, self->context);
|
||||
|
||||
if (source)
|
||||
*source = g_source_ref (s);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_core_sync:
|
||||
* @self: the core
|
||||
|
|
|
|||
|
|
@ -54,9 +54,17 @@ void wp_core_idle_add (WpCore * self, GSource **source, GSourceFunc function,
|
|||
gpointer data, GDestroyNotify destroy);
|
||||
|
||||
WP_API
|
||||
void wp_core_timeout_add (WpCore * self, GSource **source, guint64 timeout_ms,
|
||||
void wp_core_idle_add_closure (WpCore * self, GSource **source,
|
||||
GClosure * closure);
|
||||
|
||||
WP_API
|
||||
void wp_core_timeout_add (WpCore * self, GSource **source, guint timeout_ms,
|
||||
GSourceFunc function, gpointer data, GDestroyNotify destroy);
|
||||
|
||||
WP_API
|
||||
void wp_core_timeout_add_closure (WpCore * self, GSource **source,
|
||||
guint timeout_ms, GClosure * closure);
|
||||
|
||||
WP_API
|
||||
gboolean wp_core_sync (WpCore * self, GCancellable * cancellable,
|
||||
GAsyncReadyCallback callback, gpointer user_data);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue