From e04f935952dbe88015450d308ab8ce0baa16571e Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Fri, 6 Dec 2019 08:43:40 -0500 Subject: [PATCH] core: return a boolean in sync API --- lib/wp/core.c | 9 +++++---- lib/wp/core.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/wp/core.c b/lib/wp/core.c index 09ed291b..90ac5f80 100644 --- a/lib/wp/core.c +++ b/lib/wp/core.c @@ -478,14 +478,14 @@ wp_core_idle_add (WpCore * self, GSourceFunc function, gpointer data) return source; } -void +gboolean wp_core_sync (WpCore * self, GCancellable * cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr (GTask) task = NULL; int seq; - g_return_if_fail (WP_IS_CORE (self)); + g_return_val_if_fail (WP_IS_CORE (self), FALSE); task = g_task_new (self, cancellable, callback, user_data); @@ -493,7 +493,7 @@ wp_core_sync (WpCore * self, GCancellable * cancellable, g_warn_if_reached (); g_task_return_new_error (task, WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_INVARIANT, "No core proxy"); - return; + return FALSE; } seq = pw_core_proxy_sync (self->core_proxy, 0, 0); @@ -501,11 +501,12 @@ wp_core_sync (WpCore * self, GCancellable * cancellable, g_task_return_new_error (task, WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED, "pw_core_proxy_sync failed: %s", g_strerror (-seq)); - return; + return FALSE; } g_hash_table_insert (self->async_tasks, GINT_TO_POINTER (seq), g_steal_pointer (&task)); + return TRUE; } struct pw_core * diff --git a/lib/wp/core.h b/lib/wp/core.h index 4ce01a22..d2d4cc5f 100644 --- a/lib/wp/core.h +++ b/lib/wp/core.h @@ -41,7 +41,7 @@ WpCore * wp_core_new (GMainContext *context, WpProperties * properties); GMainContext * wp_core_get_context (WpCore * self); GSource * wp_core_idle_add (WpCore * self, GSourceFunc function, gpointer data); -void wp_core_sync (WpCore * self, GCancellable * cancellable, +gboolean wp_core_sync (WpCore * self, GCancellable * cancellable, GAsyncReadyCallback callback, gpointer user_data); struct pw_core * wp_core_get_pw_core (WpCore * self); struct pw_remote * wp_core_get_pw_remote (WpCore * self);