mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-04 14:20:27 +01:00
endpoint: refactor into WpEndpoint & WpImplEndpoint
This commit is contained in:
parent
8e50fab112
commit
c9cab2cd53
7 changed files with 483 additions and 634 deletions
|
|
@ -413,7 +413,7 @@ wp_core_class_init (WpCoreClass * klass)
|
|||
to autodetect the GType of proxies created through wp_proxy_new_global() */
|
||||
g_type_ensure (WP_TYPE_CLIENT);
|
||||
g_type_ensure (WP_TYPE_DEVICE);
|
||||
g_type_ensure (WP_TYPE_PROXY_ENDPOINT);
|
||||
g_type_ensure (WP_TYPE_ENDPOINT);
|
||||
g_type_ensure (WP_TYPE_LINK);
|
||||
g_type_ensure (WP_TYPE_NODE);
|
||||
g_type_ensure (WP_TYPE_PORT);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -9,15 +9,10 @@
|
|||
#ifndef __WIREPLUMBER_ENDPOINT_H__
|
||||
#define __WIREPLUMBER_ENDPOINT_H__
|
||||
|
||||
#include "exported.h"
|
||||
#include "proxy.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define WP_TYPE_ENDPOINT (wp_endpoint_get_type ())
|
||||
WP_API
|
||||
G_DECLARE_INTERFACE (WpEndpoint, wp_endpoint, WP, ENDPOINT, GObject)
|
||||
|
||||
/**
|
||||
* WpDirection:
|
||||
* @WP_DIRECTION_INPUT: a sink, consuming input
|
||||
|
|
@ -36,9 +31,19 @@ typedef enum {
|
|||
WP_ENDPOINT_CONTROL_CHANNEL_VOLUMES = 0x10008 /* SPA_PROP_channelVolumes */,
|
||||
} WpEndpointControl;
|
||||
|
||||
struct _WpEndpointInterface
|
||||
typedef enum { /*< flags >*/
|
||||
WP_ENDPOINT_FEATURE_CONTROLS = WP_PROXY_FEATURE_LAST,
|
||||
} WpEndpointFeatures;
|
||||
|
||||
/* WpEndpoint */
|
||||
|
||||
#define WP_TYPE_ENDPOINT (wp_endpoint_get_type ())
|
||||
WP_API
|
||||
G_DECLARE_DERIVABLE_TYPE (WpEndpoint, wp_endpoint, WP, ENDPOINT, WpProxy)
|
||||
|
||||
struct _WpEndpointClass
|
||||
{
|
||||
GTypeInterface parent;
|
||||
WpProxyClass parent_class;
|
||||
|
||||
const gchar * (*get_name) (WpEndpoint * self);
|
||||
const gchar * (*get_media_class) (WpEndpoint * self);
|
||||
|
|
@ -47,8 +52,6 @@ struct _WpEndpointInterface
|
|||
const struct spa_pod * (*get_control) (WpEndpoint * self, guint32 control_id);
|
||||
gboolean (*set_control) (WpEndpoint * self, guint32 control_id,
|
||||
const struct spa_pod * value);
|
||||
|
||||
// void (*create_link) (WpEndpoint * self, WpProperties * props);
|
||||
};
|
||||
|
||||
WP_API
|
||||
|
|
@ -92,70 +95,45 @@ WP_API
|
|||
gboolean wp_endpoint_set_control_float (WpEndpoint * self, guint32 control_id,
|
||||
gfloat value);
|
||||
|
||||
// void wp_endpoint_create_link (WpEndpoint * self, WpProperties * props);
|
||||
/* WpImplEndpoint */
|
||||
|
||||
/* proxy */
|
||||
|
||||
typedef enum { /*< flags >*/
|
||||
WP_PROXY_ENDPOINT_FEATURE_CONTROLS = WP_PROXY_FEATURE_LAST,
|
||||
} WpProxyEndpointFeatures;
|
||||
|
||||
#define WP_TYPE_PROXY_ENDPOINT (wp_proxy_endpoint_get_type ())
|
||||
#define WP_TYPE_IMPL_ENDPOINT (wp_impl_endpoint_get_type ())
|
||||
WP_API
|
||||
G_DECLARE_FINAL_TYPE (WpProxyEndpoint, wp_proxy_endpoint,
|
||||
WP, PROXY_ENDPOINT, WpProxy)
|
||||
G_DECLARE_DERIVABLE_TYPE (WpImplEndpoint, wp_impl_endpoint,
|
||||
WP, IMPL_ENDPOINT, WpEndpoint)
|
||||
|
||||
/* exported */
|
||||
|
||||
#define WP_TYPE_EXPORTED_ENDPOINT (wp_exported_endpoint_get_type ())
|
||||
WP_API
|
||||
G_DECLARE_DERIVABLE_TYPE (WpExportedEndpoint, wp_exported_endpoint,
|
||||
WP, EXPORTED_ENDPOINT, WpExported)
|
||||
|
||||
struct _WpExportedEndpointClass
|
||||
struct _WpImplEndpointClass
|
||||
{
|
||||
WpExportedClass parent_class;
|
||||
WpEndpointClass parent_class;
|
||||
};
|
||||
|
||||
WP_API
|
||||
WpExportedEndpoint * wp_exported_endpoint_new (WpCore * core);
|
||||
WpImplEndpoint * wp_impl_endpoint_new (WpCore * core);
|
||||
|
||||
WP_API
|
||||
guint32 wp_exported_endpoint_get_global_id (WpExportedEndpoint * self);
|
||||
|
||||
WP_API
|
||||
WpProperties * wp_exported_endpoint_get_properties (WpExportedEndpoint * self);
|
||||
|
||||
WP_API
|
||||
void wp_exported_endpoint_set_property (WpExportedEndpoint * self,
|
||||
void wp_impl_endpoint_set_property (WpImplEndpoint * self,
|
||||
const gchar * key, const gchar * value);
|
||||
|
||||
WP_API
|
||||
void wp_exported_endpoint_update_properties (WpExportedEndpoint * self,
|
||||
void wp_impl_endpoint_update_properties (WpImplEndpoint * self,
|
||||
WpProperties * updates);
|
||||
|
||||
WP_API
|
||||
void wp_exported_endpoint_set_name (WpExportedEndpoint * self,
|
||||
void wp_impl_endpoint_set_name (WpImplEndpoint * self,
|
||||
const gchar * name);
|
||||
|
||||
WP_API
|
||||
void wp_exported_endpoint_set_media_class (WpExportedEndpoint * self,
|
||||
void wp_impl_endpoint_set_media_class (WpImplEndpoint * self,
|
||||
const gchar * media_class);
|
||||
|
||||
WP_API
|
||||
void wp_exported_endpoint_set_direction (WpExportedEndpoint * self,
|
||||
void wp_impl_endpoint_set_direction (WpImplEndpoint * self,
|
||||
WpDirection dir);
|
||||
|
||||
WP_API
|
||||
void wp_exported_endpoint_register_control (WpExportedEndpoint * self,
|
||||
void wp_impl_endpoint_register_control (WpImplEndpoint * self,
|
||||
WpEndpointControl control);
|
||||
|
||||
// void wp_exported_endpoint_register_stream (WpExportedEndpoint * self,
|
||||
// WpExportedEndpointStream * stream);
|
||||
// void wp_exported_endpoint_remove_stream (WpExportedEndpoint * self,
|
||||
// WpExportedEndpointStream * stream);
|
||||
// GPtrArray * wp_exported_endpoint_list_streams (WpExportedEndpoint * self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ struct _WpPwAudioSoftdspEndpoint
|
|||
WpAudioStream *adapter;
|
||||
GPtrArray *converters;
|
||||
|
||||
WpExportedEndpoint *exported_ep;
|
||||
WpImplEndpoint *impl_ep;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -116,7 +116,7 @@ endpoint_get_global_id (WpBaseEndpoint *ep)
|
|||
{
|
||||
WpPwAudioSoftdspEndpoint *self = WP_PW_AUDIO_SOFTDSP_ENDPOINT (ep);
|
||||
|
||||
return wp_exported_endpoint_get_global_id (self->exported_ep);
|
||||
return wp_proxy_get_bound_id (WP_PROXY (self->impl_ep));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -169,19 +169,19 @@ on_adapter_control_changed (WpAudioStream * s, guint32 control_id,
|
|||
{
|
||||
/* block to avoid recursion - WpEndpoint emits the "control-changed"
|
||||
signal when we change the value here */
|
||||
g_signal_handlers_block_by_func (self->exported_ep,
|
||||
g_signal_handlers_block_by_func (self->impl_ep,
|
||||
on_exported_control_changed, self);
|
||||
|
||||
switch (control_id) {
|
||||
case WP_ENDPOINT_CONTROL_VOLUME: {
|
||||
gfloat vol = wp_audio_stream_get_volume (s);
|
||||
wp_endpoint_set_control_float (WP_ENDPOINT (self->exported_ep),
|
||||
wp_endpoint_set_control_float (WP_ENDPOINT (self->impl_ep),
|
||||
control_id, vol);
|
||||
break;
|
||||
}
|
||||
case WP_ENDPOINT_CONTROL_MUTE: {
|
||||
gboolean m = wp_audio_stream_get_mute (s);
|
||||
wp_endpoint_set_control_boolean (WP_ENDPOINT (self->exported_ep),
|
||||
wp_endpoint_set_control_boolean (WP_ENDPOINT (self->impl_ep),
|
||||
control_id, m);
|
||||
break;
|
||||
}
|
||||
|
|
@ -189,12 +189,12 @@ on_adapter_control_changed (WpAudioStream * s, guint32 control_id,
|
|||
break;
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (self->exported_ep,
|
||||
g_signal_handlers_unblock_by_func (self->impl_ep,
|
||||
on_exported_control_changed, self);
|
||||
}
|
||||
|
||||
static void
|
||||
on_endpoint_exported (GObject * exported, GAsyncResult *res, gpointer data)
|
||||
on_endpoint_exported (GObject * impl_ep, GAsyncResult *res, gpointer data)
|
||||
{
|
||||
WpPwAudioSoftdspEndpoint *self = WP_PW_AUDIO_SOFTDSP_ENDPOINT (data);
|
||||
GError *error = NULL;
|
||||
|
|
@ -202,7 +202,7 @@ on_endpoint_exported (GObject * exported, GAsyncResult *res, gpointer data)
|
|||
g_return_if_fail (self->init_task);
|
||||
|
||||
/* Get the object */
|
||||
wp_exported_export_finish (WP_EXPORTED (exported), res, &error);
|
||||
wp_proxy_augment_finish (WP_PROXY (impl_ep), res, &error);
|
||||
if (error) {
|
||||
g_warning ("WpPwAudioSoftdspEndpoint:%p Aborting construction", self);
|
||||
g_task_return_error (self->init_task, error);
|
||||
|
|
@ -221,15 +221,15 @@ do_export (WpPwAudioSoftdspEndpoint *self)
|
|||
g_autoptr (WpProperties) props = NULL;
|
||||
g_autoptr (WpProperties) extra_props = NULL;
|
||||
|
||||
g_return_if_fail (!self->exported_ep);
|
||||
g_return_if_fail (!self->impl_ep);
|
||||
|
||||
self->exported_ep = wp_exported_endpoint_new (core);
|
||||
self->impl_ep = wp_impl_endpoint_new (core);
|
||||
|
||||
wp_exported_endpoint_register_control (self->exported_ep,
|
||||
wp_impl_endpoint_register_control (self->impl_ep,
|
||||
WP_ENDPOINT_CONTROL_VOLUME);
|
||||
wp_exported_endpoint_register_control (self->exported_ep,
|
||||
wp_impl_endpoint_register_control (self->impl_ep,
|
||||
WP_ENDPOINT_CONTROL_MUTE);
|
||||
// wp_exported_endpoint_register_control (self->exported_ep,
|
||||
// wp_impl_endpoint_register_control (self->impl_ep,
|
||||
// WP_ENDPOINT_CONTROL_CHANNEL_VOLUMES);
|
||||
|
||||
props = wp_proxy_get_properties (WP_PROXY (self->node));
|
||||
|
|
@ -242,28 +242,28 @@ do_export (WpPwAudioSoftdspEndpoint *self)
|
|||
wp_properties_setf (extra_props, "endpoint.priority", "%d",
|
||||
wp_base_endpoint_get_priority (WP_BASE_ENDPOINT (self)));
|
||||
|
||||
wp_exported_endpoint_update_properties (self->exported_ep, props);
|
||||
wp_exported_endpoint_update_properties (self->exported_ep, extra_props);
|
||||
wp_impl_endpoint_update_properties (self->impl_ep, props);
|
||||
wp_impl_endpoint_update_properties (self->impl_ep, extra_props);
|
||||
|
||||
wp_exported_endpoint_set_name (self->exported_ep,
|
||||
wp_impl_endpoint_set_name (self->impl_ep,
|
||||
wp_base_endpoint_get_name (WP_BASE_ENDPOINT (self)));
|
||||
wp_exported_endpoint_set_media_class (self->exported_ep,
|
||||
wp_impl_endpoint_set_media_class (self->impl_ep,
|
||||
wp_base_endpoint_get_media_class (WP_BASE_ENDPOINT (self)));
|
||||
wp_exported_endpoint_set_direction (self->exported_ep,
|
||||
wp_impl_endpoint_set_direction (self->impl_ep,
|
||||
wp_base_endpoint_get_direction (WP_BASE_ENDPOINT (self)));
|
||||
|
||||
wp_endpoint_set_control_float (WP_ENDPOINT (self->exported_ep),
|
||||
wp_endpoint_set_control_float (WP_ENDPOINT (self->impl_ep),
|
||||
WP_ENDPOINT_CONTROL_VOLUME, wp_audio_stream_get_volume (self->adapter));
|
||||
wp_endpoint_set_control_boolean (WP_ENDPOINT (self->exported_ep),
|
||||
wp_endpoint_set_control_boolean (WP_ENDPOINT (self->impl_ep),
|
||||
WP_ENDPOINT_CONTROL_MUTE, wp_audio_stream_get_mute (self->adapter));
|
||||
|
||||
g_signal_connect_object (self->exported_ep, "control-changed",
|
||||
g_signal_connect_object (self->impl_ep, "control-changed",
|
||||
(GCallback) on_exported_control_changed, self, 0);
|
||||
g_signal_connect_object (self->adapter, "control-changed",
|
||||
(GCallback) on_adapter_control_changed, self, 0);
|
||||
|
||||
wp_exported_export (WP_EXPORTED (self->exported_ep), NULL,
|
||||
on_endpoint_exported, self);
|
||||
wp_proxy_augment (WP_PROXY (self->impl_ep), WP_PROXY_FEATURE_BOUND,
|
||||
NULL, on_endpoint_exported, self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -354,9 +354,7 @@ endpoint_finalize (GObject * object)
|
|||
{
|
||||
WpPwAudioSoftdspEndpoint *self = WP_PW_AUDIO_SOFTDSP_ENDPOINT (object);
|
||||
|
||||
if (self->exported_ep)
|
||||
wp_exported_unexport (WP_EXPORTED (self->exported_ep));
|
||||
g_clear_object (&self->exported_ep);
|
||||
g_clear_object (&self->impl_ep);
|
||||
|
||||
g_clear_pointer(&self->streams, g_variant_unref);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ select_new_default_ep (struct module_data * data, WpDefaultEndpointType type,
|
|||
|
||||
for (guint i = 0; i < arr->len; i++) {
|
||||
WpEndpoint *ep = g_ptr_array_index (arr, i);
|
||||
guint32 id = wp_exported_endpoint_get_global_id (WP_EXPORTED_ENDPOINT (ep));
|
||||
guint32 id = wp_proxy_get_bound_id (WP_PROXY (ep));
|
||||
guint32 priority = 0;
|
||||
const gchar *priority_str;
|
||||
|
||||
|
|
@ -38,8 +38,7 @@ select_new_default_ep (struct module_data * data, WpDefaultEndpointType type,
|
|||
if (g_strcmp0 (media_class, wp_endpoint_get_media_class (ep)) != 0)
|
||||
continue;
|
||||
|
||||
g_autoptr (WpProperties) properties =
|
||||
wp_exported_endpoint_get_properties (WP_EXPORTED_ENDPOINT (ep));
|
||||
g_autoptr (WpProperties) properties = wp_proxy_get_properties (WP_PROXY (ep));
|
||||
|
||||
priority_str = wp_properties_get (properties, "endpoint.priority");
|
||||
if (priority_str)
|
||||
|
|
@ -99,7 +98,7 @@ on_endpoint_removed (WpObjectManager * om, WpEndpoint * ep,
|
|||
else
|
||||
return;
|
||||
|
||||
ep_id = wp_exported_endpoint_get_global_id (WP_EXPORTED_ENDPOINT (ep));
|
||||
ep_id = wp_proxy_get_bound_id (WP_PROXY (ep));
|
||||
def_id = wp_session_get_default_endpoint (WP_SESSION (data->session), type);
|
||||
|
||||
if (ep_id == def_id)
|
||||
|
|
@ -135,6 +134,6 @@ wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
|||
g_signal_connect (data->om, "object-removed",
|
||||
(GCallback) on_endpoint_removed, data);
|
||||
wp_object_manager_add_object_interest (data->om,
|
||||
WP_TYPE_EXPORTED_ENDPOINT, NULL);
|
||||
WP_TYPE_IMPL_ENDPOINT, NULL);
|
||||
wp_core_install_object_manager (core, data->om);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ typedef struct {
|
|||
WpCore *proxy_core;
|
||||
WpObjectManager *proxy_om;
|
||||
|
||||
WpExportedEndpoint *exported_endpoint;
|
||||
WpImplEndpoint *impl_endpoint;
|
||||
WpProxy *proxy_endpoint;
|
||||
|
||||
gint n_events;
|
||||
|
|
@ -109,32 +109,30 @@ test_endpoint_teardown (TestEndpointFixture *self, gconstpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
test_endpoint_basic_exported_object_added (WpObjectManager *om,
|
||||
test_endpoint_basic_impl_object_added (WpObjectManager *om,
|
||||
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
||||
{
|
||||
g_debug ("exported object added");
|
||||
g_debug ("impl object added");
|
||||
|
||||
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
||||
g_assert_true (WP_IS_EXPORTED_ENDPOINT (endpoint));
|
||||
g_assert_true (WP_IS_IMPL_ENDPOINT (endpoint));
|
||||
|
||||
g_assert_null (fixture->exported_endpoint);
|
||||
fixture->exported_endpoint = WP_EXPORTED_ENDPOINT (endpoint);
|
||||
g_assert_null (fixture->impl_endpoint);
|
||||
fixture->impl_endpoint = WP_IMPL_ENDPOINT (endpoint);
|
||||
|
||||
if (++fixture->n_events == 3)
|
||||
g_main_loop_quit (fixture->loop);
|
||||
}
|
||||
|
||||
static void
|
||||
test_endpoint_basic_exported_object_removed (WpObjectManager *om,
|
||||
test_endpoint_basic_impl_object_removed (WpObjectManager *om,
|
||||
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
||||
{
|
||||
g_debug ("exported object removed");
|
||||
g_debug ("impl object removed");
|
||||
|
||||
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
||||
g_assert_true (WP_IS_EXPORTED_ENDPOINT (endpoint));
|
||||
g_assert_true (WP_IS_IMPL_ENDPOINT (endpoint));
|
||||
|
||||
g_assert_nonnull (fixture->exported_endpoint);
|
||||
fixture->exported_endpoint = NULL;
|
||||
g_assert_nonnull (fixture->impl_endpoint);
|
||||
fixture->impl_endpoint = NULL;
|
||||
|
||||
if (++fixture->n_events == 2)
|
||||
g_main_loop_quit (fixture->loop);
|
||||
|
|
@ -147,7 +145,6 @@ test_endpoint_basic_proxy_object_added (WpObjectManager *om,
|
|||
g_debug ("proxy object added");
|
||||
|
||||
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
||||
g_assert_true (WP_IS_PROXY_ENDPOINT (endpoint));
|
||||
|
||||
g_assert_null (fixture->proxy_endpoint);
|
||||
fixture->proxy_endpoint = WP_PROXY (endpoint);
|
||||
|
|
@ -163,7 +160,6 @@ test_endpoint_basic_proxy_object_removed (WpObjectManager *om,
|
|||
g_debug ("proxy object removed");
|
||||
|
||||
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
||||
g_assert_true (WP_IS_PROXY_ENDPOINT (endpoint));
|
||||
|
||||
g_assert_nonnull (fixture->proxy_endpoint);
|
||||
fixture->proxy_endpoint = NULL;
|
||||
|
|
@ -173,17 +169,17 @@ test_endpoint_basic_proxy_object_removed (WpObjectManager *om,
|
|||
}
|
||||
|
||||
static void
|
||||
test_endpoint_basic_export_done (WpExported * endpoint, GAsyncResult * res,
|
||||
test_endpoint_basic_export_done (WpProxy * endpoint, GAsyncResult * res,
|
||||
TestEndpointFixture *fixture)
|
||||
{
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
g_debug ("export done");
|
||||
|
||||
g_assert_true (wp_exported_export_finish (endpoint, res, &error));
|
||||
g_assert_true (wp_proxy_augment_finish (endpoint, res, &error));
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert_true (WP_IS_EXPORTED_ENDPOINT (endpoint));
|
||||
g_assert_true (WP_IS_IMPL_ENDPOINT (endpoint));
|
||||
|
||||
if (++fixture->n_events == 3)
|
||||
g_main_loop_quit (fixture->loop);
|
||||
|
|
@ -217,17 +213,17 @@ test_endpoint_basic_notify_properties (WpEndpoint * endpoint, GParamSpec * param
|
|||
static void
|
||||
test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
||||
{
|
||||
g_autoptr (WpExportedEndpoint) endpoint = NULL;
|
||||
g_autoptr (WpImplEndpoint) endpoint = NULL;
|
||||
gfloat float_value;
|
||||
gboolean boolean_value;
|
||||
|
||||
/* set up the export side */
|
||||
g_signal_connect (fixture->export_om, "object-added",
|
||||
(GCallback) test_endpoint_basic_exported_object_added, fixture);
|
||||
(GCallback) test_endpoint_basic_impl_object_added, fixture);
|
||||
g_signal_connect (fixture->export_om, "object-removed",
|
||||
(GCallback) test_endpoint_basic_exported_object_removed, fixture);
|
||||
(GCallback) test_endpoint_basic_impl_object_removed, fixture);
|
||||
wp_object_manager_add_object_interest (fixture->export_om,
|
||||
WP_TYPE_EXPORTED_ENDPOINT, NULL);
|
||||
WP_TYPE_IMPL_ENDPOINT, NULL);
|
||||
wp_core_install_object_manager (fixture->export_core, fixture->export_om);
|
||||
|
||||
g_assert_true (wp_core_connect (fixture->export_core));
|
||||
|
|
@ -240,16 +236,16 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
wp_object_manager_add_proxy_interest (fixture->proxy_om,
|
||||
PW_TYPE_INTERFACE_Endpoint, NULL,
|
||||
WP_PROXY_FEATURE_INFO | WP_PROXY_FEATURE_BOUND |
|
||||
WP_PROXY_ENDPOINT_FEATURE_CONTROLS);
|
||||
WP_ENDPOINT_FEATURE_CONTROLS);
|
||||
wp_core_install_object_manager (fixture->proxy_core, fixture->proxy_om);
|
||||
|
||||
g_assert_true (wp_core_connect (fixture->proxy_core));
|
||||
|
||||
/* create endpoint */
|
||||
endpoint = wp_exported_endpoint_new (fixture->export_core);
|
||||
wp_exported_endpoint_set_property (endpoint, "test.property", "test-value");
|
||||
wp_exported_endpoint_register_control (endpoint, WP_ENDPOINT_CONTROL_VOLUME);
|
||||
wp_exported_endpoint_register_control (endpoint, WP_ENDPOINT_CONTROL_MUTE);
|
||||
endpoint = wp_impl_endpoint_new (fixture->export_core);
|
||||
wp_impl_endpoint_set_property (endpoint, "test.property", "test-value");
|
||||
wp_impl_endpoint_register_control (endpoint, WP_ENDPOINT_CONTROL_VOLUME);
|
||||
wp_impl_endpoint_register_control (endpoint, WP_ENDPOINT_CONTROL_MUTE);
|
||||
g_assert_true (wp_endpoint_set_control_float (WP_ENDPOINT (endpoint),
|
||||
WP_ENDPOINT_CONTROL_VOLUME, 0.7f));
|
||||
g_assert_true (wp_endpoint_set_control_boolean (WP_ENDPOINT (endpoint),
|
||||
|
|
@ -258,7 +254,7 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
/* verify properties are set before export */
|
||||
{
|
||||
g_autoptr (WpProperties) props =
|
||||
wp_exported_endpoint_get_properties (endpoint);
|
||||
wp_proxy_get_properties (WP_PROXY (endpoint));
|
||||
g_assert_cmpstr (wp_properties_get (props, "test.property"), ==,
|
||||
"test-value");
|
||||
}
|
||||
|
|
@ -270,16 +266,16 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
g_assert_cmpint (boolean_value, ==, TRUE);
|
||||
|
||||
/* do export */
|
||||
wp_exported_export (WP_EXPORTED (endpoint), NULL,
|
||||
wp_proxy_augment (WP_PROXY (endpoint), WP_PROXY_FEATURE_BOUND, NULL,
|
||||
(GAsyncReadyCallback) test_endpoint_basic_export_done, fixture);
|
||||
|
||||
/* run until objects are created and features are cached */
|
||||
fixture->n_events = 0;
|
||||
g_main_loop_run (fixture->loop);
|
||||
g_assert_cmpint (fixture->n_events, ==, 3);
|
||||
g_assert_nonnull (fixture->exported_endpoint);
|
||||
g_assert_nonnull (fixture->impl_endpoint);
|
||||
g_assert_nonnull (fixture->proxy_endpoint);
|
||||
g_assert_true (fixture->exported_endpoint == endpoint);
|
||||
g_assert_true (fixture->impl_endpoint == endpoint);
|
||||
|
||||
/* test round 1: verify the values on the proxy */
|
||||
|
||||
|
|
@ -287,10 +283,10 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
WP_PROXY_FEATURE_PW_PROXY |
|
||||
WP_PROXY_FEATURE_INFO |
|
||||
WP_PROXY_FEATURE_BOUND |
|
||||
WP_PROXY_ENDPOINT_FEATURE_CONTROLS);
|
||||
WP_ENDPOINT_FEATURE_CONTROLS);
|
||||
|
||||
g_assert_cmpuint (wp_proxy_get_bound_id (fixture->proxy_endpoint), ==,
|
||||
wp_exported_endpoint_get_global_id (endpoint));
|
||||
wp_proxy_get_bound_id (WP_PROXY (endpoint)));
|
||||
|
||||
{
|
||||
g_autoptr (WpProperties) props =
|
||||
|
|
@ -345,7 +341,7 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
g_assert_cmpfloat_with_epsilon (float_value, 1.0f, 0.001);
|
||||
g_assert_cmpint (boolean_value, ==, TRUE);
|
||||
|
||||
/* change control on the exported */
|
||||
/* change control on the impl */
|
||||
fixture->n_events = 0;
|
||||
g_assert_true (wp_endpoint_set_control_boolean (WP_ENDPOINT (endpoint),
|
||||
WP_ENDPOINT_CONTROL_MUTE, FALSE));
|
||||
|
|
@ -372,9 +368,9 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
g_assert_cmpfloat_with_epsilon (float_value, 1.0f, 0.001);
|
||||
g_assert_cmpint (boolean_value, ==, FALSE);
|
||||
|
||||
/* change a property on the exported */
|
||||
/* change a property on the impl */
|
||||
fixture->n_events = 0;
|
||||
wp_exported_endpoint_set_property (endpoint, "test.property", "changed-value");
|
||||
wp_impl_endpoint_set_property (endpoint, "test.property", "changed-value");
|
||||
|
||||
/* run until the change is on both sides */
|
||||
g_main_loop_run (fixture->loop);
|
||||
|
|
@ -384,7 +380,7 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
|
||||
{
|
||||
g_autoptr (WpProperties) props =
|
||||
wp_exported_endpoint_get_properties (endpoint);
|
||||
wp_proxy_get_properties (WP_PROXY (endpoint));
|
||||
g_assert_cmpstr (wp_properties_get (props, "test.property"), ==,
|
||||
"changed-value");
|
||||
}
|
||||
|
|
@ -395,14 +391,14 @@ test_endpoint_basic (TestEndpointFixture *fixture, gconstpointer data)
|
|||
"changed-value");
|
||||
}
|
||||
|
||||
/* unexport */
|
||||
/* destroy impl endpoint */
|
||||
fixture->n_events = 0;
|
||||
wp_exported_unexport (WP_EXPORTED (endpoint));
|
||||
g_clear_object (&endpoint);
|
||||
|
||||
/* run until objects are destroyed */
|
||||
g_main_loop_run (fixture->loop);
|
||||
g_assert_cmpint (fixture->n_events, ==, 2);
|
||||
g_assert_null (fixture->exported_endpoint);
|
||||
g_assert_null (fixture->impl_endpoint);
|
||||
g_assert_null (fixture->proxy_endpoint);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ list_endpoints (WpObjectManager * om, struct WpCliData * d)
|
|||
session = WP_SESSION (g_object_ref (g_ptr_array_index (arr, 0)));
|
||||
g_clear_pointer (&arr, g_ptr_array_unref);
|
||||
|
||||
arr = wp_object_manager_get_objects (om, WP_TYPE_PROXY_ENDPOINT);
|
||||
arr = wp_object_manager_get_objects (om, WP_TYPE_ENDPOINT);
|
||||
|
||||
g_print ("Audio capture devices:\n");
|
||||
for (i = 0; i < arr->len; i++) {
|
||||
|
|
@ -118,7 +118,7 @@ set_default (WpObjectManager * om, struct WpCliData * d)
|
|||
return;
|
||||
}
|
||||
|
||||
arr = wp_object_manager_get_objects (om, WP_TYPE_PROXY_ENDPOINT);
|
||||
arr = wp_object_manager_get_objects (om, WP_TYPE_ENDPOINT);
|
||||
|
||||
for (i = 0; i < arr->len; i++) {
|
||||
WpEndpoint *ep = g_ptr_array_index (arr, i);
|
||||
|
|
@ -152,7 +152,7 @@ set_volume (WpObjectManager * om, struct WpCliData * d)
|
|||
g_autoptr (GPtrArray) arr = NULL;
|
||||
guint i;
|
||||
|
||||
arr = wp_object_manager_get_objects (om, WP_TYPE_PROXY_ENDPOINT);
|
||||
arr = wp_object_manager_get_objects (om, WP_TYPE_ENDPOINT);
|
||||
|
||||
for (i = 0; i < arr->len; i++) {
|
||||
WpEndpoint *ep = g_ptr_array_index (arr, i);
|
||||
|
|
@ -261,7 +261,7 @@ main (gint argc, gchar **argv)
|
|||
if (argc == 2 && !g_strcmp0 (argv[1], "ls-endpoints")) {
|
||||
wp_object_manager_add_proxy_interest (om, PW_TYPE_INTERFACE_Endpoint,
|
||||
NULL, WP_PROXY_FEATURE_INFO | WP_PROXY_FEATURE_BOUND |
|
||||
WP_PROXY_ENDPOINT_FEATURE_CONTROLS);
|
||||
WP_ENDPOINT_FEATURE_CONTROLS);
|
||||
wp_object_manager_add_proxy_interest (om, PW_TYPE_INTERFACE_Session,
|
||||
NULL, WP_PROXY_FEATURE_INFO | WP_PROXY_FEATURE_BOUND |
|
||||
WP_SESSION_FEATURE_DEFAULT_ENDPOINT);
|
||||
|
|
@ -295,7 +295,7 @@ main (gint argc, gchar **argv)
|
|||
|
||||
wp_object_manager_add_proxy_interest (om, PW_TYPE_INTERFACE_Endpoint,
|
||||
NULL, WP_PROXY_FEATURE_INFO | WP_PROXY_FEATURE_BOUND |
|
||||
WP_PROXY_ENDPOINT_FEATURE_CONTROLS);
|
||||
WP_ENDPOINT_FEATURE_CONTROLS);
|
||||
|
||||
data.params.set_volume.id = id;
|
||||
data.params.set_volume.volume = volume;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue