From 563f2a272600ec7704b43fc53a8bbef187d16765 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 6 Apr 2016 21:03:00 +0200 Subject: [PATCH] client: Fix unref of source and source-input Make sure we unref the source-input when it is removed. When the source-input is removed, we should also unref the source. Do this by adding the source as data for the source-input and unreffing it when the source-input is freed. --- pinos/server/client-source.c | 14 ++++++++++++++ pinos/server/client.c | 11 ++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pinos/server/client-source.c b/pinos/server/client-source.c index 6bdb6bbab..d1a965e58 100644 --- a/pinos/server/client-source.c +++ b/pinos/server/client-source.c @@ -371,6 +371,15 @@ on_input_socket_notify (GObject *gobject, gst_element_set_state (priv->pipeline, GST_STATE_READY); } +static void +handle_remove_source_input (PinosSourceOutput *output, + gpointer user_data) +{ + PinosClientSourcePrivate *priv = user_data; + + g_clear_pointer (&priv->input, g_object_unref); +} + PinosSourceOutput * pinos_client_source_get_source_input (PinosClientSource *source, const gchar *client_path, @@ -399,6 +408,11 @@ pinos_client_source_get_source_input (PinosClientSource *source, if (priv->input == NULL) return NULL; + g_signal_connect (priv->input, + "remove", + (GCallback) handle_remove_source_input, + priv); + g_signal_connect (priv->input, "notify::socket", (GCallback) on_input_socket_notify, source); } return g_object_ref (priv->input); diff --git a/pinos/server/client.c b/pinos/server/client.c index d47d0e41e..064ba0ac6 100644 --- a/pinos/server/client.c +++ b/pinos/server/client.c @@ -242,11 +242,6 @@ handle_create_source_input (PinosClient1 *interface, if (source == NULL) goto no_source; - g_object_set_data_full (G_OBJECT (client), - pinos_source_get_object_path (PINOS_SOURCE (source)), - source, - g_object_unref); - sender = g_dbus_method_invocation_get_sender (invocation); input = pinos_client_source_get_source_input (PINOS_CLIENT_SOURCE (source), @@ -258,6 +253,11 @@ handle_create_source_input (PinosClient1 *interface, if (input == NULL) goto no_input; + g_object_set_data_full (G_OBJECT (input), + "input-source", + source, + g_object_unref); + source_input_path = pinos_source_output_get_object_path (input); priv->outputs = g_list_prepend (priv->outputs, input); @@ -291,6 +291,7 @@ no_source: no_input: { g_dbus_method_invocation_return_gerror (invocation, error); + g_object_unref (source); g_clear_error (&error); g_bytes_unref (formats); pinos_properties_free (props);