From f66c05b344fc865122ecb217b70a2384ce3dfbcd Mon Sep 17 00:00:00 2001 From: anbr Date: Wed, 12 Jan 2011 21:14:22 +0100 Subject: Wrong time on playback of HD recordings (Bug #517) --- watch.c | 51 +++++++++++++++++++++++++++------------------------ watch.h | 6 +++--- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/watch.c b/watch.c index 5806871..4e96c85 100644 --- a/watch.c +++ b/watch.c @@ -284,10 +284,7 @@ void ciMonWatch::Action(void) if(m_eWatchMode != eLiveTV) { current = 0; total = 0; - if (ReplayPosition(current,total) - && theSetup.m_nRenderMode == eRenderMode_DualLine) { - bReDraw |= ReplayTime(current,total); - } + bReDraw |= ReplayTime(current,total); } } @@ -741,29 +738,26 @@ eReplayState ciMonWatch::ReplayMode() const return eReplayNone; } -bool ciMonWatch::ReplayPosition(int ¤t, int &total) const +bool ciMonWatch::ReplayPosition(int ¤t, int &total, double& dFrameRate) const { if (m_pControl && ((cControl *)m_pControl)->GetIndex(current, total, false)) { total = (total == 0) ? 1 : total; +#if VDRVERSNUM >= 10703 + dFrameRate = ((cControl *)m_pControl)->FramesPerSecond(); +#endif return true; } return false; } -const char * ciMonWatch::FormatReplayTime(int current, int total) const +const char * ciMonWatch::FormatReplayTime(int current, int total, double dFrameRate) const { static char s[32]; -#if VDRVERSNUM >= 10701 - int cs = (current / DEFAULTFRAMESPERSECOND); - int ts = (total / DEFAULTFRAMESPERSECOND); - bool g = (((current / DEFAULTFRAMESPERSECOND) / 3600) > 0) - || (((total / DEFAULTFRAMESPERSECOND) / 3600) > 0); -#else - int cs = (current / FRAMESPERSEC); - int ts = (total / FRAMESPERSEC); - bool g = (((current / FRAMESPERSEC) / 3600) > 0) - || (((total / FRAMESPERSEC) / 3600) > 0); -#endif + + int cs = (int)((double)current / dFrameRate); + int ts = (int)((double)total / dFrameRate); + bool g = ((cs / 3600) > 0) || ((ts / 3600) > 0); + int cm = cs / 60; cs %= 60; int tm = ts / 60; @@ -786,13 +780,22 @@ const char * ciMonWatch::FormatReplayTime(int current, int total) const return s; } -bool ciMonWatch::ReplayTime(int current, int total) { - const char * sz = FormatReplayTime(current,total); - if(!replayTime || strcmp(sz,*replayTime)) { - if(replayTime) - delete replayTime; - replayTime = new cString(sz); - return replayTime != NULL; +bool ciMonWatch::ReplayTime(int ¤t, int &total) { + double dFrameRate; +#if VDRVERSNUM >= 10701 + dFrameRate = DEFAULTFRAMESPERSECOND; +#else + dFrameRate = FRAMESPERSEC; +#endif + if(ReplayPosition(current,total,dFrameRate) + && theSetup.m_nRenderMode == eRenderMode_DualLine) { + const char * sz = FormatReplayTime(current,total,dFrameRate); + if(!replayTime || strcmp(sz,*replayTime)) { + if(replayTime) + delete replayTime; + replayTime = new cString(sz); + return replayTime != NULL; + } } return false; } diff --git a/watch.h b/watch.h index 54e3f5b..2b1f61b 100644 --- a/watch.h +++ b/watch.h @@ -128,10 +128,10 @@ protected: bool Replay(); bool RenderScreen(bool bRedraw); eReplayState ReplayMode() const; - bool ReplayPosition(int ¤t, int &total) const; + bool ReplayPosition(int ¤t, int &total, double& dFrameRate) const; bool CurrentTime(); - bool ReplayTime(int current, int total); - const char * FormatReplayTime(int current, int total) const; + bool ReplayTime(int& current, int& total); + const char * FormatReplayTime(int current, int total, double dFrameRate) const; public: ciMonWatch(); virtual ~ciMonWatch(); -- cgit v1.2.3