From 1767dc40a5f67213420654dd27611c331be34c66 Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Fri, 10 Jul 2020 22:25:50 +0200 Subject: [PATCH] Use SHA1 key for machine code cache. --- src/FaustEngine.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/FaustEngine.cpp b/src/FaustEngine.cpp index 75b73c4..df781e6 100644 --- a/src/FaustEngine.cpp +++ b/src/FaustEngine.cpp @@ -1,6 +1,8 @@ #include "ScriptEngine.hpp" #include +#include + #include #define kBufferSize 64 @@ -27,34 +29,33 @@ class FaustEngine : public ScriptEngine { int run(const std::string& path, const std::string& script) override { - std::string filename = path.substr(path.find_last_of("/")); #if defined ARCH_MAC - std::string tempDir = "/private/var/tmp/"; + std::string temp_cache = "/private/var/tmp/VCV_" + generateSHA1(script); #else - std::string tempDir = ""; + std::string temp_cache = "" + generateSHA1(script); #endif std::string error_msg; // Try to load the machine code cache - fDSPFactory = readDSPFactoryFromMachineFile(tempDir + filename, "", error_msg); + fDSPFactory = readDSPFactoryFromMachineFile(temp_cache, "", error_msg); if (!fDSPFactory) { // Otherwise recompile the DSP fDSPFactory = createDSPFactoryFromString("FaustDSP", script, 0, NULL, "", error_msg, -1); if (!fDSPFactory) { - display("ERROR: cannot create Faust factory !"); + display("ERROR: cannot create factory !"); return -1; } else { // And save the cache display("Compiling factory finished"); - writeDSPFactoryToMachineFile(fDSPFactory, tempDir + filename, ""); + writeDSPFactoryToMachineFile(fDSPFactory, temp_cache, ""); } } // Create DSP fDSP = fDSPFactory->createDSPInstance(); if (!fDSP) { - display("ERROR: cannot create Faust instance !"); + display("ERROR: cannot create instance !"); return -1; } else { display("Created DSP");