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

daemon: quit when the pipewire remote disconnects or signals an error

This is implemented in a slightly hacky way, we register the GMainLoop
as a global object and use it from the module to quit the daemon.
This is bad design because the module assumes it is loaded inside
our daemon.

In the future, this should change. It looks like we should have an
object that tracks the state of PipeWire and main() should track
state changes of that object and decide what to do.
parent d4ddad18
No related branches found
No related tags found
No related merge requests found
...@@ -110,14 +110,24 @@ on_remote_state_changed (void *d, enum pw_remote_state old_state, ...@@ -110,14 +110,24 @@ on_remote_state_changed (void *d, enum pw_remote_state old_state,
&data->registry_listener, &registry_events, data); &data->registry_listener, &registry_events, data);
break; break;
case PW_REMOTE_STATE_UNCONNECTED: case PW_REMOTE_STATE_UNCONNECTED: {
// TODO quit wireplumber g_autoptr (WpCore) core = wp_module_get_core (data->module);
if (core) {
g_message ("disconnected from PipeWire");
g_main_loop_quit (wp_core_get_global (core,
g_quark_from_string ("main-loop")));
}
break; break;
}
case PW_REMOTE_STATE_ERROR: case PW_REMOTE_STATE_ERROR: {
// TODO quit wireplumber g_autoptr (WpCore) core = wp_module_get_core (data->module);
if (core) {
g_message ("PipeWire remote error: %s", error);
g_main_loop_quit (wp_core_get_global (core,
g_quark_from_string ("main-loop")));
}
break; break;
}
default: default:
break; break;
} }
......
...@@ -197,6 +197,8 @@ main (gint argc, gchar **argv) ...@@ -197,6 +197,8 @@ main (gint argc, gchar **argv)
/* init main loop */ /* init main loop */
data.loop = loop = g_main_loop_new (NULL, FALSE); data.loop = loop = g_main_loop_new (NULL, FALSE);
wp_core_register_global (core, g_quark_from_static_string ("main-loop"),
g_main_loop_ref (loop), (GDestroyNotify) g_main_loop_unref);
/* watch for exit signals */ /* watch for exit signals */
......
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