From b44d3faa1c926204643d41eb1dac31a3ec301029 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 28 Jul 2019 21:29:09 +0200 Subject: [PATCH] LibAudio: WAV: Don't emit the very last sample in each decoded batch. This is a total hack, because I haven't really looked into why these are happening. Somehow we're producing one extra sample and it's glitching up the sound stream ever so slightly. --- Libraries/LibAudio/AWavLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/LibAudio/AWavLoader.cpp b/Libraries/LibAudio/AWavLoader.cpp index 2b28f8c219..93e6a2bd17 100644 --- a/Libraries/LibAudio/AWavLoader.cpp +++ b/Libraries/LibAudio/AWavLoader.cpp @@ -257,5 +257,10 @@ RefPtr ABuffer::from_pcm_data(ByteBuffer& data, int num_channels, int b // don't belong. ASSERT(!stream.handle_read_failure()); + // HACK: This is a total hack to remove an unnecessary sample at the end of the buffer. + // FIXME: Don't generate the extra sample... :^) + for (int i = 0; i < 1; ++i) + fdata.take_last(); + return ABuffer::create_with_samples(move(fdata)); }