From 571d60b0ede4b2702a4fa2988e8151d74bb96357 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 23 Mar 2024 09:39:51 +0100 Subject: [PATCH] Fix crash showing some plugins, cleanup Signed-off-by: falkTX --- Makefile | 4 ++++ src/mod-ui | 2 +- src/plugin/DesktopPlugin.cpp | 11 +++++------ src/plugin/SharedMemory.hpp | 20 +++++++------------- src/plugin/WebView.mm | 8 ++++---- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 88108cf..f652f4d 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,7 @@ BOOTSTRAP_FILES = $(PAWPAW_PREFIX)/bin/cxfreeze-quickstart endif BOOTSTRAP_FILES += $(PAWPAW_PREFIX)/bin/jackd$(APP_EXT) BOOTSTRAP_FILES += $(PAWPAW_PREFIX)/include/armadillo +BOOTSTRAP_FILES += $(PAWPAW_PREFIX)/lib/jack/jack_mod-desktop$(SO_EXT) # --------------------------------------------------------------------------------------------------------------------- # List of files for mod-desktop packaging, often symlinks to the real files @@ -299,6 +300,9 @@ clean: rm -rf build-pedalboard rm -rf build-ui +jack: + ./utils/run.sh $(PAWPAW_TARGET) $(MAKE) HAVE_OPENGL=true NOOPT=true -C src/plugin jack + src/DPF/utils/lv2_ttl_generator$(APP_EXT): ./utils/run.sh $(PAWPAW_TARGET) $(MAKE) NOOPT=true -C src/DPF/utils/lv2-ttl-generator diff --git a/src/mod-ui b/src/mod-ui index a1e043c..5d52614 160000 --- a/src/mod-ui +++ b/src/mod-ui @@ -1 +1 @@ -Subproject commit a1e043cb5886fb61d193fd97ec49b280e63f1a5e +Subproject commit 5d52614d634a31cf7409ba537160b9baf21cfe6e diff --git a/src/plugin/DesktopPlugin.cpp b/src/plugin/DesktopPlugin.cpp index a66ff4e..59f9f93 100644 --- a/src/plugin/DesktopPlugin.cpp +++ b/src/plugin/DesktopPlugin.cpp @@ -24,7 +24,7 @@ class DesktopPlugin : public Plugin, String currentPedalboard; bool startingJackd = false; bool startingModUI = false; - bool processing = false; + std::atomic processing { false }; bool shouldStartRunner = true; float parameters[kParameterCount] = {}; float* tempBuffers[2] = {}; @@ -384,10 +384,6 @@ class DesktopPlugin : public Plugin, if (portBaseNum > 0 && run()) startRunner(500); } - else - { - shm.reset(); - } // make sure we have enough space to cover everything const double sampleRate = getSampleRate(); @@ -407,7 +403,7 @@ class DesktopPlugin : public Plugin, std::memset(tempBuffers[1], 0, sizeof(float) * numSamplesInTempBuffers); numSamplesUntilProcessing = d_isNotEqual(sampleRate, 48000.0) - ? d_nextPowerOf2(128.0 * (sampleRate / 48000.0)) + ? d_roundToUnsignedInt(128.0 * (sampleRate / 48000.0)) : 128; setLatency(numSamplesUntilProcessing); @@ -459,6 +455,9 @@ class DesktopPlugin : public Plugin, audioBufferIn.read(shmbuffers, 128); + // TODO bring back midi + shm.data->midiEventCount = 0; + if (! shm.process()) { d_stdout("shm processing failed"); diff --git a/src/plugin/SharedMemory.hpp b/src/plugin/SharedMemory.hpp index 3e28b81..ac582b5 100644 --- a/src/plugin/SharedMemory.hpp +++ b/src/plugin/SharedMemory.hpp @@ -326,21 +326,14 @@ class SharedMemory // ---------------------------------------------------------------------------------------------------------------- - void reset() + bool sync() { if (data == nullptr) - return; + return false; data->midiEventCount = 0; std::memset(data->audio, 0, sizeof(float) * 128 * 2); - } - bool sync() - { - if (data == nullptr) - return false; - - reset(); post(); return wait(); } @@ -351,9 +344,12 @@ class SharedMemory return; data->magic = 7331; + data->midiEventCount = 0; + std::memset(data->audio, 0, sizeof(float) * 128 * 2); + post(); - wait(); - data->magic = 1337; + if (wait()) + data->magic = 1337; } bool process() @@ -365,8 +361,6 @@ class SharedMemory return wait(); } - // ---------------------------------------------------------------------------------------------------------------- - private: // ---------------------------------------------------------------------------------------------------------------- // shared memory details diff --git a/src/plugin/WebView.mm b/src/plugin/WebView.mm index 1b7bb2f..e1ab108 100644 --- a/src/plugin/WebView.mm +++ b/src/plugin/WebView.mm @@ -29,8 +29,8 @@ DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT - kVerticalOffset); - WKWebView* const webview = [[WKWebView alloc] initWithFrame: rect]; - [[[webview configuration] preferences] setValue: @(true) forKey: @"developerExtrasEnabled"]; + WKWebView* const webview = [[WKWebView alloc] initWithFrame:rect]; + [[[webview configuration] preferences] setValue:@(true) forKey:@"developerExtrasEnabled"]; [view addSubview:webview]; char url[32]; @@ -42,7 +42,7 @@ NSURLRequest* const urlreq = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: nsurl]]; [nsurl release]; - [webview loadRequest: urlreq]; + [webview loadRequest:urlreq]; [webview setHidden:NO]; return new WebViewImpl{view, webview, urlreq}; @@ -63,7 +63,7 @@ void reloadWebView(void* const webview, uint) { WebViewImpl* const impl = static_cast(webview); - [impl->webview loadRequest: impl->urlreq]; + [impl->webview loadRequest:impl->urlreq]; } void resizeWebView(void* const webview, const uint offset, const uint width, const uint height)