From 5457d41934126fcdecd7433ab65cdc46843ca408 Mon Sep 17 00:00:00 2001 From: george82 Date: Sat, 19 Feb 2005 06:43:09 +0000 Subject: [PATCH] Fixed bug with the time slider jumping to one pos back when playback speed is not 1.00 git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@193 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rfbplayer/rfbplayer.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/rfbplayer/rfbplayer.cxx b/rfbplayer/rfbplayer.cxx index 40804a6c..bc18d3eb 100644 --- a/rfbplayer/rfbplayer.cxx +++ b/rfbplayer/rfbplayer.cxx @@ -58,7 +58,8 @@ char usage_msg[] = // -=- RfbPlayer's defines #define strcasecmp _stricmp -#define MAX_SPEED 10 +#define MAX_SPEED 10.00 +#define CALCULATION_ERROR MAX_SPEED / 1000 #define MAX_POS_TRACKBAR_RANGE 50 #define DEFAULT_PLAYER_WIDTH 640 #define DEFAULT_PLAYER_HEIGHT 480 @@ -335,7 +336,7 @@ RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) GotoPosDialog gotoPosDlg; if (gotoPosDlg.showDialog()) { setPos(gotoPosDlg.getPos()); - updatePos(getTimeOffset()); + updatePos(gotoPosDlg.getPos()); } } break; @@ -1061,16 +1062,17 @@ long RfbPlayer::getTimeOffset() { void RfbPlayer::updatePos(long newPos) { // Update time pos in static control char timePos[30] = "\0"; - long sliderPos = newPos; - newPos /= 1000; - sprintf(timePos, "%.2um:%.2us (%s)", newPos/60, newPos%60, fullSessionTime); + long time = newPos / 1000; + sprintf(timePos, "%.2um:%.2us (%s)", time/60, time%60, fullSessionTime); SetWindowText(timeStatic, timePos); // Update the position of slider if (!sliderDraging) { - sliderPos /= sliderStepMs; - if (sliderPos > SendMessage(posTrackBar, TBM_GETPOS, 0, 0)) - SendMessage(posTrackBar, TBM_SETPOS, TRUE, sliderPos); + double error = SendMessage(posTrackBar, TBM_GETPOS, 0, 0) * + sliderStepMs / double(newPos); + if (!((error > 1 - CALCULATION_ERROR) && (error <= 1 + CALCULATION_ERROR))) { + SendMessage(posTrackBar, TBM_SETPOS, TRUE, newPos / sliderStepMs); + } } } -- 2.39.5