From 0fb147aa0d43277c6420681d69b76f0262d06788 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 29 May 2019 18:49:09 +0000 Subject: [PATCH] Change the sound buffer size to a power of 2 Turns out giving SDL2 a non-power-of-2 buffer size crashes it in Emscripten. --- src/Sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sound.cpp b/src/Sound.cpp index 2fb0c828..d4f22320 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -16,9 +16,9 @@ #define FREQUENCY 44100 #ifdef RASPBERRY_PI -#define STREAM_SIZE 0x400 +#define STREAM_SIZE 0x400 // Larger buffer to prevent stutter #else -#define STREAM_SIZE (FREQUENCY / 200) +#define STREAM_SIZE 0x100 // FREQUENCY/200 rounded to the nearest power of 2 (SDL2 *needs* a power-of-2 buffer size) #endif #define clamp(x, y, z) (((x) > (z)) ? (z) : ((x) < (y)) ? (y) : (x))