mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-11-05 16:26:16 +00:00
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.
This commit is contained in:
parent
3ad403ab13
commit
563f2a2726
2 changed files with 20 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue