Bug 321602 - TrackChange - receiving signal twice
Summary: TrackChange - receiving signal twice
Alias: None
Product: amarok
Classification: Applications
Component: D-Bus interfaces (show other bugs)
Version: 2.7.1
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: 2.8
Assignee: Amarok Developers
Depends on:
Reported: 2013-06-25 15:34 UTC by Florent Peterschmitt
Modified: 2013-07-15 22:51 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.8
Sentry Crash Report:


Note You need to log in before you can comment on or make changes to this bug.
Description Florent Peterschmitt 2013-06-25 15:34:47 UTC
I use a small Python script to notify on Psi what is the current track playing, using org.freedesktop.MediaPlayer.TrackChange signal.

The problem isn't from the script, I tried with Clementine player and it's ok.

URL to the script (needs python-dbus and python-gobject): http://peterschmitt.fr/~florent/psisnd.py

You can try with clementine by passing -c org.mpris.clementine option and use -d to disable need of Psi running.

Reproducible: Always

Steps to Reproduce:
1. launch Amarok, have at least one track and make playlist in loop.
2. ./psisnd.py -d
3. change track to next one and see double notification.

Try with clementine player, no double notification.
Actual Results:  
♪ Reflections (Tron: Legacy OST [Special Edition]) by Daft Punk ♪
♪ Reflections (Tron: Legacy OST [Special Edition]) by Daft Punk ♪

Expected Results:  
♪ Reflections (Tron: Legacy OST [Special Edition]) by Daft Punk ♪
Comment 1 Florent Peterschmitt 2013-06-27 08:48:09 UTC
It does the same also on FreeBSD.
Comment 2 Alex Merry 2013-07-14 23:09:44 UTC
Review request at https://git.reviewboard.kde.org/r/111512/
Comment 3 Alex Merry 2013-07-15 22:44:51 UTC
Git commit f5d15e9465c6fa3d0a3997bf57130fe5e592c56e by Alex Merry.
Committed on 14/07/2013 at 22:53.
Pushed by alexmerry into branch 'master'.

MPRIS2: avoid updating Metadata when between tracks

When changing tracks, we would emit PropertiesChanged for Metadata
twice, once with mpris:trackid set to /org/kde/amarok/PendingTrack and
once with the actual new trackid (because the first time the playlist
code had not yet updated the active track).  If the track was changed
manually (not just progressing to the next one) we would often also emit
a PropertiesChanged with an empty Metadata before repopulating it.

This solves the first issue by making the signal connection for
trackChanged from EngineController queued, meaning that by the time the
MPRIS2 code gets the signal, the playlist has updated the activeTrack
and we can easily figure out the correct trackid.

It solves the second issue by ignoring the trackLengthChanged signal
when it has a meaningless value (<0), which seems to happen at some
point during track changes that are not predictable.
REVIEW: 111512

M  +1    -0    ChangeLog
M  +9    -3    src/dbus/mpris2/MediaPlayer2Player.cpp