Commit ec519752 authored by Alexander Stippich's avatar Alexander Stippich
Browse files

limit the rate with which progress is sent via MPRIS

BUG: 416179
parent c10644a3
......@@ -215,13 +215,21 @@ void MediaPlayer2Player::setPropertyPosition(int newPositionInMs)
Q_EMIT Seeked(m_position);
QVariantMap parameters;
parameters.insert(QStringLiteral("progress-visible"), true);
parameters.insert(QStringLiteral("progress"), static_cast<double>(newPositionInMs) / m_audioPlayer->duration());
/* only sent new progress when it has advanced more than 1 %
* to limit DBus traffic
*/
const auto incrementalProgress = static_cast<double>(newPositionInMs - mPreviousProgressPosition) / m_audioPlayer->duration();
if (incrementalProgress > 0.01 || incrementalProgress < 0)
{
mPreviousProgressPosition = newPositionInMs;
QVariantMap parameters;
parameters.insert(QStringLiteral("progress-visible"), true);
parameters.insert(QStringLiteral("progress"), static_cast<double>(newPositionInMs) / m_audioPlayer->duration());
mProgressIndicatorSignal.setArguments({QStringLiteral("application://org.kde.elisa.desktop"), parameters});
mProgressIndicatorSignal.setArguments({QStringLiteral("application://org.kde.elisa.desktop"), parameters});
QDBusConnection::sessionBus().send(mProgressIndicatorSignal);
QDBusConnection::sessionBus().send(mProgressIndicatorSignal);
}
}
double MediaPlayer2Player::Rate() const
......
......@@ -163,6 +163,7 @@ private:
ManageHeaderBar * m_manageHeaderBar = nullptr;
AudioWrapper *m_audioPlayer = nullptr;
mutable QDBusMessage mProgressIndicatorSignal;
int mPreviousProgressPosition = 0;
};
#endif // MEDIAPLAYER2PLAYER_H
  • This commit helped a lot in bringing down the CPU usage of plasmashell while Elisa is playing a song. However, plasmashell still consumes quite a bit of CPU, because line 216 (Q_EMIT Seeked(m_position);) is outside the if clause that was added by this commit. As such, Q_EMIT is still triggered a lot - even when the progress is less than 1% - and that induces load on the plasmashell. Why was it not moved inside the if clause like line 231 (QDBusConnection::sessionBus().send(mProgressIndicatorSignal);)?

  • Seems like a sensible change. Would you be interested in submitting a merge request to do that? Thanks!

  • Ghost User @ghost

    mentioned in merge request !193 (merged)

    ·

    mentioned in merge request !193 (merged)

    Toggle commit list
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