diff --git a/modules/module-pipewire.c b/modules/module-pipewire.c index f47d85c26f1b11e64b5c3f5f8cc34240696bbca3..97c6bc74eefae8cd78f8ca975dc68863fe75fd61 100644 --- a/modules/module-pipewire.c +++ b/modules/module-pipewire.c @@ -76,6 +76,16 @@ proxy_info_destroy(gpointer p) g_slice_free (struct proxy_info, p); } +static void +unregister_endpoint (WpProxy* wp_proxy, WpEndpoint *endpoint) +{ + g_return_if_fail(WP_IS_PROXY(wp_proxy)); + g_return_if_fail(WP_IS_ENDPOINT(endpoint)); + + /* Unregister the endpoint */ + wp_endpoint_unregister(endpoint); +} + static void proxy_node_created(GObject *initable, GAsyncResult *res, gpointer d) { @@ -123,6 +133,10 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer d) /* Register the endpoint */ wp_endpoint_register (endpoint); + /* Set destroy handler to unregister endpoint when the proxy is detroyed */ + g_signal_connect (proxy_node, "destroyed", G_CALLBACK(unregister_endpoint), + endpoint); + /* Clean up */ proxy_info_destroy (pi); } diff --git a/modules/module-pw-alsa-udev.c b/modules/module-pw-alsa-udev.c index bf02d1060baabf9f2b96dc3970a8fcf9af66190f..6b26132b2437a79c214a797881a923c79053224c 100644 --- a/modules/module-pw-alsa-udev.c +++ b/modules/module-pw-alsa-udev.c @@ -70,6 +70,16 @@ proxy_info_destroy(gpointer p) g_slice_free (struct proxy_info, p); } +static void +unregister_endpoint (WpProxy* wp_proxy, WpEndpoint *endpoint) +{ + g_return_if_fail(WP_IS_PROXY(wp_proxy)); + g_return_if_fail(WP_IS_ENDPOINT(endpoint)); + + /* Unregister the endpoint */ + wp_endpoint_unregister(endpoint); +} + static void proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data) { @@ -114,6 +124,10 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data) /* Register the endpoint */ wp_endpoint_register (endpoint); + /* Set destroy handler to unregister endpoint when the proxy is detroyed */ + g_signal_connect (proxy_node, "destroyed", G_CALLBACK(unregister_endpoint), + endpoint); + /* Clean up */ proxy_info_destroy (pi); }