diff options
author | Alex Merry <dev@randomguy3.me.uk> | 2012-04-23 20:22:29 +0100 |
---|---|---|
committer | Alex Merry <dev@randomguy3.me.uk> | 2012-04-23 20:22:29 +0100 |
commit | 3605a26c3f417e7e962f91e1d70e8318b1337a1c (patch) | |
tree | 726eef3953fb6ab0039ef56b6999b69f2d97bc47 | |
parent | e84717cb2d8bf1484dd810a66386fb7bff373581 (diff) |
Rename position variables
These names are more accurate.
-rw-r--r-- | mpris2/playerinterfacetest.cpp | 19 | ||||
-rw-r--r-- | mpris2/playerinterfacetest.h | 4 |
2 files changed, 13 insertions, 10 deletions
diff --git a/mpris2/playerinterfacetest.cpp b/mpris2/playerinterfacetest.cpp index 467242a..168570e 100644 --- a/mpris2/playerinterfacetest.cpp +++ b/mpris2/playerinterfacetest.cpp @@ -28,7 +28,7 @@ PlayerInterfaceTest::PlayerInterfaceTest(const QString& service, QObject* parent : InterfaceTest(MPRIS2_PLAYER_IFACE, service, parent) { m_pos = -1; - m_currentRate = 0.0; + m_effectiveRate = 0.0; propsNotUpdated << "Position"; } @@ -395,11 +395,14 @@ void PlayerInterfaceTest::checkRateConsistency(const QVariantMap& oldProps) void PlayerInterfaceTest::updateCurrentRate() { + m_pos = predictedPosition(); + m_posLastCalculated = QTime::currentTime(); + QString playbackStatus = properties().value("PlaybackStatus").toString(); if (playbackStatus == "Playing") { - m_currentRate = properties().value("Rate").toDouble(); + m_effectiveRate = properties().value("Rate").toDouble(); } else { - m_currentRate = 0.0; + m_effectiveRate = 0.0; } } @@ -407,7 +410,7 @@ void PlayerInterfaceTest::_m_seeked(qint64 position, const QDBusMessage& message { emit interfaceInfo(Signal, "Seeked", "Got Seeked(" + QString::number(position) + ") signal"); m_pos = position; - m_posLastUpdated = QTime::currentTime(); + m_posLastCalculated = QTime::currentTime(); props["Position"] = position; checkPosition(); emit Seeked(position); @@ -415,8 +418,8 @@ void PlayerInterfaceTest::_m_seeked(qint64 position, const QDBusMessage& message qint64 PlayerInterfaceTest::predictedPosition() { - qint64 elapsed = (qint64)m_posLastUpdated.elapsed() * 1000L; - return m_pos + (m_currentRate * elapsed); + qint64 elapsed = (qint64)m_posLastCalculated.elapsed() * 1000L; + return m_pos + (m_effectiveRate * elapsed); } void PlayerInterfaceTest::checkPredictedPosition() @@ -426,14 +429,14 @@ void PlayerInterfaceTest::checkPredictedPosition() // if this is the initial fetch if (m_pos == -1) { m_pos = position; - m_posLastUpdated = QTime::currentTime(); + m_posLastCalculated = QTime::currentTime(); updateCurrentRate(); return; } qint64 predictedPos = predictedPosition(); m_pos = position; - m_posLastUpdated = QTime::currentTime(); + m_posLastCalculated = QTime::currentTime(); updateCurrentRate(); qint64 diffMillis = (position - predictedPos) / 1000; diff --git a/mpris2/playerinterfacetest.h b/mpris2/playerinterfacetest.h index c021edc..727b5e6 100644 --- a/mpris2/playerinterfacetest.h +++ b/mpris2/playerinterfacetest.h @@ -78,8 +78,8 @@ namespace Mpris2 { void updateCurrentRate(); qint64 m_pos; - qreal m_currentRate; // 0.0 if not playing, Rate otherwise - QTime m_posLastUpdated; + qreal m_effectiveRate; // 0.0 if not playing, Rate otherwise + QTime m_posLastCalculated; }; } |