From b60a5462b77ff98e10d5e8feed3fd1bf3b52dc8f Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 27 Jul 2022 21:38:22 -0700 Subject: [PATCH] [SID Input] Add static initializer for residfp The SID builder needs a static initializer, otherwise multiple instances created simultaneously, such as during populating info on adding a lot of tracks, will race and crash the player. Signed-off-by: Christopher Snowhill --- Plugins/sidplay/SidDecoder.mm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Plugins/sidplay/SidDecoder.mm b/Plugins/sidplay/SidDecoder.mm index 3ef8a6668..b04107250 100644 --- a/Plugins/sidplay/SidDecoder.mm +++ b/Plugins/sidplay/SidDecoder.mm @@ -160,6 +160,22 @@ static void sidTuneLoader(const char *fileName, std::vector &bufferRef) @implementation SidDecoder +// Need this static initializer to create the static global tables that sidplayfp doesn't really lock access to ++ (void)initialize { + ReSIDfpBuilder *builder = new ReSIDfpBuilder("ReSIDfp"); + + if(builder) { + builder->create(1); + if(builder->getStatus()) { + builder->filter(true); + builder->filter6581Curve(0.5); + builder->filter8580Curve(0.5); + } + + delete builder; + } +} + - (BOOL)open:(id)s { if(![s seekable]) return NO;