double OMXClock::GetMediaTime(bool lock) { if (!GetComponent()) { return 0.0; } double pts = 0.0; double now = GetAbsoluteClock(); if (((now - m_lastMediaTimeRead) > CLOCK_MSEC_TO_TIME(100)) || (m_lastMediaTime == 0.0)) { if (lock) Lock(); OMX_ERRORTYPE omxErr = OMX_ErrorNone; OMX_TIME_CONFIG_TIMESTAMPTYPE timestamp; OMX_INIT_STRUCTURE(timestamp); timestamp.nPortIndex = GetInputPort(); omxErr = GetConfig(OMX_IndexConfigTimeCurrentMediaTime, ×tamp); if (omxErr != OMX_ErrorNone) { if (lock) Unlock(); return 0.0; } pts = (double)FromOMXTime(timestamp.nTimestamp); //OMXLogger::OutputLog( "OMXClock::GetMediaTime - %.2f (%.2f, %.2f)", LogLevel::Debug, pts, m_lastMediaTime, now - m_lastMediaTime ); m_lastMediaTime = pts; m_lastMediaTimeRead = now; if (lock) Unlock(); } else { double speed = m_pause ? 0.0 : (double)m_omxSpeed / CLOCK_PLAYSPEED_NORMAL; pts = m_lastMediaTime + (now - m_lastMediaTimeRead) * speed; //OMXLogger::OutputLog( "OMXClock::GetMediaTime - cached %.2f (%.2f, %.2f)", LogLevel::Debug, pts, m_lastMediaTime, now - m_lastMediaTime ); } //OMXLogger::OutputLog( "OMXClock::GetMediaTime - Returning PTS %f", LogLevel::Debug, pts ); return pts; }
double OMXClock::OMXMediaTime(bool lock /* = true */) { double pts = 0.0; if(m_omx_clock.GetComponent() == NULL) return 0; double now = GetAbsoluteClock(); if (now - m_last_media_time_read > DVD_MSEC_TO_TIME(100) || m_last_media_time == 0.0) { if(lock) Lock(); OMX_ERRORTYPE omx_err = OMX_ErrorNone; OMX_TIME_CONFIG_TIMESTAMPTYPE timeStamp; OMX_INIT_STRUCTURE(timeStamp); timeStamp.nPortIndex = m_omx_clock.GetInputPort(); omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentMediaTime, &timeStamp); if(omx_err != OMX_ErrorNone) { LOG_ERROR << "OMXClock::MediaTime error getting OMX_IndexConfigTimeCurrentMediaTime"; if(lock) UnLock(); return 0; } pts = FromOMXTime(timeStamp.nTimestamp); //CLog::Log(LOGINFO, "OMXClock::MediaTime %.2f (%.2f, %.2f)", pts, m_last_media_time, now - m_last_media_time_read); m_last_media_time = pts; m_last_media_time_read = now; if(lock) UnLock(); } else { double speed = m_pause ? 0.0 : (double)m_omx_speed / DVD_PLAYSPEED_NORMAL; pts = m_last_media_time + (now - m_last_media_time_read) * speed; //CLog::Log(LOGINFO, "OMXClock::MediaTime cached %.2f (%.2f, %.2f)", pts, m_last_media_time, now - m_last_media_time_read); } return pts; }
double OMXClock::GetClock(void) const { return GetAbsoluteClock(); }
double OMXClock::GetClock(bool interpolated /*= true*/) { return GetAbsoluteClock(); }