lib: remove wp_proxy_sync in favor of wp_core_sync
They are equivalent, there is no real benefit in having both
This commit is contained in:
@@ -545,6 +545,15 @@ wp_core_sync (WpCore * self, GCancellable * cancellable,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
wp_core_sync_finish (WpCore * self, GAsyncResult * res, GError ** error)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (WP_IS_CORE (self), FALSE);
|
||||||
|
g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
|
||||||
|
|
||||||
|
return g_task_propagate_boolean (G_TASK (res), error);
|
||||||
|
}
|
||||||
|
|
||||||
WpProxy *
|
WpProxy *
|
||||||
wp_core_export_object (WpCore * self, const gchar * interface_type,
|
wp_core_export_object (WpCore * self, const gchar * interface_type,
|
||||||
gpointer local_object, WpProperties * properties)
|
gpointer local_object, WpProperties * properties)
|
||||||
|
@@ -53,6 +53,10 @@ WP_API
|
|||||||
gboolean wp_core_sync (WpCore * self, GCancellable * cancellable,
|
gboolean wp_core_sync (WpCore * self, GCancellable * cancellable,
|
||||||
GAsyncReadyCallback callback, gpointer user_data);
|
GAsyncReadyCallback callback, gpointer user_data);
|
||||||
|
|
||||||
|
WP_API
|
||||||
|
gboolean wp_core_sync_finish (WpCore * self, GAsyncResult * res,
|
||||||
|
GError ** error);
|
||||||
|
|
||||||
/* Object */
|
/* Object */
|
||||||
|
|
||||||
WP_API
|
WP_API
|
||||||
|
@@ -155,16 +155,17 @@ wp_proxy_node_get_properties (WpProxyNode * self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enum_params_done (WpProxy * proxy, GAsyncResult * res, gpointer data)
|
enum_params_done (WpCore * core, GAsyncResult * res, gpointer data)
|
||||||
{
|
{
|
||||||
int seq = GPOINTER_TO_INT (data);
|
int seq = GPOINTER_TO_INT (g_task_get_source_tag (G_TASK (data)));
|
||||||
g_autoptr (GError) error = NULL;
|
WpProxy *proxy = g_task_get_source_object (G_TASK (data));
|
||||||
g_autoptr (GTask) task = NULL;
|
g_autoptr (GTask) task = NULL;
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
/* finish the sync task */
|
/* finish the sync task */
|
||||||
wp_proxy_sync_finish (proxy, res, &error);
|
wp_core_sync_finish (core, res, &error);
|
||||||
|
|
||||||
/* find the enum params task and return from it */
|
/* find the enum params task in the hash table to steal the reference */
|
||||||
task = wp_proxy_find_async_task (proxy, seq, TRUE);
|
task = wp_proxy_find_async_task (proxy, seq, TRUE);
|
||||||
g_return_if_fail (task != NULL);
|
g_return_if_fail (task != NULL);
|
||||||
|
|
||||||
@@ -202,11 +203,14 @@ wp_proxy_node_enum_params_collect (WpProxyNode * self,
|
|||||||
g_strerror (-seq));
|
g_strerror (-seq));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wp_proxy_register_async_task (WP_PROXY (self), seq, g_steal_pointer (&task));
|
wp_proxy_register_async_task (WP_PROXY (self), seq, g_object_ref (task));
|
||||||
|
|
||||||
|
g_task_set_source_tag (task, GINT_TO_POINTER (seq));
|
||||||
|
|
||||||
/* call sync */
|
/* call sync */
|
||||||
wp_proxy_sync (WP_PROXY (self), cancellable,
|
g_autoptr (WpCore) core = wp_proxy_get_core (WP_PROXY (self));
|
||||||
(GAsyncReadyCallback) enum_params_done, GINT_TO_POINTER (seq));
|
wp_core_sync (core, cancellable, (GAsyncReadyCallback) enum_params_done,
|
||||||
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -156,16 +156,17 @@ wp_proxy_port_get_properties (WpProxyPort * self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enum_params_done (WpProxy * proxy, GAsyncResult * res, gpointer data)
|
enum_params_done (WpCore * core, GAsyncResult * res, gpointer data)
|
||||||
{
|
{
|
||||||
int seq = GPOINTER_TO_INT (data);
|
int seq = GPOINTER_TO_INT (g_task_get_source_tag (G_TASK (data)));
|
||||||
g_autoptr (GError) error = NULL;
|
WpProxy *proxy = g_task_get_source_object (G_TASK (data));
|
||||||
g_autoptr (GTask) task = NULL;
|
g_autoptr (GTask) task = NULL;
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
/* finish the sync task */
|
/* finish the sync task */
|
||||||
wp_proxy_sync_finish (proxy, res, &error);
|
wp_core_sync_finish (core, res, &error);
|
||||||
|
|
||||||
/* find the enum params task and return from it */
|
/* find the enum params task in the hash table to steal the reference */
|
||||||
task = wp_proxy_find_async_task (proxy, seq, TRUE);
|
task = wp_proxy_find_async_task (proxy, seq, TRUE);
|
||||||
g_return_if_fail (task != NULL);
|
g_return_if_fail (task != NULL);
|
||||||
|
|
||||||
@@ -203,11 +204,14 @@ wp_proxy_port_enum_params_collect (WpProxyPort * self,
|
|||||||
g_strerror (-seq));
|
g_strerror (-seq));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wp_proxy_register_async_task (WP_PROXY (self), seq, g_steal_pointer (&task));
|
wp_proxy_register_async_task (WP_PROXY (self), seq, g_object_ref (task));
|
||||||
|
|
||||||
|
g_task_set_source_tag (task, GINT_TO_POINTER (seq));
|
||||||
|
|
||||||
/* call sync */
|
/* call sync */
|
||||||
wp_proxy_sync (WP_PROXY (self), cancellable,
|
g_autoptr (WpCore) core = wp_proxy_get_core (WP_PROXY (self));
|
||||||
(GAsyncReadyCallback) enum_params_done, GINT_TO_POINTER (seq));
|
wp_core_sync (core, cancellable, (GAsyncReadyCallback) enum_params_done,
|
||||||
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -728,46 +728,6 @@ wp_proxy_get_pw_proxy (WpProxy * self)
|
|||||||
return priv->pw_proxy;
|
return priv->pw_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
wp_proxy_sync (WpProxy * self, GCancellable * cancellable,
|
|
||||||
GAsyncReadyCallback callback, gpointer user_data)
|
|
||||||
{
|
|
||||||
WpProxyPrivate *priv;
|
|
||||||
g_autoptr (GTask) task = NULL;
|
|
||||||
int seq;
|
|
||||||
|
|
||||||
g_return_if_fail (WP_IS_PROXY (self));
|
|
||||||
|
|
||||||
priv = wp_proxy_get_instance_private (self);
|
|
||||||
task = g_task_new (self, cancellable, callback, user_data);
|
|
||||||
|
|
||||||
if (G_UNLIKELY (!priv->pw_proxy)) {
|
|
||||||
g_warn_if_reached ();
|
|
||||||
g_task_return_new_error (task, WP_DOMAIN_LIBRARY,
|
|
||||||
WP_LIBRARY_ERROR_INVARIANT, "No pipewire proxy");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
seq = pw_proxy_sync (priv->pw_proxy, 0);
|
|
||||||
if (G_UNLIKELY (seq < 0)) {
|
|
||||||
g_task_return_new_error (task, WP_DOMAIN_LIBRARY,
|
|
||||||
WP_LIBRARY_ERROR_OPERATION_FAILED, "pw_proxy_sync failed: %s",
|
|
||||||
g_strerror (-seq));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_proxy_register_async_task (self, seq, g_steal_pointer (&task));
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
wp_proxy_sync_finish (WpProxy * self, GAsyncResult * res, GError ** error)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (WP_IS_PROXY (self), FALSE);
|
|
||||||
g_return_val_if_fail (g_task_is_valid (res, self), FALSE);
|
|
||||||
|
|
||||||
return g_task_propagate_boolean (G_TASK (res), error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wp_proxy_register_async_task: (skip)
|
* wp_proxy_register_async_task: (skip)
|
||||||
*/
|
*/
|
||||||
|
@@ -84,14 +84,6 @@ guint32 wp_proxy_get_interface_version (WpProxy * self);
|
|||||||
WP_API
|
WP_API
|
||||||
struct pw_proxy * wp_proxy_get_pw_proxy (WpProxy * self);
|
struct pw_proxy * wp_proxy_get_pw_proxy (WpProxy * self);
|
||||||
|
|
||||||
WP_API
|
|
||||||
void wp_proxy_sync (WpProxy * self, GCancellable * cancellable,
|
|
||||||
GAsyncReadyCallback callback, gpointer user_data);
|
|
||||||
|
|
||||||
WP_API
|
|
||||||
gboolean wp_proxy_sync_finish (WpProxy * self, GAsyncResult * res,
|
|
||||||
GError ** error);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -107,7 +107,7 @@ wp_audio_convert_event_info (WpProxyNode * proxy, GParamSpec *spec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_audio_convert_proxy_done (WpProxy *proxy, GAsyncResult *res,
|
on_audio_convert_core_done (WpCore *core, GAsyncResult *res,
|
||||||
WpAudioConvert *self)
|
WpAudioConvert *self)
|
||||||
{
|
{
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
@@ -118,7 +118,7 @@ on_audio_convert_proxy_done (WpProxy *proxy, GAsyncResult *res,
|
|||||||
struct spa_pod *format;
|
struct spa_pod *format;
|
||||||
struct spa_pod *param;
|
struct spa_pod *param;
|
||||||
|
|
||||||
wp_proxy_sync_finish (proxy, res, &error);
|
wp_core_sync_finish (core, res, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_message("WpAudioConvert:%p initial sync failed: %s", self, error->message);
|
g_message("WpAudioConvert:%p initial sync failed: %s", self, error->message);
|
||||||
wp_audio_stream_init_task_finish (WP_AUDIO_STREAM (self),
|
wp_audio_stream_init_task_finish (WP_AUDIO_STREAM (self),
|
||||||
@@ -190,8 +190,8 @@ wp_audio_convert_init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
cancellable, callback, data);
|
cancellable, callback, data);
|
||||||
|
|
||||||
/* Register a callback to be called after all the initialization is done */
|
/* Register a callback to be called after all the initialization is done */
|
||||||
wp_proxy_sync (proxy, NULL,
|
wp_core_sync (core, NULL,
|
||||||
(GAsyncReadyCallback) on_audio_convert_proxy_done, self);
|
(GAsyncReadyCallback) on_audio_convert_core_done, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -85,17 +85,6 @@ test_proxy_teardown (TestProxyFixture *self, gconstpointer user_data)
|
|||||||
wp_test_server_teardown (&self->server);
|
wp_test_server_teardown (&self->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
test_proxy_basic_done (WpProxy *proxy, GAsyncResult *res,
|
|
||||||
TestProxyFixture *fixture)
|
|
||||||
{
|
|
||||||
g_autoptr (GError) error = NULL;
|
|
||||||
g_assert_true (wp_proxy_sync_finish (proxy, res, &error));
|
|
||||||
g_assert_no_error (error);
|
|
||||||
|
|
||||||
g_main_loop_quit (fixture->loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_proxy_basic_augmented (WpProxy *proxy, GAsyncResult *res,
|
test_proxy_basic_augmented (WpProxy *proxy, GAsyncResult *res,
|
||||||
TestProxyFixture *fixture)
|
TestProxyFixture *fixture)
|
||||||
@@ -107,8 +96,7 @@ test_proxy_basic_augmented (WpProxy *proxy, GAsyncResult *res,
|
|||||||
g_assert_true (wp_proxy_get_features (proxy) & WP_PROXY_FEATURE_PW_PROXY);
|
g_assert_true (wp_proxy_get_features (proxy) & WP_PROXY_FEATURE_PW_PROXY);
|
||||||
g_assert_nonnull (wp_proxy_get_pw_proxy (proxy));
|
g_assert_nonnull (wp_proxy_get_pw_proxy (proxy));
|
||||||
|
|
||||||
wp_proxy_sync (proxy, NULL, (GAsyncReadyCallback) test_proxy_basic_done,
|
g_main_loop_quit (fixture->loop);
|
||||||
fixture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user