Closed gnome-mpv closed 1 year ago
Using the default GMainContext may cause deadlocks when mpv-mpris is loaded in an mpv frontend that use GLib. See https://github.com/celluloid-player/celluloid/issues/486 for an example of this happening in Celluloid.
Minimal reproducer:
// Build with: gcc `pkg-config --cflags --libs glib-2.0 mpv` test.c -o test #include <glib.h> #include <stdio.h> #include <mpv/client.h> struct UserData { mpv_handle *mpv; GMainLoop *loop; }; gboolean handle_timeout(struct UserData *user_data) { mpv_terminate_destroy(user_data->mpv); g_main_loop_quit(user_data->loop); return G_SOURCE_REMOVE; } int main(int argc, char **argv) { mpv_handle *mpv = mpv_create(); mpv_initialize(mpv); mpv_command_string(mpv, "load-script ./mpris.so"); GMainLoop *loop = g_main_loop_new(NULL, FALSE); struct UserData user_data = {.mpv = mpv, .loop = loop}; g_timeout_add(1000, G_SOURCE_FUNC(handle_timeout), &user_data); puts("Quitting in 1 second..."); g_main_loop_run(loop); g_main_loop_unref(loop); return 0; }
Thanks!
Using the default GMainContext may cause deadlocks when mpv-mpris is loaded in an mpv frontend that use GLib. See https://github.com/celluloid-player/celluloid/issues/486 for an example of this happening in Celluloid.
Minimal reproducer: