File indexing completed on 2024-06-16 04:38:28
0001 /* 0002 SPDX-FileCopyrightText: 2003 Fabrice Bellard 0003 SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic <max@smoothware.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef CLOCK_H 0009 #define CLOCK_H 0010 0011 // no AV correction is done if too big error 0012 #define AV_NOSYNC_THRESHOLD 10.0 0013 0014 namespace SubtitleComposer { 0015 class PacketQueue; 0016 0017 class Clock 0018 { 0019 public: 0020 Clock(); 0021 0022 double get() const; 0023 void setAt(double pts, int serial, double time); 0024 void set(double pts, int serial); 0025 void setSpeed(double speed); 0026 void init(const PacketQueue *queue); 0027 void syncTo(Clock *other); 0028 0029 inline double pts() const { return m_pts; } 0030 inline double lastUpdated() const { return m_lastUpdated; } 0031 inline double speed() const { return m_speed; } 0032 inline int serial() const { return m_serial; } 0033 inline int paused() const { return m_paused; } 0034 inline void pause(bool pause) { m_paused = pause; } 0035 0036 private: 0037 double m_pts; // clock base 0038 double m_ptsDrift; // clock base minus time at which we updated the clock 0039 double m_lastUpdated; 0040 double m_speed; 0041 int m_serial; // clock is based on a packet with this serial 0042 bool m_paused; 0043 const int *m_queueSerial; // pointer to the current packet queue serial, used for obsolete clock detection 0044 }; 0045 } 0046 0047 #endif // CLOCK_H