2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
24 #if defined(HAVE_OMXLIB)
28 #include "linux/XTimeUtils.h"
31 static inline OMX_TICKS ToOMXTime(int64_t pts)
35 ticks.nHighPart = pts >> 32;
38 static inline int64_t FromOMXTime(OMX_TICKS ticks)
40 int64_t pts = ticks.nLowPart | ((uint64_t)(ticks.nHighPart) << 32);
44 #define FromOMXTime(x) (x)
45 #define ToOMXTime(x) (x)
51 AV_SYNC_EXTERNAL_MASTER,
61 pthread_mutex_t m_lock;
68 COMXCoreComponent m_omx_clock;
74 double GetAbsoluteClock(bool interpolated = true) { return m_clock ? m_clock->GetAbsoluteClock(interpolated):0; }
75 double GetClock(bool interpolated = true) { return m_clock ? m_clock->GetClock(interpolated):0; }
76 double GetClock(double& absolute, bool interpolated = true) { return m_clock ? m_clock->GetClock(absolute, interpolated):0; }
77 void Discontinuity(double currentPts = 0LL) { if (m_clock) m_clock->Discontinuity(currentPts); }
78 void OMXSetClockPorts(OMX_TIME_CONFIG_CLOCKSTATETYPE *clock);
79 bool OMXSetReferenceClock(bool lock = true);
80 bool OMXInitialize(CDVDClock *clock, bool has_video, bool has_audio);
81 void OMXDeinitialize();
82 bool OMXIsPaused() { return m_pause; };
83 bool OMXStop(bool lock = true);
84 bool OMXStep(int steps = 1, bool lock = true);
85 bool OMXReset(bool lock = true);
86 double OMXMediaTime(bool lock = true);
87 double OMXClockAdjustment(bool lock = true);
88 bool OMXMediaTime(double pts, bool lock = true);
89 bool OMXPause(bool lock = true);
90 bool OMXResume(bool lock = true);
91 bool OMXSetSpeed(int speed, bool lock = true, bool pause_resume = false);
92 int OMXPlaySpeed() { return m_omx_speed; };
93 COMXCoreComponent *GetOMXClock();
94 bool OMXStateExecute(bool lock = true);
95 void OMXStateIdle(bool lock = true);
96 bool HDMIClockSync(bool lock = true);
97 static int64_t CurrentHostCounter(void);
98 static int64_t CurrentHostFrequency(void);
99 bool HasVideo() { return m_has_video; };
100 bool HasAudio() { return m_has_audio; };
101 void HasVideo(bool has_video) { m_has_video = has_video; };
102 void HasAudio(bool has_audio) { m_has_audio = has_audio; };
104 int GetRefreshRate(double* interval = NULL);
105 void SetRefreshRate(double fps) { m_fps = fps; };
107 static double NormalizeFrameduration(double frameduration);