From 1859ba5ec81de2bb2a2660030748c1b915db0631 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 7 Nov 2016 08:53:57 +0100 Subject: [PATCH 1/5] output/winmm: 8 bit playback is not supported Everything must be S16. --- NEWS | 2 ++ src/output/plugins/WinmmOutputPlugin.cxx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0f11eea76..68d33c2b7 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ ver 0.19.20 (not yet released) * decoder - ffmpeg: ignore empty packets - sidplay: fix playback speed with libsidplayfp +* output + - winmm: fix 8 bit playback ver 0.19.19 (2016/08/23) * decoder diff --git a/src/output/plugins/WinmmOutputPlugin.cxx b/src/output/plugins/WinmmOutputPlugin.cxx index e5c5a6f0c..1d54aaf6b 100644 --- a/src/output/plugins/WinmmOutputPlugin.cxx +++ b/src/output/plugins/WinmmOutputPlugin.cxx @@ -148,10 +148,10 @@ winmm_output_open(AudioOutput *ao, AudioFormat &audio_format, } switch (audio_format.format) { - case SampleFormat::S8: case SampleFormat::S16: break; + case SampleFormat::S8: case SampleFormat::S24_P32: case SampleFormat::S32: case SampleFormat::FLOAT: From 5c3e55b5b18fd35e987b1abc662fdc4aa3d6c9c0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Nov 2016 19:50:38 +0100 Subject: [PATCH 2/5] {input,output}/alsa: fix gcc 7.0 -Wimplicit-fallthrough --- NEWS | 1 + src/input/plugins/AlsaInputPlugin.cxx | 4 ++++ src/output/plugins/AlsaOutputPlugin.cxx | 3 +++ 3 files changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 68d33c2b7..ebd959a6e 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ver 0.19.20 (not yet released) - sidplay: fix playback speed with libsidplayfp * output - winmm: fix 8 bit playback +* fix gcc 7.0 -Wimplicit-fallthrough ver 0.19.19 (2016/08/23) * decoder diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx index f03f745c6..e5d1ae024 100644 --- a/src/input/plugins/AlsaInputPlugin.cxx +++ b/src/input/plugins/AlsaInputPlugin.cxx @@ -247,6 +247,10 @@ AlsaInputStream::Recover(int err) case -EPIPE: LogDebug(alsa_input_domain, "Buffer Overrun"); // drop through +#if GCC_CHECK_VERSION(7,0) + [[fallthrough]]; +#endif + case -ESTRPIPE: case -EINTR: err = snd_pcm_recover(capture_handle, err, 1); diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 28c374a00..14eaeeb5f 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -760,6 +760,9 @@ alsa_recover(AlsaOutput *ad, int err) if (err == -EAGAIN) return 0; /* fall-through to snd_pcm_prepare: */ +#if GCC_CHECK_VERSION(7,0) + [[fallthrough]]; +#endif case SND_PCM_STATE_SETUP: case SND_PCM_STATE_XRUN: ad->period_position = 0; From 521c6da8300ae5340b5858d1e7629ccb63143d43 Mon Sep 17 00:00:00 2001 From: Wieland Hoffmann Date: Fri, 4 Nov 2016 19:54:13 +0100 Subject: [PATCH 3/5] =?UTF-8?q?doc/protocol:=20UTF=3D8=20=E2=86=92=20UTF-8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/protocol.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/protocol.xml b/doc/protocol.xml index ac78ab8ae..69bbc3b2f 100644 --- a/doc/protocol.xml +++ b/doc/protocol.xml @@ -66,7 +66,7 @@ strcpy just fine with UTF-8 encoded strings. For example: OK encoded in UTF-8 is simply OK. For more - information on UTF=8: + information on UTF-8: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8) From 8bde47280ae4a6bdb39a9e1b527aec2d15601710 Mon Sep 17 00:00:00 2001 From: Wieland Hoffmann Date: Fri, 4 Nov 2016 20:04:36 +0100 Subject: [PATCH 4/5] doc/protocol: Turn the link to the UTF-8 FAQ into a ulink element --- doc/protocol.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/protocol.xml b/doc/protocol.xml index 69bbc3b2f..c36c29a6b 100644 --- a/doc/protocol.xml +++ b/doc/protocol.xml @@ -67,7 +67,7 @@ strings. For example: OK encoded in UTF-8 is simply OK. For more information on UTF-8: - http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8) + ) From 7019f6bea455f0d843131ec5b88cf057ebba5058 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 17 Nov 2016 21:58:27 +0100 Subject: [PATCH 5/5] decoder/pcm: round buffer size down to nearest frame size https://bugs.musicpd.org/view.php?id=4599 --- NEWS | 1 + src/decoder/plugins/PcmDecoderPlugin.cxx | 45 +++++++++++++++++------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index ebd959a6e..f426c29cb 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.19.20 (not yet released) * decoder - ffmpeg: ignore empty packets + - pcm: fix corruption bug with partial frames (after short read) - sidplay: fix playback speed with libsidplayfp * output - winmm: fix 8 bit playback diff --git a/src/decoder/plugins/PcmDecoderPlugin.cxx b/src/decoder/plugins/PcmDecoderPlugin.cxx index c07a7b9b1..8e12412c5 100644 --- a/src/decoder/plugins/PcmDecoderPlugin.cxx +++ b/src/decoder/plugins/PcmDecoderPlugin.cxx @@ -23,10 +23,28 @@ #include "input/InputStream.hxx" #include "util/Error.hxx" #include "util/ByteReverse.hxx" +#include "util/StaticFifoBuffer.hxx" #include "Log.hxx" +#include #include +template +static bool +FillBuffer(Decoder &decoder, InputStream &is, B &buffer) +{ + buffer.Shift(); + auto w = buffer.Write(); + assert(!w.IsEmpty()); + + size_t nbytes = decoder_read(decoder, is, w.data, w.size); + if (nbytes == 0 && is.LockIsEOF()) + return false; + + buffer.Append(nbytes); + return true; +} + static void pcm_stream_decode(Decoder &decoder, InputStream &is) { @@ -50,25 +68,27 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) decoder_initialized(decoder, audio_format, is.IsSeekable(), total_time); + StaticFifoBuffer buffer; + DecoderCommand cmd; do { - char buffer[4096]; - - size_t nbytes = decoder_read(decoder, is, - buffer, sizeof(buffer)); - - if (nbytes == 0 && is.LockIsEOF()) + if (!FillBuffer(decoder, is, buffer)) break; + auto r = buffer.Read(); + /* round down to the nearest frame size, because we + must not pass partial frames to decoder_data() */ + r.size -= r.size % frame_size; + buffer.Consume(r.size); + if (reverse_endian) /* make sure we deliver samples in host byte order */ - reverse_bytes_16((uint16_t *)buffer, - (uint16_t *)buffer, - (uint16_t *)(buffer + nbytes)); + reverse_bytes_16((uint16_t *)r.data, + (uint16_t *)r.data, + (uint16_t *)(r.data + r.size)); - cmd = nbytes > 0 - ? decoder_data(decoder, is, - buffer, nbytes, 0) + cmd = !r.IsEmpty() + ? decoder_data(decoder, is, r.data, r.size, 0) : decoder_get_command(decoder); if (cmd == DecoderCommand::SEEK) { uint64_t frame = decoder_seek_where_frame(decoder); @@ -76,6 +96,7 @@ pcm_stream_decode(Decoder &decoder, InputStream &is) Error error; if (is.LockSeek(offset, error)) { + buffer.Clear(); decoder_command_finished(decoder); } else { LogError(error);