Skip to content

Commit

Permalink
Fix crash showing some plugins, cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Mar 23, 2024
1 parent 13e7437 commit 571d60b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/mod-ui
11 changes: 5 additions & 6 deletions src/plugin/DesktopPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DesktopPlugin : public Plugin,
String currentPedalboard;
bool startingJackd = false;
bool startingModUI = false;
bool processing = false;
std::atomic<bool> processing { false };
bool shouldStartRunner = true;
float parameters[kParameterCount] = {};
float* tempBuffers[2] = {};
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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");
Expand Down
20 changes: 7 additions & 13 deletions src/plugin/SharedMemory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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()
Expand All @@ -365,8 +361,6 @@ class SharedMemory
return wait();
}

// ----------------------------------------------------------------------------------------------------------------

private:
// ----------------------------------------------------------------------------------------------------------------
// shared memory details
Expand Down
8 changes: 4 additions & 4 deletions src/plugin/WebView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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};
Expand All @@ -63,7 +63,7 @@ void reloadWebView(void* const webview, uint)
{
WebViewImpl* const impl = static_cast<WebViewImpl*>(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)
Expand Down

0 comments on commit 571d60b

Please sign in to comment.