decoder/sidplay: fix playback speed with libsidplayfp

https://bugs.musicpd.org/view.php?id=4577
This commit is contained in:
Max Kellermann
2016-10-27 20:24:16 +02:00
parent 11ba44870b
commit 49c04ccfc7
2 changed files with 11 additions and 3 deletions

View File

@@ -354,12 +354,19 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
DecoderCommand cmd;
do {
short buffer[4096];
size_t nbytes;
nbytes = player.play(buffer, ARRAY_SIZE(buffer));
if (nbytes == 0)
const auto result = player.play(buffer, ARRAY_SIZE(buffer));
if (result <= 0)
break;
#ifdef HAVE_SIDPLAYFP
/* libsidplayfp returns the number of samples */
const size_t nbytes = result * sizeof(buffer[0]);
#else
/* libsidplay2 returns the number of bytes */
const size_t nbytes = result;
#endif
decoder_timestamp(decoder, (double)player.time() / timebase);
cmd = decoder_data(decoder, nullptr, buffer, nbytes, 0);