Avoid RT-unsafe allocations on HostMIDI-Map
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
21004ab183
commit
d8a341be95
3 changed files with 19 additions and 22 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "plugincontext.hpp"
|
#include "plugincontext.hpp"
|
||||||
|
#include "ModuleWidgets.hpp"
|
||||||
#include "Widgets.hpp"
|
#include "Widgets.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
@ -34,7 +35,7 @@
|
||||||
|
|
||||||
USE_NAMESPACE_DISTRHO;
|
USE_NAMESPACE_DISTRHO;
|
||||||
|
|
||||||
static const int MAX_MIDI_CONTROL = 120; /* 0x77 + 1 */
|
static constexpr const int MAX_MIDI_CONTROL = 120; /* 0x77 + 1 */
|
||||||
|
|
||||||
struct HostMIDIMap : TerminalModule {
|
struct HostMIDIMap : TerminalModule {
|
||||||
enum ParamIds {
|
enum ParamIds {
|
||||||
|
|
@ -93,6 +94,7 @@ struct HostMIDIMap : TerminalModule {
|
||||||
for (int id = 0; id < MAX_MIDI_CONTROL; ++id)
|
for (int id = 0; id < MAX_MIDI_CONTROL; ++id)
|
||||||
{
|
{
|
||||||
paramHandles[id].color = nvgRGBf(0.76f, 0.11f, 0.22f);
|
paramHandles[id].color = nvgRGBf(0.76f, 0.11f, 0.22f);
|
||||||
|
paramHandles[id].text.reserve(25);
|
||||||
pcontext->engine->addParamHandle(¶mHandles[id]);
|
pcontext->engine->addParamHandle(¶mHandles[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,15 +368,17 @@ struct HostMIDIMap : TerminalModule {
|
||||||
nextLearningId = learningId = -1;
|
nextLearningId = learningId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME this allocates string during RT!!
|
// this is called during RT!!
|
||||||
void refreshParamHandleText(const int id)
|
void refreshParamHandleText(const int id)
|
||||||
{
|
{
|
||||||
std::string text;
|
char textBuf[25];
|
||||||
|
|
||||||
if (ccs[id] >= 0)
|
if (ccs[id] >= 0)
|
||||||
text = string::f("CC%02d", ccs[id]);
|
std::sprintf(textBuf, "CC%02d", ccs[id]);
|
||||||
else
|
else
|
||||||
text = "MIDI-Map";
|
std::strcpy(textBuf, "MIDI-Map");
|
||||||
paramHandles[id].text = text;
|
|
||||||
|
paramHandles[id].text.assign(textBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMapLen()
|
void updateMapLen()
|
||||||
|
|
@ -679,7 +683,7 @@ struct HostMIDIMapDisplay : Widget {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HostMIDIMapWidget : ModuleWidget {
|
struct HostMIDIMapWidget : ModuleWidgetWith11HP {
|
||||||
HostMIDIMap* const module;
|
HostMIDIMap* const module;
|
||||||
|
|
||||||
HostMIDIMapWidget(HostMIDIMap* const m)
|
HostMIDIMapWidget(HostMIDIMap* const m)
|
||||||
|
|
@ -687,11 +691,7 @@ struct HostMIDIMapWidget : ModuleWidget {
|
||||||
{
|
{
|
||||||
setModule(m);
|
setModule(m);
|
||||||
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostMIDIMap.svg")));
|
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostMIDIMap.svg")));
|
||||||
|
createAndAddScrews();
|
||||||
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
|
|
||||||
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
|
|
||||||
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
|
||||||
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
|
||||||
|
|
||||||
HostMIDIMapDisplay* const display = createWidget<HostMIDIMapDisplay>(Vec(1.0f, 71.0f));
|
HostMIDIMapDisplay* const display = createWidget<HostMIDIMapDisplay>(Vec(1.0f, 71.0f));
|
||||||
display->box.size = Vec(box.size.x - 2.0f, box.size.y - 89.0f);
|
display->box.size = Vec(box.size.x - 2.0f, box.size.y - 89.0f);
|
||||||
|
|
@ -701,13 +701,8 @@ struct HostMIDIMapWidget : ModuleWidget {
|
||||||
|
|
||||||
void draw(const DrawArgs& args) override
|
void draw(const DrawArgs& args) override
|
||||||
{
|
{
|
||||||
nvgBeginPath(args.vg);
|
drawBackground(args.vg);
|
||||||
nvgRect(args.vg, 0, 0, box.size.x, box.size.y);
|
ModuleWidgetWith11HP::draw(args);
|
||||||
nvgFillPaint(args.vg, nvgLinearGradient(args.vg, 0, 0, 0, box.size.y,
|
|
||||||
nvgRGB(0x18, 0x19, 0x19), nvgRGB(0x21, 0x22, 0x22)));
|
|
||||||
nvgFill(args.vg);
|
|
||||||
|
|
||||||
ModuleWidget::draw(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendContextMenu(Menu* const menu) override
|
void appendContextMenu(Menu* const menu) override
|
||||||
|
|
|
||||||
|
|
@ -95,3 +95,4 @@ struct ModuleWidgetWithSideScrews : ModuleWidget {
|
||||||
typedef ModuleWidgetWithSideScrews<3> ModuleWidgetWith3HP;
|
typedef ModuleWidgetWithSideScrews<3> ModuleWidgetWith3HP;
|
||||||
typedef ModuleWidgetWithSideScrews<8> ModuleWidgetWith8HP;
|
typedef ModuleWidgetWithSideScrews<8> ModuleWidgetWith8HP;
|
||||||
typedef ModuleWidgetWithSideScrews<9> ModuleWidgetWith9HP;
|
typedef ModuleWidgetWithSideScrews<9> ModuleWidgetWith9HP;
|
||||||
|
typedef ModuleWidgetWithSideScrews<11> ModuleWidgetWith11HP;
|
||||||
|
|
|
||||||
|
|
@ -377,8 +377,9 @@ struct OpenGlWidgetWithBrowserPreview : OpenGlWidget {
|
||||||
fb = nvgluCreateFramebuffer(args.vg, box.size.x * oversample, box.size.y * oversample, 0);
|
fb = nvgluCreateFramebuffer(args.vg, box.size.x * oversample, box.size.y * oversample, 0);
|
||||||
DISTRHO_SAFE_ASSERT_RETURN(fb != nullptr,);
|
DISTRHO_SAFE_ASSERT_RETURN(fb != nullptr,);
|
||||||
|
|
||||||
// draw our special framebuffer
|
|
||||||
nvgluBindFramebuffer(fb);
|
nvgluBindFramebuffer(fb);
|
||||||
|
|
||||||
|
// draw our special framebuffer
|
||||||
drawFramebufferForBrowserPreview();
|
drawFramebufferForBrowserPreview();
|
||||||
|
|
||||||
// reset to regular framebuffer
|
// reset to regular framebuffer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue