mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-02 07:28:02 +02:00
m-device-activation: don't set device routes
This is already done by module-default-routes
This commit is contained in:
parent
ee87161d29
commit
22dbdea894
1 changed files with 1 additions and 79 deletions
|
|
@ -17,7 +17,6 @@ struct _WpDeviceActivation
|
|||
WpPlugin parent;
|
||||
|
||||
GWeakRef default_profile;
|
||||
GWeakRef default_routes;
|
||||
WpObjectManager *plugins_om;
|
||||
WpObjectManager *devices_om;
|
||||
};
|
||||
|
|
@ -26,67 +25,6 @@ G_DECLARE_FINAL_TYPE (WpDeviceActivation, wp_device_activation, WP,
|
|||
DEVICE_ACTIVATION, WpPlugin)
|
||||
G_DEFINE_TYPE (WpDeviceActivation, wp_device_activation, WP_TYPE_PLUGIN)
|
||||
|
||||
static void
|
||||
set_device_route (WpDeviceActivation *self, WpPipewireObject *device,
|
||||
gint index, gint device_id)
|
||||
{
|
||||
g_return_if_fail (device);
|
||||
|
||||
/* Set route */
|
||||
wp_pipewire_object_set_param (device, "Route", 0,
|
||||
wp_spa_pod_new_object (
|
||||
"Spa:Pod:Object:Param:Route", "Route",
|
||||
"index", "i", index,
|
||||
"device", "i", device_id,
|
||||
NULL));
|
||||
wp_info_object (self, "route %d set on device " WP_OBJECT_FORMAT, index,
|
||||
WP_OBJECT_ARGS (device));
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_enum_route_done (WpPipewireObject *proxy, GAsyncResult *res,
|
||||
WpDeviceActivation *self)
|
||||
{
|
||||
g_autoptr (WpIterator) routes = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr (WpPlugin) dr = g_weak_ref_get (&self->default_routes);
|
||||
GHashTable *default_routes = NULL;
|
||||
|
||||
/* Finish */
|
||||
routes = wp_pipewire_object_enum_params_finish (proxy, res, &error);
|
||||
if (error) {
|
||||
wp_warning_object (self, "failed to enum routes on device");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the default route name if default-route module is loaded */
|
||||
if (dr)
|
||||
g_signal_emit_by_name (dr, "get-routes", WP_DEVICE (proxy), &default_routes);
|
||||
|
||||
/* Find the route index and device ID */
|
||||
if (default_routes) {
|
||||
g_auto (GValue) item = G_VALUE_INIT;
|
||||
for (; wp_iterator_next (routes, &item); g_value_unset (&item)) {
|
||||
WpSpaPod *pod = g_value_get_boxed (&item);
|
||||
const gchar *n = NULL;
|
||||
gpointer device_id;
|
||||
gint i = 0;
|
||||
|
||||
/* Parse route */
|
||||
if (!wp_spa_pod_get_object (pod, NULL,
|
||||
"index", "i", &i,
|
||||
"name", "s", &n,
|
||||
NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Set the route */
|
||||
if (g_hash_table_lookup_extended (default_routes, n, NULL, &device_id))
|
||||
set_device_route (self, proxy, i, GPOINTER_TO_INT (device_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_device_profile (WpDeviceActivation *self, WpPipewireObject *device, gint index)
|
||||
{
|
||||
|
|
@ -159,14 +97,6 @@ handle_device_profiles (WpDeviceActivation *self, WpPipewireObject *proxy,
|
|||
/* Set the profile */
|
||||
if (index >= 0)
|
||||
set_device_profile (self, proxy, index);
|
||||
|
||||
/*
|
||||
* Enum available routes
|
||||
* This is done after setting the profile as a profile change can change the
|
||||
* current route (this is f.e. the case with Alsa ACP devices)
|
||||
*/
|
||||
wp_pipewire_object_enum_params (proxy, "EnumRoute", NULL, NULL,
|
||||
(GAsyncReadyCallback) on_device_enum_route_done, self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -188,7 +118,6 @@ on_plugin_added (WpObjectManager *om, WpPlugin *plugin, gpointer d)
|
|||
{
|
||||
WpDeviceActivation *self = WP_DEVICE_ACTIVATION (d);
|
||||
g_autoptr (WpPlugin) dp = g_weak_ref_get (&self->default_profile);
|
||||
g_autoptr (WpPlugin) dr = g_weak_ref_get (&self->default_routes);
|
||||
const gchar *name = wp_plugin_get_name (plugin);
|
||||
|
||||
if (g_strcmp0 (name, "default-profile") == 0) {
|
||||
|
|
@ -196,11 +125,6 @@ on_plugin_added (WpObjectManager *om, WpPlugin *plugin, gpointer d)
|
|||
wp_warning_object (self, "skipping additional default profile plugin");
|
||||
else
|
||||
g_weak_ref_set (&self->default_profile, plugin);
|
||||
} else if (g_strcmp0 (name, "default-routes") == 0) {
|
||||
if (dr)
|
||||
wp_warning_object (self, "skipping additional default routes plugin");
|
||||
else
|
||||
g_weak_ref_set (&self->default_routes, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -213,8 +137,7 @@ wp_device_activation_enable (WpPlugin * plugin, WpTransition * transition)
|
|||
/* Create the plugin object manager */
|
||||
self->plugins_om = wp_object_manager_new ();
|
||||
wp_object_manager_add_interest (self->plugins_om, WP_TYPE_PLUGIN,
|
||||
WP_CONSTRAINT_TYPE_G_PROPERTY, "name", "c(ss)",
|
||||
"default-profile", "default-routes", NULL);
|
||||
WP_CONSTRAINT_TYPE_G_PROPERTY, "name", "=s", "default-profile", NULL);
|
||||
g_signal_connect_object (self->plugins_om, "object-added",
|
||||
G_CALLBACK (on_plugin_added), self, 0);
|
||||
wp_core_install_object_manager (core, self->plugins_om);
|
||||
|
|
@ -239,7 +162,6 @@ wp_device_activation_disable (WpPlugin * plugin)
|
|||
g_clear_object (&self->devices_om);
|
||||
g_clear_object (&self->plugins_om);
|
||||
g_weak_ref_clear (&self->default_profile);
|
||||
g_weak_ref_clear (&self->default_routes);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue