fix macOS timer bug
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "viewerplaybacktimer.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QtMath>
|
||||
|
||||
namespace olive
|
||||
@@ -31,7 +30,7 @@ void ViewerPlaybackTimer::Start(const int64_t &start_timestamp,
|
||||
const int &playback_speed,
|
||||
const double &timebase)
|
||||
{
|
||||
start_msec_ = QDateTime::currentMSecsSinceEpoch();
|
||||
timer_.start();
|
||||
start_timestamp_ = start_timestamp;
|
||||
playback_speed_ = playback_speed;
|
||||
timebase_ = timebase * 1000;
|
||||
@@ -39,7 +38,7 @@ void ViewerPlaybackTimer::Start(const int64_t &start_timestamp,
|
||||
|
||||
int64_t ViewerPlaybackTimer::GetTimestampNow() const
|
||||
{
|
||||
int64_t real_time = QDateTime::currentMSecsSinceEpoch() - start_msec_;
|
||||
int64_t real_time = timer_.elapsed();
|
||||
|
||||
int64_t frames_since_start =
|
||||
qFloor(static_cast<double>(real_time) / (timebase_));
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#define VIEWERPLAYBACKTIMER_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
@@ -37,7 +38,7 @@ public:
|
||||
int64_t GetTimestampNow() const;
|
||||
|
||||
private:
|
||||
qint64 start_msec_;
|
||||
QElapsedTimer timer_;
|
||||
int64_t start_timestamp_;
|
||||
|
||||
int playback_speed_;
|
||||
|
||||
Reference in New Issue
Block a user