From 5e6d138b5e5a2ec72e4a290463ba4f1a7ef0daf8 Mon Sep 17 00:00:00 2001 From: Mark Calderbank Date: Wed, 21 Mar 2007 23:08:38 +0000 Subject: [PATCH] Fix rounding error in radio playback navigation --- playerradio.cc | 8 ++++---- playerradio.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/playerradio.cc b/playerradio.cc index 448e4dd..4cb3665 100644 --- a/playerradio.cc +++ b/playerradio.cc @@ -246,7 +246,7 @@ void PlayerRadio::jumpToPercent(double percent) unLock(); } -void PlayerRadio::skipForward(int seconds) +void PlayerRadio::skipForward(UINT seconds) { lock(); logger->log("PlayerRadio", Log::DEBUG, "SKIP FORWARD %i SECONDS", seconds); @@ -256,13 +256,13 @@ void PlayerRadio::skipForward(int seconds) if (currentSeconds == 0) { unLock(); return; } // div by zero if (currentPacket == 0) { unLock(); return; } // Current pos from demuxer is not valid - ULONG newPacket = demuxer->getPacketNum() / currentSeconds * (currentSeconds + seconds); + ULONG newPacket = currentPacket + (currentPacket * seconds / currentSeconds); if (newPacket > lengthPackets) { switchState(S_PLAY); unLock(); } else switchState(S_JUMP, newPacket); unLock(); } -void PlayerRadio::skipBackward(int seconds) // FIXME why are these signed?! +void PlayerRadio::skipBackward(UINT seconds) { lock(); logger->log("PlayerRadio", Log::DEBUG, "SKIP BACKWARD %i SECONDS", seconds); @@ -277,7 +277,7 @@ void PlayerRadio::skipBackward(int seconds) // FIXME why are these signed?! if ((UINT)seconds > currentSeconds) newPacket = 0; else - newPacket = demuxer->getPacketNum() / currentSeconds * (currentSeconds - seconds); + newPacket = currentPacket - (currentPacket * seconds / currentSeconds); switchState(S_JUMP, newPacket); unLock(); diff --git a/playerradio.h b/playerradio.h index cb4802a..863ea91 100644 --- a/playerradio.h +++ b/playerradio.h @@ -60,8 +60,8 @@ class PlayerRadio : public Thread_TYPE, public Callback void stop(); void pause(); void jumpToPercent(double percent); - void skipForward(int seconds); - void skipBackward(int seconds); + void skipForward(UINT seconds); + void skipBackward(UINT seconds); UCHAR getState() { return state; } ULONG getCurrentSeconds(); -- 2.39.5