MPRIS control: do not accumulate interface objects

Authored by kossebau on Mar 16 2018, 12:44 PM.

Description

MPRIS control: do not accumulate interface objects

Summary:
If MPRIS players were appearing and disappearing multiple times, the
OrgFreedesktopDBusPropertiesInterface & OrgMprisMediaPlayer2PlayerInterface
instances created for listening to the signals had been accumulating and
thus resulting in X signals per X restarted player, because the instances
were not deleted when a player disappeared.
Additionally were instances of them created on the fly on the stack in
some of the methods, instead of reusing the existing ones.

This patch changes that by introducing a class MprisPlayer which holds all
data & instances per player. This allows to look up the respective
interfaces instances to reuse them as well as properly controlling their
lifetime.

Test Plan:
Starting and restarting multiple MPRIS players (incl. multiple instances of
the same player app) works as expected as befire. They are listed on the
Android Media control as well as have proper states there when selected.
Additionally no longer multiple change signals are emitted if restarting a
player.

Reviewers: KDE Connect, mtijink

Reviewed By: KDE Connect, mtijink

Subscribers: mtijink

Differential Revision: https://phabricator.kde.org/D11389

Details