Skip to content
Snippets Groups Projects
Commit 43365715 authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

many crash fixes

parent ac65d44b
No related branches found
No related tags found
No related merge requests found
...@@ -34,17 +34,6 @@ wp_plugin_init (WpPlugin * self) ...@@ -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 static void
wp_plugin_set_property (GObject * object, guint property_id, wp_plugin_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
...@@ -144,7 +133,6 @@ wp_plugin_class_init (WpPluginClass * klass) ...@@ -144,7 +133,6 @@ wp_plugin_class_init (WpPluginClass * klass)
klass->handle_pw_proxy = default_handle_pw_proxy; klass->handle_pw_proxy = default_handle_pw_proxy;
object_class->dispose = wp_plugin_dispose;
object_class->get_property = wp_plugin_get_property; object_class->get_property = wp_plugin_get_property;
object_class->set_property = wp_plugin_set_property; object_class->set_property = wp_plugin_set_property;
......
...@@ -77,16 +77,6 @@ struct task_data { ...@@ -77,16 +77,6 @@ struct task_data {
GPtrArray *result; 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 /* Updates the info structure while copying the properties into self->properties
* and avoiding making a second copy of the properties dict in info->props */ * and avoiding making a second copy of the properties dict in info->props */
#define PROXY_INFO_FUNC(TYPE, type) \ #define PROXY_INFO_FUNC(TYPE, type) \
...@@ -117,12 +107,18 @@ find_task (gconstpointer t, gconstpointer s) ...@@ -117,12 +107,18 @@ find_task (gconstpointer t, gconstpointer s)
uint32_t next, const struct spa_pod *param) \ uint32_t next, const struct spa_pod *param) \
{ \ { \
WpProxy *self = WP_PROXY (object); \ WpProxy *self = WP_PROXY (object); \
GList *l; \ GList *l = self->tasks; \
struct task_data *data; \ 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); \ g_return_if_fail (l != NULL); \
\
data = g_task_get_task_data (G_TASK (l->data)); \ data = g_task_get_task_data (G_TASK (l->data)); \
g_ptr_array_add (data->result, spa_pod_copy (param)); \ g_ptr_array_add (data->result, spa_pod_copy (param)); \
} }
...@@ -191,21 +187,31 @@ proxy_event_destroy (void *object) ...@@ -191,21 +187,31 @@ proxy_event_destroy (void *object)
self->proxy = NULL; self->proxy = NULL;
g_signal_emit (self, signals[SIGNAL_DESTROYED], 0); g_signal_emit (self, signals[SIGNAL_DESTROYED], 0);
g_object_unref (self);
} }
static void static void
proxy_event_done (void *object, int seq) proxy_event_done (void *object, int seq)
{ {
WpProxy *self = WP_PROXY (object); WpProxy *self = WP_PROXY (object);
GList *l; GList *l = self->tasks;
struct task_data *data; 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); g_return_if_fail (l != NULL);
data = g_task_get_task_data (G_TASK (l->data)); data = g_task_get_task_data (G_TASK (l->data));
g_task_return_pointer (G_TASK (l->data), g_ptr_array_ref (data->result), g_task_return_pointer (G_TASK (l->data), g_ptr_array_ref (data->result),
(GDestroyNotify) g_ptr_array_unref); (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 = { static const struct pw_proxy_events proxy_events = {
...@@ -274,6 +280,9 @@ wp_proxy_constructed (GObject * object) ...@@ -274,6 +280,9 @@ wp_proxy_constructed (GObject * object)
pw_proxy_add_listener (self->proxy, &self->proxy_listener, &proxy_events, pw_proxy_add_listener (self->proxy, &self->proxy_listener, &proxy_events,
self); self);
/* this reference is held by the pw_proxy, released in proxy_event_destroy() */
g_object_ref (self);
if (events) if (events)
pw_proxy_add_proxy_listener(self->proxy, &self->proxy_proxy_listener, pw_proxy_add_proxy_listener(self->proxy, &self->proxy_proxy_listener,
events, self); events, self);
...@@ -297,7 +306,6 @@ wp_proxy_finalize (GObject * object) ...@@ -297,7 +306,6 @@ wp_proxy_finalize (GObject * object)
WpProxy *self = WP_PROXY (object); WpProxy *self = WP_PROXY (object);
g_clear_pointer (&self->properties, pw_properties_free); g_clear_pointer (&self->properties, pw_properties_free);
g_clear_object (&self->core);
G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object); G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object);
} }
...@@ -560,7 +568,7 @@ wp_proxy_enum_params (WpProxy * self, guint32 id, ...@@ -560,7 +568,7 @@ wp_proxy_enum_params (WpProxy * self, guint32 id,
data->result = g_ptr_array_new_with_free_func (free); data->result = g_ptr_array_new_with_free_func (free);
g_task_set_task_data (task, data, (GDestroyNotify) task_data_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) { switch (self->type) {
case PW_TYPE_INTERFACE_Node: case PW_TYPE_INTERFACE_Node:
...@@ -599,7 +607,5 @@ wp_proxy_enum_params_finish (WpProxy * self, ...@@ -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), g_return_val_if_fail (g_async_result_is_tagged (res, wp_proxy_enum_params),
NULL); NULL);
self->tasks = g_list_remove (self->tasks, res);
return g_task_propagate_pointer (G_TASK (res), err); return g_task_propagate_pointer (G_TASK (res), err);
} }
...@@ -179,11 +179,10 @@ plug_dsp (WpProxy * node) ...@@ -179,11 +179,10 @@ plug_dsp (WpProxy * node)
g_info ("making audio dsp for session %u", session->session_id); g_info ("making audio dsp for session %u", session->session_id);
core = wp_proxy_get_core (node); 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)); core_proxy = pw_remote_get_core_proxy (wp_pipewire_objects_get_pw_remote (pw_objects));
pw_props = wp_object_get_interface (WP_OBJECT (node), pw_props = WP_PIPEWIRE_PROPERTIES (node);
WP_TYPE_PIPEWIRE_PROPERTIES);
props = pw_properties_new_dict ( props = pw_properties_new_dict (
wp_pipewire_properties_get_as_spa_dict (pw_props)); wp_pipewire_properties_get_as_spa_dict (pw_props));
if ((name = pw_properties_get (props, "device.nick")) == NULL) if ((name = pw_properties_get (props, "device.nick")) == NULL)
...@@ -220,25 +219,27 @@ plug_dsp (WpProxy * node) ...@@ -220,25 +219,27 @@ plug_dsp (WpProxy * node)
} }
static void 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 (GError) error = NULL;
g_autoptr (GPtrArray) params = NULL; g_autoptr (GPtrArray) params = NULL;
WpProxy *node;
DefaultSession *session; DefaultSession *session;
struct spa_audio_info_raw info = { 0, }; struct spa_audio_info_raw info = { 0, };
guint32 media_type, media_subtype; guint32 media_type, media_subtype;
guint i; guint i;
g_debug ("done enumerating port %u params", 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) { if (!params) {
g_warning ("%s", error->message); g_warning ("%s", error->message);
return; 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++) { for (i = 0; i < params->len; i++) {
struct spa_pod *param = g_ptr_array_index (params, 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) ...@@ -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_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 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, wp_proxy_enum_params (port, SPA_PARAM_EnumFormat,
audio_port_enum_params_done, NULL); audio_port_enum_params_done, node);
return TRUE; return TRUE;
} }
...@@ -301,7 +302,7 @@ handle_pw_proxy (WpPlugin * self, WpProxy * proxy) ...@@ -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), g_debug ("handling audio port %u (parent node %u)", wp_proxy_get_id (proxy),
wp_proxy_get_id (parent)); wp_proxy_get_id (parent));
return handle_audio_port (self, proxy); return handle_audio_port (self, proxy, parent);
} }
return FALSE; return FALSE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment