Skip to content

dataengines/mpris2: explicitly wait 100ms before adding new media player

Fushan Wen requested to merge work/fuf/wait100 into Plasma/5.27

Due to async nature of DBus, when a media player registers a service, the service may not be able to provide both MPRIS2 object paths.

Here is an example:

g_bus_own_name_on_connection (bus, "org.mpris.MediaPlayer2.buggyplayer", (GBusNameOwnerFlags) 0, nullptr, nullptr, nullptr, nullptr);
GObject *object_core = (GObject *)mpris_media_player2_skeleton_new();
// ...set properties for org.mpris.MediaPlayer2, connect to signals
GObject *object_player = (GObject *)mpris_media_player2_player_skeleton_new();
// ...set properties for org.mpris.MediaPlayer2.Player, connect to signals
g_dbus_interface_skeleton_export ((GDBusInterfaceSkeleton *)object_core, bus, "/org/mpris/MediaPlayer2", & error)
g_dbus_interface_skeleton_export ((GDBusInterfaceSkeleton *)object_player, bus, "/org/mpris/MediaPlayer2", & error)

Until the last g_dbus_interface_skeleton_export is called, the service is unable to provide a valid MPRIS2 interface, so the player will not be accepted by the data engine. This can be worked around by waiting 100ms before querying properties from the service.

Merge request reports

Loading