aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-14 00:15:04 +0100
committerMax Kellermann <max@duempel.org>2009-11-14 00:46:30 +0100
commit873025a495795c88880114f73b4fbba000670877 (patch)
treec142b72c8eacd273836bf00f6bcedc76081e4550 /src
parent409a3ed808ea111cd4c62ac71c66cef7b86615af (diff)
downloadmpd-873025a495795c88880114f73b4fbba000670877.tar.gz
mpd-873025a495795c88880114f73b4fbba000670877.tar.xz
mpd-873025a495795c88880114f73b4fbba000670877.zip
decoder/sidplay: correctly calculate floating point time
Internally, use only the integer time. When needed, convert it to a floating point seconds value.
Diffstat (limited to 'src')
-rw-r--r--src/decoder/sidplay_plugin.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/decoder/sidplay_plugin.cxx b/src/decoder/sidplay_plugin.cxx
index f88e5b582..b200eee3b 100644
--- a/src/decoder/sidplay_plugin.cxx
+++ b/src/decoder/sidplay_plugin.cxx
@@ -283,8 +283,10 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
/* .. and play */
- float data_time=0;
- int timebase=player.timebase();
+ unsigned data_time = 0;
+ const unsigned timebase = player.timebase();
+ song_len *= timebase;
+
enum decoder_command cmd;
do {
char buffer[4096];
@@ -295,12 +297,13 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
break;
cmd = decoder_data(decoder, NULL, buffer, nbytes,
- data_time, 0, NULL);
-
- data_time=player.time()/timebase;
+ (float)data_time / (float)timebase,
+ 0, NULL);
+ data_time = player.time();
if(cmd==DECODE_COMMAND_SEEK) {
- int target_time=decoder_seek_where(decoder);
+ unsigned target_time = (unsigned)
+ (decoder_seek_where(decoder) * timebase);
/* can't rewind so return to zero and seek forward */
if(target_time<data_time) {
@@ -313,13 +316,13 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
nbytes=player.play(buffer, sizeof(buffer));
if(nbytes==0)
break;
- data_time=player.time()/timebase;
+ data_time = player.time();
}
decoder_command_finished(decoder);
}
- if(song_len && data_time>=(float)song_len)
+ if (song_len > 0 && data_time >= song_len)
break;
} while (cmd != DECODE_COMMAND_STOP);