Commit 1962a8ca authored by George Kiagiadakis's avatar George Kiagiadakis

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
......@@ -110,14 +110,24 @@ on_remote_state_changed (void *d, enum pw_remote_state old_state,
&data->registry_listener, &registry_events, data);
break;
case PW_REMOTE_STATE_UNCONNECTED:
// TODO quit wireplumber
case PW_REMOTE_STATE_UNCONNECTED: {
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;
case PW_REMOTE_STATE_ERROR:
// TODO quit wireplumber
}
case PW_REMOTE_STATE_ERROR: {
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;
}
default:
break;
}
......
......@@ -197,6 +197,8 @@ main (gint argc, gchar **argv)
/* init main loop */
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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment