many crash fixes
This commit is contained in:
@@ -34,17 +34,6 @@ wp_plugin_init (WpPlugin * self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
wp_plugin_dispose (GObject * object)
|
||||
{
|
||||
WpPlugin *plugin = WP_PLUGIN (object);
|
||||
WpPluginPrivate *priv = wp_plugin_get_instance_private (plugin);
|
||||
|
||||
g_clear_object (&priv->core);
|
||||
|
||||
G_OBJECT_CLASS (wp_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_plugin_set_property (GObject * object, guint property_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
@@ -144,7 +133,6 @@ wp_plugin_class_init (WpPluginClass * klass)
|
||||
|
||||
klass->handle_pw_proxy = default_handle_pw_proxy;
|
||||
|
||||
object_class->dispose = wp_plugin_dispose;
|
||||
object_class->get_property = wp_plugin_get_property;
|
||||
object_class->set_property = wp_plugin_set_property;
|
||||
|
||||
|
@@ -77,16 +77,6 @@ struct task_data {
|
||||
GPtrArray *result;
|
||||
};
|
||||
|
||||
static gint
|
||||
find_task (gconstpointer t, gconstpointer s)
|
||||
{
|
||||
GTask *task = (GTask *) t;
|
||||
int seq = GPOINTER_TO_INT (s);
|
||||
struct task_data *data = g_task_get_task_data (task);
|
||||
|
||||
return data->seq - seq;
|
||||
}
|
||||
|
||||
/* Updates the info structure while copying the properties into self->properties
|
||||
* and avoiding making a second copy of the properties dict in info->props */
|
||||
#define PROXY_INFO_FUNC(TYPE, type) \
|
||||
@@ -117,12 +107,18 @@ find_task (gconstpointer t, gconstpointer s)
|
||||
uint32_t next, const struct spa_pod *param) \
|
||||
{ \
|
||||
WpProxy *self = WP_PROXY (object); \
|
||||
GList *l; \
|
||||
struct task_data *data; \
|
||||
GList *l = self->tasks; \
|
||||
struct task_data *data = NULL; \
|
||||
\
|
||||
l = g_list_find_custom (self->tasks, GINT_TO_POINTER (seq), find_task); \
|
||||
/* FIXME: seq is not propagated properly \
|
||||
while (l) { \
|
||||
data = g_task_get_task_data (G_TASK (l->data)); \
|
||||
if (data && data->seq == seq) \
|
||||
break; \
|
||||
l = g_list_next (l); \
|
||||
} \
|
||||
*/ \
|
||||
g_return_if_fail (l != NULL); \
|
||||
\
|
||||
data = g_task_get_task_data (G_TASK (l->data)); \
|
||||
g_ptr_array_add (data->result, spa_pod_copy (param)); \
|
||||
}
|
||||
@@ -191,21 +187,31 @@ proxy_event_destroy (void *object)
|
||||
|
||||
self->proxy = NULL;
|
||||
g_signal_emit (self, signals[SIGNAL_DESTROYED], 0);
|
||||
g_object_unref (self);
|
||||
}
|
||||
|
||||
static void
|
||||
proxy_event_done (void *object, int seq)
|
||||
{
|
||||
WpProxy *self = WP_PROXY (object);
|
||||
GList *l;
|
||||
struct task_data *data;
|
||||
GList *l = self->tasks;
|
||||
struct task_data *data = NULL;
|
||||
|
||||
l = g_list_find_custom (self->tasks, GINT_TO_POINTER (seq), find_task);
|
||||
/* FIXME: seq is not propagated properly */
|
||||
#if 0
|
||||
while (l) {
|
||||
data = g_task_get_task_data (G_TASK (l->data));
|
||||
if (data && data->seq == seq)
|
||||
break;
|
||||
l = g_list_next (l);
|
||||
}
|
||||
#endif
|
||||
g_return_if_fail (l != NULL);
|
||||
|
||||
data = g_task_get_task_data (G_TASK (l->data));
|
||||
g_task_return_pointer (G_TASK (l->data), g_ptr_array_ref (data->result),
|
||||
(GDestroyNotify) g_ptr_array_unref);
|
||||
g_object_unref (l->data);
|
||||
self->tasks = g_list_remove_link (self->tasks, l);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events proxy_events = {
|
||||
@@ -274,6 +280,9 @@ wp_proxy_constructed (GObject * object)
|
||||
pw_proxy_add_listener (self->proxy, &self->proxy_listener, &proxy_events,
|
||||
self);
|
||||
|
||||
/* this reference is held by the pw_proxy, released in proxy_event_destroy() */
|
||||
g_object_ref (self);
|
||||
|
||||
if (events)
|
||||
pw_proxy_add_proxy_listener(self->proxy, &self->proxy_proxy_listener,
|
||||
events, self);
|
||||
@@ -297,7 +306,6 @@ wp_proxy_finalize (GObject * object)
|
||||
WpProxy *self = WP_PROXY (object);
|
||||
|
||||
g_clear_pointer (&self->properties, pw_properties_free);
|
||||
g_clear_object (&self->core);
|
||||
|
||||
G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -560,7 +568,7 @@ wp_proxy_enum_params (WpProxy * self, guint32 id,
|
||||
data->result = g_ptr_array_new_with_free_func (free);
|
||||
g_task_set_task_data (task, data, (GDestroyNotify) task_data_free);
|
||||
|
||||
self->tasks = g_list_append (self->tasks, task);
|
||||
self->tasks = g_list_append (self->tasks, g_object_ref (task));
|
||||
|
||||
switch (self->type) {
|
||||
case PW_TYPE_INTERFACE_Node:
|
||||
@@ -599,7 +607,5 @@ wp_proxy_enum_params_finish (WpProxy * self,
|
||||
g_return_val_if_fail (g_async_result_is_tagged (res, wp_proxy_enum_params),
|
||||
NULL);
|
||||
|
||||
self->tasks = g_list_remove (self->tasks, res);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (res), err);
|
||||
}
|
||||
|
@@ -179,11 +179,10 @@ plug_dsp (WpProxy * node)
|
||||
g_info ("making audio dsp for session %u", session->session_id);
|
||||
|
||||
core = wp_proxy_get_core (node);
|
||||
pw_objects = wp_object_get_interface (core, WP_TYPE_PIPEWIRE_OBJECTS);
|
||||
pw_objects = WP_PIPEWIRE_OBJECTS (core);
|
||||
core_proxy = pw_remote_get_core_proxy (wp_pipewire_objects_get_pw_remote (pw_objects));
|
||||
|
||||
pw_props = wp_object_get_interface (WP_OBJECT (node),
|
||||
WP_TYPE_PIPEWIRE_PROPERTIES);
|
||||
pw_props = WP_PIPEWIRE_PROPERTIES (node);
|
||||
props = pw_properties_new_dict (
|
||||
wp_pipewire_properties_get_as_spa_dict (pw_props));
|
||||
if ((name = pw_properties_get (props, "device.nick")) == NULL)
|
||||
@@ -220,25 +219,27 @@ plug_dsp (WpProxy * node)
|
||||
}
|
||||
|
||||
static void
|
||||
audio_port_enum_params_done (GObject * proxy, GAsyncResult * res, gpointer data)
|
||||
audio_port_enum_params_done (GObject * port, GAsyncResult * res, gpointer data)
|
||||
{
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr (GPtrArray) params = NULL;
|
||||
WpProxy *node;
|
||||
DefaultSession *session;
|
||||
struct spa_audio_info_raw info = { 0, };
|
||||
guint32 media_type, media_subtype;
|
||||
guint i;
|
||||
|
||||
g_debug ("done enumerating port %u params",
|
||||
wp_proxy_get_id (WP_PROXY (proxy)));
|
||||
wp_proxy_get_id (WP_PROXY (port)));
|
||||
|
||||
params = wp_proxy_enum_params_finish (WP_PROXY (proxy), res, &error);
|
||||
params = wp_proxy_enum_params_finish (WP_PROXY (port), res, &error);
|
||||
if (!params) {
|
||||
g_warning ("%s", error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
session = g_object_get_data (proxy, "module-default-session.session");
|
||||
node = WP_PROXY (data);
|
||||
session = g_object_get_data (G_OBJECT (node), "module-default-session.session");
|
||||
|
||||
for (i = 0; i < params->len; i++) {
|
||||
struct spa_pod *param = g_ptr_array_index (params, i);
|
||||
@@ -260,14 +261,14 @@ audio_port_enum_params_done (GObject * proxy, GAsyncResult * res, gpointer data)
|
||||
}
|
||||
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) plug_dsp,
|
||||
g_object_ref (proxy), g_object_unref);
|
||||
g_object_ref (node), g_object_unref);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_audio_port (WpPlugin * self, WpProxy * proxy)
|
||||
handle_audio_port (WpPlugin * self, WpProxy * port, WpProxy * node)
|
||||
{
|
||||
wp_proxy_enum_params (proxy, SPA_PARAM_EnumFormat,
|
||||
audio_port_enum_params_done, NULL);
|
||||
wp_proxy_enum_params (port, SPA_PARAM_EnumFormat,
|
||||
audio_port_enum_params_done, node);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -301,7 +302,7 @@ handle_pw_proxy (WpPlugin * self, WpProxy * proxy)
|
||||
{
|
||||
g_debug ("handling audio port %u (parent node %u)", wp_proxy_get_id (proxy),
|
||||
wp_proxy_get_id (parent));
|
||||
return handle_audio_port (self, proxy);
|
||||
return handle_audio_port (self, proxy, parent);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
Reference in New Issue
Block a user